how to seperate the run time argument with | character

how to seperate the run time argument with | character

am 08.04.2008 21:46:53 von mitr

Hi,

I have a perl script, where I am passing more than 3 arguments, but I
want to seperate them with |(pipe)or any other special charcater
instead of blank space, cause the argument itself I have the space
like " sixty three".
For example c:\perl>perl sample.pl sixty three|fouty four| twenty two
in windows.

now I am passing the argument like

c:\perl>perl sample.pl two three four, when you do not have the space
in the argument itself then it is fine otherwise it is taking
everything as an argument.

Could anyone please help me on this issue?


Thanks!

Bala!!!


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: how to seperate the run time argument with | character

am 09.04.2008 05:30:05 von chas.owens

On Tue, Apr 8, 2008 at 3:46 PM, mitr wrote:
>
> Hi,
>
> I have a perl script, where I am passing more than 3 arguments, but I
> want to seperate them with |(pipe)or any other special charcater
> instead of blank space, cause the argument itself I have the space
> like " sixty three".
> For example c:\perl>perl sample.pl sixty three|fouty four| twenty two
> in windows.
>
> now I am passing the argument like
>
> c:\perl>perl sample.pl two three four, when you do not have the space
> in the argument itself then it is fine otherwise it is taking
> everything as an argument.
>
> Could anyone please help me on this issue?
snip

The correct way to do this is to quote the arguments that contain
characters the shell cares about (space, |, &, [, $, etc):

perl sample.pl 'this is one argument' two three

--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: how to seperate the run time argument with | character

am 09.04.2008 05:31:42 von Jeff Pang

Don't need the pipe symbol. Use single quote for each argument.

> cat t2.pl
use strict;
use Data::Dumper;
print Dumper \@ARGV;

> perl t2.pl 'aa bb' 'cc dd'
$VAR1 = [
'aa bb',
'cc dd'
];

On 4/9/08, mitr wrote:
>
> Hi,
>
> I have a perl script, where I am passing more than 3 arguments, but I
> want to seperate them with |(pipe)or any other special charcater
> instead of blank space, cause the argument itself I have the space
> like " sixty three".
> For example c:\perl>perl sample.pl sixty three|fouty four| twenty two
> in windows.
>
> now I am passing the argument like
>
> c:\perl>perl sample.pl two three four, when you do not have the space
> in the argument itself then it is fine otherwise it is taking
> everything as an argument.
>
> Could anyone please help me on this issue?
>
>
> Thanks!
>
> Bala!!!
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: how to seperate the run time argument with | character

am 10.04.2008 01:30:03 von Jenda Krynicky

Subject: how to seperate the run time argument with |

SEPARATE!

> Hi,
>
> I have a perl script, where I am passing more than 3 arguments, but I
> want to seperate them with |(pipe)or any other special charcater
> instead of blank space, cause the argument itself I have the space
> like " sixty three".
> For example c:\perl>perl sample.pl sixty three|fouty four| twenty two
> in windows.
>
> now I am passing the argument like
>
> c:\perl>perl sample.pl two three four, when you do not have the space
> in the argument itself then it is fine otherwise it is taking
> everything as an argument.

c:\perl>perl sample.pl "sixty three" "fouty four" " twenty two"

As you can see it's passed to the script corectly:

perl -MData::Dumper -e "print Dumper(\@ARGV)" "sixty three" "fouty
four" " twenty two"

If you want to be able to use singlequotes, want parameter globing
(handling of a*.txt) and a few other goodies in Windows similar to
the way you'd do that in Unix you may try http://Jenda.Krynicky.cz/#G

HTH, Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/