Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Placing text onto multiple lines

by Limbic~Region (Chancellor)
on May 11, 2003 at 22:33 UTC ( #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? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2023-01-28 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?