SPUG: How do -aF"\t" in DOS/Windoze?

ced at carios2.ca.boeing.com ced at carios2.ca.boeing.com
Mon Jul 16 21:52:11 CDT 2001


> So somebody please tell me how to write scripts for the ActivePerl I
> downloaded only yesterday to a Win95 box!  Although the "perldoc perlrun"
> documentation promises that you can use /, ", or " on the shebang line
> to enclose the field-separators for the -F option, none of these works for me.

> "perl -wlnaFx" works to make the field-separator x, but nothing more
> elaborate works;  I either get a syntax error, or no splitting on the
> specified delimiter,  using:

> perl -wlnaF'x'
> perl -wlnaF"x"
> perl -wlnaF/x/
> perl -wlnaF\"x\", etc.

> Although I was embarrassed, I even tried doubling the quotes,
> thinking DOS might be confusing itself with VMS, to no avail:

> perl -wlnaF''x''
> perl -wlnaF""x""

> And once I get that figured out, I'd like to add the -i option, with it's
> own argument, which I can't even make work on Linux:

I'm not sure about the quoting issue you're seeing but I don't think
-i works with -p or -n since Win32 won't rename a file that's been 
opened for reading. I can only think of cumbersome workarounds
but maybe there's a slick alternative.

> # Trying to "shebangify" following one-liner:
> /usr/bin/perl -wlnaF' ' -i'.bak' -e 'print "$F[0]\n"' 

> # Here are some attempts, and their errors (OpenLinux 2.2.18; perl 5.6.0)

> #! /usr/bin/perl -wlnaF' ' -i'.bak'
> Unrecognized file test: -i at s line 1.

> #! /usr/bin/perl -wlnaF' ' -i.bak
> Unrecognized file test: -i at s line 1.

> (Does it think that second argument is the *program* ?)

> #! /usr/bin/perl -wlnaF' 'i.bak

> Bareword found where operator expected at s line 1, near "' 'i"
> 	(Missing operator before i?)
> Unquoted string "i" may clash with future reserved word at s line 1.
> syntax error at s line 1, near "' 'i"
> Unquoted string "bak" may clash with future reserved word at s line 1.
> Execution of s aborted due to compilation errors.
> 
> #! /usr/bin/perl -wlnaF' 'i.bak
> 
> This one doesn't generate nay errors, but it doesn't split on <SP> either:
> #! /usr/bin/perl -wlnaF/ /i.bak
> 
> Can somebody please tell me the correct syntax to a) on Linux, include 
> two options on the shebang line that require corresponding arguments,
> that might need quoting, and b) on Dos/Windoze, supply a non-printing
> ( <TAB> )  or special ( \t) character as the argument of -F.
> 

Dang, I don't have Linux/bash handy but the following worked on 
Solaris/ksh.  

#!/usr/bin/perl -lawn -i.bak -F\t

(I noticed though the -a pattern will split on whitespace exactly 
like split " " though so the alternate field specifier shouldn't 
be necessary though in one of the cases above)


Rgds,
--
Charles

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list