> ""Budi" == "Budi Milis" <[EMAIL PROTECTED]> writes:
"Budi> On 9/6/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> Consider this:
>> my $arg = @ARGV ? shift @ARGV : ;
>>
"Budi> Works as I expected, many thanks.
"Budi> However, my previous code was:
"Budi> my $time_in = $ARG[0] || ;
"B
"Budi Milis" schreef:
> How do accept pipe as an valid argument in perl, for example:
>
> echo 123456 | ./convert_time.pl
>
> convert_time.pl:
> #!/usr/bin/perl
>
> use POSIX qw(strftime);
>
> my $time_in = $ARGV[0];
> my $time_out = strftime "%Y%m%d", localtime($time_in);
> print "$time_out\n";
Don't write it like this.Consider this case:
$ARGV[0] ==0;
then your statement :
my $time_in = $ARGV[0] || ;
should be broken.
--Jeff Pang
-Original Message-
From: [EMAIL PROTECTED]
To: beginners@perl.org
Sent: Wed, 6 Sep 2006 1:58 PM
Subject: Re: pipe as an argument
On 9
On 9/6/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Consider this:
my $arg = @ARGV ? shift @ARGV : ;
Works as I expected, many thanks.
However, my previous code was:
my $time_in = $ARG[0] || ;
and it doesn't work, why and whats the different with yours?
rgds,
--
To unsubscribe, e-mail:
HI,
Change this line:
my $time_in = $ARGV[0];
to:
my $time_in = ;
--Jeff Pang
-Original Message-
From: [EMAIL PROTECTED]
To: beginners@perl.org
Sent: Wed, 6 Sep 2006 12:54 PM
Subject: pipe as an argument
All,
How do accept pipe as an valid argument in perl, for example:
echo
All,
How do accept pipe as an valid argument in perl, for example:
echo 123456 | ./convert_time.pl
convert_time.pl:
#!/usr/bin/perl
use POSIX qw(strftime);
my $time_in = $ARGV[0];
my $time_out = strftime "%Y%m%d", localtime($time_in);
print "$time_out\n";
rgrds,
--
To unsubscribe, e-mail: [