in reply to Why doesn't this work?
For me, your first example works:
C:\Dokumente und Einstellungen\corion>perl -MData::Dumper -e "{$_=[];l +ocal $/=qq(\n); @$_=<>};warn Dumper $_; my $count=@$_; print $count, +' lines';" \boot.ini $VAR1 = [ '[boot loader] ', ... ]; 5 lines
while the second one does always output "1 lines". This is the special behaviour of split. To make split produce more results than needed on the left hand side, you need to give it a LIMIT. Also, you will want to call split in list context using this operator =()=:
> perl -e "{$/=undef, $_=<>} my $count=()=split /\n/,$_,-1; print $cou +nt" \boot.ini 6
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why doesn't this work?
by perl-diddler (Chaplain) on Apr 12, 2013 at 21:55 UTC | |
by Corion (Patriarch) on Apr 12, 2013 at 22:05 UTC |