Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Why do spaces keep getting added after I print the elements of an array?

by chipmunk (Parson)
on Jun 28, 2001 at 01:53 UTC ( [id://92081]=note: print w/replies, xml ) Need Help??


in reply to Why do spaces keep getting added after I print the elements of an array?

The issue with $" has already been answered, but I just wanted to put out something about the regex you're splitting on: my @record = split /(["<",">"])/; You've got a character class there, with some redundant characters. It's actually equivalent to the character class ["<>,]. I'm not sure if that's what you meant with the quotes and the comma. You're also getting the delimiters in your resulting array, because of the capturing parens in the regex.

Here's another way of solving the problem, that I think is a tiny bit simpler:

while (<OLDFILE>) { chomp; my($last, $first, $email) = split /, */; $email =~ tr/<>//d; print NEWFILE "$last, $first, $email\n"; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-24 03:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found