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

Re^2: Make string that results from split behave like double-quoted string

by protist (Monk)
on Aug 23, 2013 at 20:11 UTC ( #1050727=note: print w/replies, xml ) Need Help??


in reply to Re: Make string that results from split behave like double-quoted string
in thread Make string that results from split behave like double-quoted string

I would imagine it would be more efficient to do the substitution before the split.

No needless iterating then.

Something like this:

while (<DATA>) { chomp; s/\\n/\n/g; ## Avoiding $_ is sometimes my @ar = split /\|/; ## even more fun than using warn Dumper @ar; ## it. ;P }
  • Comment on Re^2: Make string that results from split behave like double-quoted string
  • Download Code

Replies are listed 'Best First'.
Re^3: Make string that results from split behave like double-quoted string
by chilledham (Friar) on Aug 23, 2013 at 20:22 UTC

    ++ regarding the substitution before the split.

    Regarding use of $_, I do tend to avoid that myself, however it can make some examples more clear. Notice I left it out of the chomp and another example in the edit.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050727]
help
Chatterbox?
Eily just learned that you get a message when replying to yourself
[Eily]: "Hey I got an answer!" => "Oh, right, it's me..."
[stonecolddevin]: good morning all
[Eily]: good morning stonecolddevin :)
[jedikaiti]: Hey, it's a stonecolddevin

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2017-11-22 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (327 votes). Check out past polls.

    Notices?