For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > October 2004 > How do I use " and \n in @ARGV[1]?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

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

2004-10-19, 3:57 pm

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"


Anno Siegel

2004-10-19, 3:57 pm

nntp <nntp@rogers.com> wrote in comp.lang.perl.misc:
> 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
nntp

2004-10-19, 3:57 pm

> > My program needs @ARGV[1] as an input string. In this input string,
>
> That depends on your shell, not Perl.
>
> Anno


How about Windows and Linux.


Robert Sedlacek

2004-10-19, 3:57 pm

nntp wrote:

> How about Windows and Linux.


I see two ways:

1. Try it.
2. Find out, what Anno meaned with »shell«.

g,
Robert

--
http://www.dunkelheit.at/
-<[::..::::..::::..]>-

Tad McClellan

2004-10-19, 3:57 pm

nntp <nntp@rogers.com> wrote:

> 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?


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Sherm Pendley

2004-10-19, 3:57 pm

nntp wrote:

> 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--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
Michele Dondi

2004-10-19, 8:56 pm

On Tue, 19 Oct 2004 09:10:14 -0400, "nntp" <nntp@rogers.com> wrote:

>
>How about Windows and Linux.


Is this supposed to be a question? If so, then how about asking one
that does make sense?!?


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{po
p^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Michele Dondi

2004-10-19, 8:56 pm

On 19 Oct 2004 13:08:02 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

>nntp <nntp@rogers.com> wrote in comp.lang.perl.misc:

[snip]
>
>That depends on your shell, not Perl.


Also, have you (nntp, not Anno!) tried?!?


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{po
p^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Tad McClellan

2004-10-19, 8:56 pm

nntp <nntp@rogers.com> wrote:


[color=darkred]
> 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.


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Tad McClellan

2004-10-19, 8:56 pm

nntp <nntp@rogers.com> wrote:
[color=darkred]
[color=darkred]


I asked you to provide attributions when quoting someone, yet here
are more unattributed quotes.

I give up, into the killfile you go!


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com