--- Tor Hildrum <[EMAIL PROTECTED]> wrote:
> Hi there, I just have a little peculiarity that I am wondering about.
> 
> The following code works as expected:
> #!/usr/bin/perl
> 
> while(<>)
> {
>      @F = split('');
> 
>      print map unpack("B8",$_),@F;
> }
> 
> Test run:
> tor% ./test.pl
> abc
> 01100001011000100110001100001010*
> 
> BUT:
> tor% perl -aF'' -ne 'print map{unpack"B8",[EMAIL PROTECTED]'
> does not.
> 
> tor% perl -aF'' -ne 'print map{unpack"B8",[EMAIL PROTECTED]'
> abc
> 01100001
> 
> Doesn't autosplit or -F work as described in perlrun?

Firstly you're not passing a parameter to perl's -F. '' is 
interpreted by the shell to mean 'the empty string', so what 
follows the F is the empty string.

To pass literal quotes to the program (perl) you need to 
escape them stick them or stick them in quotes:

bash-2.05a$ perl -aF"''" -ne 'print map{unpack"B8",[EMAIL PROTECTED]'
abc
01100001011000100110001100001010

bash-2.05a$ perl -aF'""' -ne 'print map{unpack"B8",[EMAIL PROTECTED]'
abc
01100001011000100110001100001010

bash-2.05a$ perl -aF\"\" -ne 'print map{unpack"B8",[EMAIL PROTECTED]'
abc
01100001011000100110001100001010

bash-2.05a$ perl -aF\'\' -ne 'print map{unpack"B8",[EMAIL PROTECTED]'
abc
01100001011000100110001100001010



However, you also have the option of achieving the same effect 
without using quoe characters to bound the -F regexp, so none 
of the above are desirable for perl golfing.

Phil

=====
When inserting a CD, hold down shift to stop the AutoRun feature
In the Device Manager, disable the SbcpHid device.
http://www.cs.princeton.edu/~jhalderm/cd3/

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

Reply via email to