Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Editing just one column in a file

by ZWcarp (Beadle)
on Nov 30, 2011 at 20:23 UTC ( #940931=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Editing just one column in a file
in thread Editing just one column in a file

Why is it that this

 perl -lane '$,="\t"; print @F[0..4] ."\t\t\t" . @F[25..30]' file.txt

Does not do what I intended ( for the ranges to be printed by tabs, followed by three blank columns followed by another range). Thankyou for your help!


Comment on Re^4: Editing just one column in a file
Download Code
Re^5: Editing just one column in a file
by BrowserUk (Pope) on Nov 30, 2011 at 21:12 UTC

    Because $, is the character used when you give a list of values to the print statement, but you've used '.'s.

    Ie. You're giving the print statement a single (concatenated) value, therefore the item separator is never used.

    This might achieve your goal:

    perl -lane '$,="\t"; print @F[0..4], "\t\t\t", @F[25..30]' file.txt

    but "three blank columns" is a very nebulous concept.

    Update: FTR, I might code that as:

    print join "\t", @F[0..4], ('')x3, @F[25..30];

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://940931]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-09-20 01:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (151 votes), past polls