in reply to Look ahead and comp if pattern matches next line
Hope this helps.my @records = (); my %current = (); while (<FILE>) { my @line = split /\s*\|/; if ($line[0] =~ /^\S/) { if (keys %current) { push @records, {%current}; %current = (); } @current{qw/name var1 var2 var3/} = @line; } elsif ($line[0] =~ /^ (.*)/) { $current{name} .= $1; } else { # Deal with the other lines as you need to.. } } push @records, {%current};
perl -e 'print "I love $^X$\"$]!$/"#$&V"+@( NO CARRIER'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Look ahead and comp if pattern matches next line
by Er1kW (Initiate) on Apr 28, 2001 at 03:38 UTC |