http://qs321.pair.com?node_id=674155

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I have to read lines from a log file which begins with // with some white spaces before and put them in a array so below is the code what i could write and this works. But i want to know if i can remove the spaces before pushing into array instead of using s/^\s+//g; in foreach loop while printing and also i want to ignore the lines with -// which is getting included.

open (FH,"$file") || die ("could not openfile"); my @arr; while (<FH>) { chomp; push @arr , $_ unless $_ !~ /\s+\/\// ; } foreach (@arr){ s/^\s+//g; s/^-\/\/.+//g; print $_."\n"; } Thanks in advance.