bfilipow has asked for the wisdom of the Perl Monks concerning the following question:
Esteemed Monks,
I have a problem with -F switch. I HAVE gone through one-liner perldocumentation.
Assume I want to write every second character from input. I wrote code which works fine:
ls -al | perl -lne '@F=split //; $i=0; @a = map {$i++%2 ? $_ : " "} @F; print @a;'But my question is why the code below does not work? I.e. it produces blank output:
ls -al | perl -F// -lne '$i=0; @a = map {$i++%2 ? $_ : " "} @F; print @a;'perl -h clearly states that:
-F/pattern/ split() pattern for -a switch (//'s are optional)and -a is described as:
-a autosplit mode with -n or -p (splits $_ into @F)I use "perl, v5.8.3 built for x86_64-linux-thread-multi"
Thank you for your patience,
bfilipow-the-wisdom-seeker
Thank you again wise monks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl oneliner problem with -F switch
by McDarren (Abbot) on Dec 02, 2005 at 09:37 UTC | |
|
Re: Perl oneliner problem with -F switch
by Fang (Pilgrim) on Dec 02, 2005 at 09:37 UTC | |
|
Re: Perl oneliner problem with -F switch
by sauoq (Abbot) on Dec 02, 2005 at 09:38 UTC |