split is another handy function in perl to split lines into list of space seperated words by default.We can use any delimiter to split any part of line.
For example:
For example:
while( my $line = <fh> ) { chomp($line); $line =~ s/^\s+//; # trim leading space $line =~ s/\s+$//; # trim trailing space $line =~ s/^\s+$//; # trim blank lines next unless($line); # if line is undef skip it next if ($line =~ /^#/); #ignore comment lines @Iline = split(/[=&]/,$line,3); #printing the first three matching fields of the line print "@Iline \n"; }
No comments:
Post a Comment