On Mar 16, 2011 11:53 AM, ind...@students.itb.ac.id wrote:
if(@ARGV != 1){
I don't think you can look at an array like its a string like that.
Maybe string( @ARGV ) != 1 might work. But what you probably want is:
If( defined( $ARGV[ 0 ] ) )
Hi Indra,
On 2011-03-16 22:51 +0700, ind...@students.itb.ac.id wrote:
if(@ARGV != 1){
print ARGV error \n;
print firstradar velx vely \n;
exit(1);
}
...
I got this error message :
ARGV error
firstradar velx vely
This is your output if the number of arguments isn't what
On 3/16/11 Wed Mar 16, 2011 8:51 AM, ind...@students.itb.ac.id
ind...@students.itb.ac.id scribbled:
Hi, I am Indra. I am new in perl.
I start to run my script :
**
***
#!/usr/bin/perl -w
On 11-03-16 12:11 PM, shawn wilson wrote:
On Mar 16, 2011 11:53 AM,ind...@students.itb.ac.id wrote:
if(@ARGV != 1){
I don't think you can look at an array like its a string like that.
Maybe string( @ARGV ) != 1 might work. But what you probably want is:
If( defined( $ARGV[ 0 ] ) )
No,
On 3/16/11 Wed Mar 16, 2011 9:11 AM, shawn wilson ag4ve...@gmail.com
scribbled:
On Mar 16, 2011 11:53 AM, ind...@students.itb.ac.id wrote:
if(@ARGV != 1){
I don't think you can look at an array like its a string like that.
Maybe string( @ARGV ) != 1 might work. But what you probably
On 2011-03-16 17:13 +0100, Olof Johansson wrote:
This is your output if the number of arguments isn't what you
expected. Guessing from
print firstradar velx vely \n;
you probably want to change
if(@ARGV != 1){
to
if(@ARGV != 2){
as @ARGV is a list and lists in scalar
Hi Indra,
a few comments on your code.
On Wednesday 16 Mar 2011 17:51:19 ind...@students.itb.ac.id wrote:
Hi, I am Indra. I am new in perl.
I start to run my script :
***
**
#!/usr/bin/perl -w
Olof Johansson wrote:
On 2011-03-16 22:51 +0700, ind...@students.itb.ac.id wrote:
if(@ARGV != 1){
print ARGV error \n;
print firstradar velx vely \n;
exit(1);
}
...
I got this error message :
ARGV error
firstradar velx vely
This is your output if the number of arguments
Shlomi Fish wrote:
On Wednesday 16 Mar 2011 17:51:19 ind...@students.itb.ac.id wrote:
if(@ARGV != 1){
1. There should be a space before the {.
There could be, but there doesn't have to be.
print ARGV error \n;
print firstradar velx vely \n;
You should output errors STDERR -
John W. Krahn jwkr...@shaw.ca writes:
print Ditching $ditch\n;
$ditch = '';
What is the point of assigning to $ditch if it goes out of scope at
the next line?
I can only ascribe it to deep seated stupidity
What would be the better way to test what the for loop is doing?
--
To
Harry Putnam wrote:
This is probably blindingly simple but I'm not understanding why @ARGV
is not reduced to () (no args)? in this example
To Perl, @ARGV is just another array. It has some special features but
can be assigned values just like other arrays. You can use it to do
tricks, like
HP == Harry Putnam rea...@newsguy.com writes:
HP print Now lets ditch the rest in a for loop\n;
HP for (@ARGV){
change that for to a while. for will create a list of aliases to the
array elements passed to it. it doesn't check its length as you seem to
think. while will loop until @ARGV is
Harry Putnam wrote:
This is probably blindingly simple but I'm not understanding why @ARGV
is not reduced to () (no args)? in this example
[ SNIP ]
print Now lets ditch the rest in a for loop\n;
for (@ARGV){
my $ditch = shift;
perldoc perlsyn
[ SNIP ]
Foreach Loops
[ SNIP ]
The
suresh kumar wrote:
This is my part of the script,
if (($#ARGV == 1) ($ARGV[0] eq -f)) {
..
if ($ARGV[0] ne -f ) {
..
if i run my script i am seeing this kind of warnings.
Use of
On Thu, 2008-07-31 at 18:00 +0530, suresh kumar wrote:
Hi,
This is my part of the script,
if (($#ARGV == 1) ($ARGV[0] eq -f)) {
..
if ($ARGV[0] ne -f ) {
..
if i run my script i am seeing
Hi thanks for looking at the script..
Just to clarify, the scipt runs perfectly if $input it hardcoded eg
$input=httpd.
thus if the process is running then it exits, if the process is not
running then it exicutes
exec /etc/init.d/$input restart ;
But if I use $input=$ARGV[0] to give the process
Gregory Machin am Freitag, 15. Dezember 2006 14:05:
On 12/14/06, D. Bolliger [EMAIL PROTECTED] wrote:
Gregory Machin am Donnerstag, 14. Dezember 2006 13:24:
[reordered]
#!/usr/bin/perl
# if your prgram has the string grep in the name or in the path
# this program won't work.
On 12/14/2006 06:24 AM, Gregory Machin wrote:
hi
the script will not work if I use $ARGV[0] but works 100% if I hard
code the $input variable;
what have i missed ?
#!/usr/bin/perl
# if your prgram has the string grep in the name or in the path
# this program won't work.
use strict;
use
Gregory Machin am Donnerstag, 14. Dezember 2006 13:24:
hi
Hi Gregory
the script will not work
Not work? :-)
if I use $ARGV[0] but works 100% if I hard
code the $input variable;
what have i missed ?
You can give anything as cmd line argument, and the script will tell you that
it is not
Binish A R napsal(a):
arguments. Then how come I cannot access the first
element with $ARGV[0]?
I think @ARGV wont work in command line.
Try to write the code in a script and check it out.
#!/usr/bin/perl -w
print $ARGV[0];
$ perl script.pl arg_1
This returns arg_1 same as
c:\perl -e
John W. Krahn napsal(a):
arguments. Then how come I cannot access the first
element with $ARGV[0]?
Are tou not thinking on $0?
HG
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response
Hans Ginzel wrote:
John W. Krahn napsal(a):
arguments. Then how come I cannot access the first
element with $ARGV[0]?
Are tou not thinking on $0?
HG
I think @ARGV wont work in command line.
Try to write the code in a script and check it out.
#!/usr/bin/perl -w
print $ARGV[0];
$
Christopher Spears wrote:
From what I understand, @ARGV contains invocation
arguments. Then how come I cannot access the first
element with $ARGV[0]? What would be the proper way
to do this?
Well, you can access the first element as $ARGV[0], so something else is
going on. Show us your
Christopher Spears wrote:
From what I understand, @ARGV contains invocation
arguments. Then how come I cannot access the first
element with $ARGV[0]?
You can't?
What would be the proper way
to do this?
$ perl -le'print $ARGV[0]' one two three four
one
John
--
use Perl;
program
Brian Volk wrote:
I have a directory full of .txt files that I need to send to
Regexp::Common... I want to over ride the diamond operator by
defining the directory using @ARGV .
@ARGV = readdir BIN;
Just a thought.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To
Gunnar Hjalmarsson wrote:
@ARGV = readdir BIN;
OTOH, you probably want to exclude at least the '.' and '..'
directories, so maybe
@ARGV = grep { !/^\./ } readdir BIN;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For
Brian Volk wrote:
Hi All,
I have a directory full of .txt files that I need to send to
Regexp::Common... I want to over ride the diamond operator by
defining the directory using @ARGV . I'm not sure how I define
it.. Please help, w/o too much laughing! :-)
Dillon, John wrote:
According to
http://vipe.technion.ac.il/~shlomif/lecture/Perl/Newbies/lecture2/argv.html
the following program will do ...whatever (make a backup of files) and it
takes the file specified at the command line. I guessed from this that one
has a .pl file with the following
On Tue, Sep 30, 2003 at 11:03:02AM +0100, Dillon, John wrote:
According to
http://vipe.technion.ac.il/~shlomif/lecture/Perl/Newbies/lecture2/argv.html
the following program will do ...whatever (make a backup of files) and it
takes the file specified at the command line. I guessed from this
John Dillon wrote:
According to
http://vipe.technion.ac.il/~shlomif/lecture/Perl/Newbies/lecture2/argv.html
the following program will do ...whatever (make a backup of files) and it
takes the file specified at the command line. I guessed from this that one
has a .pl file with the following
Dan Muey wrote:
if you do use strict; and a -w switch and you use $ARGV[0]
it says use of uninitiated value at line ... if $ARGV[n] is empty
What do I need to do with @ARGV or $ARGV[n] to make it not give that message?
#!/usr/bin/perl -w
use strict;
if($ARGV[0] =~ /\d/) { print $ARGV[0]
Dan Muey wrote:
./test.pl
Use of uninitialized value at ./test.pl line 4.
HI
./test.pl hi7
hi7 has a number in it
HI
use:
if ( defined $ARGV[0] )
Thanks that did it!
Wags ;)
Whoops! Should have read this before I posted. Using defined() will
R. Joseph Newton wrote:
Dan Muey wrote:
use:
if ( defined $ARGV[0] )
Thanks that did it!
Whoops! Should have read this before I posted. Using defined() will capture a
0 from STDIN, which could be ameaningful value. Your suggestion is much better
than mine on
Mark -
Copied and ran you script exactly as you have shown
and it works. I named it t02.pl, so I ran it
like:
c: perl t02.pl a b
and got
a b
I am running ActivePerl 5.6.1 on W2K sp3.
1) Did your say 'perl' or just enter the script name?
If not, try w/perl.
2) If that is the
while ($ARGV) {
print count $count $ARGV[$count]\n;
$count++;
}
What is $ARGV[$count]? Is it supposed to be
the line of the file?
Either use:
my @file = ARGV;
foreach my $line (@file) {
print 'count' . $count++ . $_ . \n;
}
Or:
while (ARGV) {
print count $. $_;
once. On
the second iteration there is no value to process.
Angus
-Original Message-
From: Jonathan E. Paton [mailto:[EMAIL PROTECTED]]
Sent: 18 March 2002 11:05
To: [EMAIL PROTECTED]
Subject: Re: @ARGV question
while ($ARGV) {
print count $count $ARGV[$count]\n
$ARGV[$count] represents the index of the
array. I am passing in parameters and some
contain space between two words and I noticed
that using while (@ARGV) it loops the exact
amount of times per words, not per parameter.
So if I passed Hi There it goes around the
loop twice rather than
:[EMAIL PROTECTED]]
Sent: 18 March 2002 11:34
To: [EMAIL PROTECTED]
Subject: RE: @ARGV question
$ARGV[$count] represents the index of the
array. I am passing in parameters and some
contain space between two words and I noticed
that using while (@ARGV) it loops the exact
amount of times per words
From: Laycock, Angus [EMAIL PROTECTED]
$ARGV[$count] represents the index of the array. I am passing in
parameters and some contain space between two words and I noticed that
using while (@ARGV) it loops the exact amount of times per words,
not per parameter.
I see. So you wanted
Jenda,
Thanks for a very impressive answer.
Angus
-Original Message-
From: Jenda Krynicky [mailto:[EMAIL PROTECTED]]
Sent: 18 March 2002 12:05
To: Laycock, Angus; [EMAIL PROTECTED]
Subject: RE: @ARGV question
From: Laycock, Angus [EMAIL PROTECTED]
$ARGV[$count] represents the index
From: Pfeiffer, Richard [EMAIL PROTECTED]
I have what I think is a trick question and is causing me a bit of
trouble:
My command line looks similar to this:
command.pl-rz:\Tech Team -p/Tools Team -fFile Found
Today.txt -vRDP 1.2_A
What I'm trying to check for
On Fri, Feb 08, 2002 at 08:13:17AM -0600, Pfeiffer, Richard wrote:
My command line looks similar to this:
command.pl-rz:\Tech Team -p/Tools Team -fFile Found Today.txt
-vRDP 1.2_A
What I'm trying to check for is to make sure when people run my script, they
have each option
On Mon, Dec 17, 2001 at 10:31:43PM -0600, Michael wrote:
I cant seem to get the ARGV to work right via web I get not found error but
it works via command line. whats the trick?
It works if I do this get_file.pl test1.txt test2.txt
but it wont work via
Michael Pratt wrote:
I cant seem to get the ARGV to work right via web I get not found error but
it works via command line. whats the trick?
It works if I do this get_file.pl test1.txt test2.txt
but it wont work via http://www.host.com/cgi-bin/get_files.pl test1.txt
test2.txt
You
-Original Message-
From: Michael Pratt [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 17, 2001 11:32 PM
To: [EMAIL PROTECTED]
Subject: ARGV
I cant seem to get the ARGV to work right via web I get not
found error but
it works via command line. whats the trick?
It works
Maybe you can consider something like this ... after reading in from the ORG
file and splitting the elements into @fields ... you can so something along
these lines
for my $field (@fields) {
my $field_length = length($field);
my $format =
I have tried to find out in full detail about the file handle $ARGV
and only got the basics.
Could any one please explain the $ARGV in more detail, e.g. how to
put a input file into the $ARGV, if the input file was constantly changing!
The File in may program:
47 matches
Mail list logo