Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
You didn't try that, did you? It's not going to work. See, if $F is interpolated by the shell, you end up with:
join(t, @F)
This is wrong on several accounts. First, inside the one-liner, you need to place quotes around $F, otherwise, at best you end up with bare words, but more likely, you end up with something that cannot be compiled (Try F=":") for instance. Second, the shell doesn't know "\t" as something special. It just sees an escaped t, and hence, F="\t" is equivalent to "t".

Also, the command line switches -line won't do what you expect it to do. It means "chomp of newlines, and add newlines to print, and modify the input file, leaving a backup with extension 'ne'".

You probably want (untested):

F=' ' # Enter a tab here. perl -F"$F" -i -wlne "munge(@F); print join('$F',@F);" file

But you can to better, it can also work if you want to use single quotes for the one liner. The shell's quoting mechanism are superior to Perls in some expects. Exploit them:

perl -F"$F" -i -wlpe 'munge(@F); $_ = join("'$F'",@F);'

In reply to Re^2: Does Perl 5 (or 6?) need another built-in variable for the -F switch? by Anonymous Monk
in thread Does Perl 5 (or 6?) need another built-in variable for the -F switch? by japhy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-03-29 00:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found