Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Text Massage

by citromatik (Curate)
on Apr 07, 2009 at 23:21 UTC ( [id://756182]=note: print w/replies, xml ) Need Help??


in reply to Text Massage

This is what I understand from your explanation:

  • You want to get rid of the first line of the file
  • and for the rest of the lines, put each element in a separate line and add a blank after each original "row".

This is some (untested) code to do this:

open my $infh, "<", "old.txt" or die $!; open my $outfh, ">", "new.txt" or die $!; <$infh>; # Discard the first line while (<$infh>) { chomp; s/\t/\n/; print {$outfh} "$_\n"; } close $infh; close $outfh;

I am asuming that the records are separated by tabs. The first line can also be discarded inside the while loop by using the $. variable (see perlvar: next unless $. == 1).

If I haven't understand you correctly, please let me know

citromatik

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-20 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found