Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: parsing text file

by ViceRaid (Chaplain)
on Apr 08, 2002 at 17:09 UTC ( [id://157484]=note: print w/replies, xml ) Need Help??


in reply to parsing text file

hi

Assuming that

  1. $line is a line you've read from your text file, and that
  2. a newline is your record delimiter, and that
  3. your fields' content never contains tabs:
$line =~ s/\t+/\t/g;

The + modifier to the \t tells the regular expression to find one or more of the preceding thingie (in this case, a tab). The g modifier at the end tells the regular expression to perform the substitution on all occurrences of the match.

HTH

//=\\

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-23 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found