On 2/25/2004 9:29 PM, Balaji Thoguluva wrote:

Hi,
I have a question on pattern matching. Assume I have a line like this consisting of header field(via) and values(IPaddress) repeated like below
via: 192.168.6.100; via:192.168.6.101; via: 203.290.89.90; ......so on
I would like to know how many via: header field occur and to get each via header field value. I want to know how to loop through each via header field to extract the value by pattern matching expressions.

There are alternatives to using regexs:


#!/usr/bin/perl
use strict;
use warnings;

#chomp(my $header = <DATA>);
#my @via = split /;\s*/, $header;
#s/^via:\s*// for @via;

# -or-

#my @via = map { s/^via:\s*//; $_ }
#          split /;\s*/, scalar <DATA>;

print join "\n", @via;

__DATA__
via: 192.168.6.100; via:192.168.6.101; via: 203.290.89.90;



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to