Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: help regarding command line arguments

by roboticus (Chancellor)
on Nov 18, 2014 at 12:35 UTC ( [id://1107563]=note: print w/replies, xml ) Need Help??


in reply to help regarding command line arguments

praveenchappa:

When you use "\n" in a string in your script, perl converts the "\n" into the newline character. But you don't want perl to automatically do that in data, 'cause sometimes you really want the characters "\" and "n". When you pass data into your script, perl assumes the data is what you want, so it doesn't touch it.

So if you want the "\n" converted into a newline, just tell perl to do the conversion for you, like so:

use strict; use threads; my $t = shift; my $u = $t; $u =~ s/\\n/\n/g; print "<$t>\n\n<$u>\n";

Which gives me this when I run it:

$ perl zoop.pl "foo\nbar\n\n\nbaz" <foo\nbar\n\n\nbaz> <foo bar baz>

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-26 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found