How do I use " and \n in @ARGV[1]?

N

nntp

My program needs @ARGV[1] as an input string. In this input string,
sometimes I need " and new line \n. How do I do this?
Currently I am doing this:

perl perlfile.pl "somestring"


Can I do
perl perlfile.pl "somestring\"afterquote"
perl perlfile.pl "somestring\nanotherline"
 
A

Anno Siegel

nntp said:
My program needs @ARGV[1] as an input string. In this input string,
sometimes I need " and new line \n. How do I do this?
Currently I am doing this:

perl perlfile.pl "somestring"


Can I do
perl perlfile.pl "somestring\"afterquote"
perl perlfile.pl "somestring\nanotherline"

That depends on your shell, not Perl.

Anno
 
T

Tad McClellan

nntp said:
My program needs @ARGV[1] as an input string.
^ ^
^ ^
No it doesn't.

It may need $ARGV[0] as an input string though.

In this input string,
sometimes I need " and new line \n. How do I do this?


It depends on your shell, not on your choice of programming language.

You do not have a Perl question.

Can I do
perl perlfile.pl "somestring\"afterquote"
perl perlfile.pl "somestring\nanotherline"


What happened when you tried it?
 
S

Sherm Pendley

nntp said:
Can I do
perl perlfile.pl "somestring\"afterquote"
perl perlfile.pl "somestring\nanotherline"

Your question is about shells, not Perl. The answer would be exactly the
same, for example, if you were doing this:

python pyfile.py "somestring\nanotherline"

Having said that - your second should probably work in most popular UNIX
shells.

Also, Perl inherited its "here-doc" syntax from shells - Bash, for
example, can use the same <<"FOO" syntax to define multiline strings
that Perl uses. Again though, it's a question about the shell you're
using, not Perl.

sherm--
 
T

Tad McClellan

nntp said:
How about Windows and Linux.


This is a Perl newsgroup.

This is not a Windows newsgroup.

This is not a Linux newsgroup.

Ask Perl questions in a Perl newsgroup.

Ask Windows questions in a Windows newsgroup.

Ask Linux questions in a Linux newsgroup.

It is not a hard concept, please DO NOT make off-topic postings.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top