Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Placing text onto multiple lines

by Limbic~Region (Chancellor)
on May 11, 2003 at 22:33 UTC ( [id://257294]=note: print w/replies, xml ) Need Help??


in reply to Placing text onto multiple lines

Anonymous Monk,
This seems like what you want, but if not - say so and I will try something else:

#!/usr/bin/perl -w use strict; open (INPUT,"jobs.txt") or die "Unable to open input : $!"; open (OUTPUT,"jobs.txt") or die "Unable to open output : $!"; select OUTPUT; $\ = "\n"; while (<INPUT>) { chomp; my @fields = split /\t/; unless (@fields > 2) { print join "\t" , @fields; } else { my $firstfield = shift @fields; while (my $nextfield = shift @fields) { print $firstfield, "\t", $nextfield; } } } close INPUT; close OUTPUT;

Cheers - L~R

Update: Both vladb++ and pzbagel++ have simpler solutions than this. The only thing I would point out is you said tab delimited.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2025-05-21 14:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.