Brandon McCaig bamcc...@gmail.com writes:
Hope that helps.
Yes it does.
Thanks for the continuing review and criticism much needed in my case...
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On Fri, Nov 28, 2014 at 9:40 AM, Brandon McCaig bamcc...@gmail.com wrote:
# Protip: I'm not sure which is better, interpolating $status
# into the format string, or passing it as an argument. I'm
# sure it's negligible in this case.
printf %-60s $status\n, $abs_path;
I lied.
On Tue, Nov 18, 2014 at 05:46:15PM -0500, Harry Putnam wrote:
#!/usr/bin/perl
use strict;
use warnings;
if (!@ARGV) {
Alternatively to the @ARGV == 0 suggested by others, there's
always:
unless(@ARGV) { ... }
It's a matter of taste. Nothing really wrong with !@ARGV.
usage
quoting in that usage for several
version upgrades... maybe a year or longer.
You might want to:
use Data::Dumper;
print Dumper(@ARGV);
I'll try try that next time... thanks.
Mystery solved by Rob D... I was looking at one script and running a
different one.
[...]
Kent Fredric kentfred
Harry Putnam rea...@newsguy.com writes:
Carl Inglis carl.ing...@gmail.com writes:
Interesting - in perl 5.10.1 on my system it works as expected.
One point to note, your $myscript in your usage should be escaped
otherwise you get an error.
No. That changed in some previous version a
On 20 November 2014 10:05, Harry Putnam rea...@newsguy.com wrote:
, unless I specifically google up
some examples of something
I believe current advice is not to do that, as there is a vast abundance of
very poor/chronically outdated code that may be returned by such a search,
or you might
of user forgetting to supply a
target directory.
The `if (!@ARGV) {[...] bleh; exit}' thing.
I'm pretty sure it is some other bit in there causing the grief but I
don't understand what.
Only thing I did to debug was to make sure `use File::Find; comes
after if (!@ARGV), but that seems not to matter
Interesting - in perl 5.10.1 on my system it works as expected.
One point to note, your $myscript in your usage should be escaped
otherwise you get an error.
You might want to:
use Data::Dumper;
print Dumper(@ARGV);
just before your test to see what it thinks @ARGV is actually set
On 19 November 2014 11:46, Harry Putnam rea...@newsguy.com wrote:
Only thing I did to debug was to make sure `use File::Find; comes
after if (!@ARGV), but that seems not to matter.
That will be because 'use' is processed during BEGIN { }, while your
condition is during the main execution
on the
if clause designed to catch the advent of user forgetting to supply a
target directory.
The `if (!@ARGV) {[...] bleh; exit}' thing.
I'm pretty sure it is some other bit in there causing the grief but I
don't understand what.
Only thing I did to debug was to make sure `use File::Find; comes
after
my $bib_abbrev, '', $bib_abbrev_filename
And here.
my $bib_output, '', basename($ARGV[0]).bib
Perl won't interpolate function calls inside double-quotes. You can do:
open my $bib_output, '', basename($filename) . .bib
or die Foo bar. $!;
You can also do @{[basename($filename
On Sun, Mar 4, 2012 at 2:34 AM, Shawn H Corey shawnhco...@gmail.com wrote:
On 12-03-03 11:37 AM, lina wrote:
my $tex_filename = $ARGV[0] ;
# for catfile()
use File::Spec;
# divide the input file name into its path and name,
# ignore its extension
my ( $name, $path ) = fileparse
On 04/03/2012 09:24, lina wrote:
On Sun, Mar 4, 2012 at 2:34 AM, Shawn H Coreyshawnhco...@gmail.com wrote:
On 12-03-03 11:37 AM, lina wrote:
my $tex_filename = $ARGV[0] ;
# for catfile()
use File::Spec;
# divide the input file name into its path and name,
# ignore its extension
my
On 12-03-04 04:24 AM, lina wrote:
#!/usr/bin/env perl
use strict;
use warnings;
use File::Spec;
use File::Basename;
my $INPUTFILE = $ARGV[0];
my $tex_filename = $INPUTFILE;
my $bib_filename = /home/lina/texmf/bibtex/bib/biophymd.bib;
my $bib_abbrev_filename =/home/lina/texmf/bibtex/bib
$bib_abbrev_filename =/home/lina/texmf/bibtex/bib/biophyabbrev.bib
open my $bib_abbrev, '', $bib_abbrev_filename
my $bib_output, '', basename($ARGV[0]).bib
### here the ARGV[0] is try.tex, so the output filename is try.bib.
my %dict;
my $tex_filename = $ARGV[0] ;
open my $file, '', $tex_filename or die
$bib_output, '', basename($ARGV[0]).bib
Perl won't interpolate function calls inside double-quotes. You can do:
open my $bib_output, '', basename($filename) . .bib
or die Foo bar. $!;
You can also do @{[basename($filename)]}.bib (using the Turtle operator
mentioned here - http://www.catonmat.net
On 12-03-03 11:37 AM, lina wrote:
my $tex_filename = $ARGV[0] ;
# for catfile()
use File::Spec;
# divide the input file name into its path and name,
# ignore its extension
my ( $name, $path ) = fileparse( $tex_filename, qr/\.[^\.]+$/ );
# create a new name with .bib extension
my
$_^[(BCAPPI^[$B$r:n@.^[(B
0=^[$BNJ}$N^[(BCAPPI^[$B$r:n@.^[(B
# work directory #
$workdir = ..;
$datadir = ../volume;
$year= 2011;
if(@ARGV != 1){
print ARGV error \n;
print firstradar velx vely \n;
exit(1
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
$UNFOLD = 1; #1=UNFOLD^[$B%G!%?$r;HMQ^[(B
0=^[$B@8^[(Bvolume^[$B%G!%?$r;HMQ^[(B
$XDR_NUM = 1; #1=^[$BJRJ}$N$_^[(BCAPPI^[$B$r:n@.^[(B
0=^[$BNJ}$N^[(BCAPPI^[$B$r:n@.^[(B
# work directory #
$workdir = ..;
$datadir = ../volume;
$year= 2011;
if(@ARGV != 1){
print ARGV error \n
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
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
=^[$B@8^[(Bvolume^[$B%G!%?$r;HMQ^[(B $XDR_NUM = 1;
#1=^[$BJRJ}$N$_^[(BCAPPI^[$B$r:n@.^[(B 0=^[$BNJ}$N^[(BCAPPI^[$B$r:n@.^[(B
# work directory #
$workdir = ..;
$datadir = ../volume;
$year= 2011;
1. Add my.
2. Maybe use http://perldoc.perl.org/File/Spec.html
if(@ARGV != 1){
1
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
This is probably blindingly simple but I'm not understanding why @ARGV
is not reduced to () (no args)? in this example
I'm trying to understand what happens with ARGV in s getops loop with
arguments after the getopts Options, or any time there is ARGV, I
guess.
Why doesn't the `for loop' reduce
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
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
Shawn H. Corey wrote:
Andrew Steinborn wrote:
I need to know how to get the arguments passed to Perl. I'm using the
ActiveState built version of Perl on Windows Vista.
Perl loads the command-line arguments into the special variable @ARGV
See `perldoc perlvar`.
Thanks. I figured it out
On Sun Aug 23 2009 @ 9:06, Andrew Steinborn wrote:
Shawn H. Corey wrote:
Andrew Steinborn wrote:
I need to know how to get the arguments passed to Perl. I'm
using the ActiveState built version of Perl on Windows Vista.
Perl loads the command-line arguments into the special variable @ARGV
I need to know how to get the arguments passed to Perl. I'm using the
ActiveState built version of Perl on Windows Vista.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
Andrew Steinborn wrote:
I need to know how to get the arguments passed to Perl. I'm using the
ActiveState built version of Perl on Windows Vista.
Perl loads the command-line arguments into the special variable @ARGV
See `perldoc perlvar`.
--
Just my 0.0002 million dollars worth
inside the script.
so... i want to do things like this:
***
my $path = $ARGV[3];
chown 0, 0, /tmp/$path;
***
and perl complains that the var is tainted.
I perfectly understand that... and all the security reasons to work like
that... but
1. how can i untain that var?
2
Hi Jordi,
Jordi Moles Blanco wrote:
1. how can i untain that var?
2. can i modify the way that snmp works to disable that -T flag when
it passes the control to the perl script?
i've tried to untain the var with any means i've found, like this one:
*
$path =~ s/;//g;
*
En/na Raymond Wan ha escrit:
Hi Jordi,
Jordi Moles Blanco wrote:
1. how can i untain that var?
2. can i modify the way that snmp works to disable that -T flag
when it passes the control to the perl script?
i've tried to untain the var with any means i've found, like this one:
*
Jordi Moles Blanco schreef:
my $path = $ARGV[3];
my ($path) = $ARGV[3] =~
m{ ^# SOB
(# start capturing
(?:# start group
/ # a slash
[a-z]+ # followed by 1 or more lowercase letters
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 this kind of warnings.
Use of uninitialized value in string eq
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
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
.
use strict;
use warnings;
my $line;
my $input;
$input=$ARGV[0]; #$input=httpd;
chomp $input;
open PROS, ps -ef|grep $input |;
while ($line = PROS){
unless ($line =~ m/grep/){
print $input is running\n;
exit;
}
}
print $input isn't running\n
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
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 warnings;
my $line;
my $input;
$input=$ARGV[0
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
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
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?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http
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 code
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
I'm trying to automate g++ through a Perl script.
Here is what I have written so far:
#!/bin/perl -w
use strict;
my $counter;
$counter = 0;
for (my $i = 0; $i @ARGV; $i++) {
$counter++;
}
if ($counter == 0) {
print Not enough arguments!;
print Usage: ./cedit somefile.C
necessary to initialize this variable.
It doesn't hurt, but it's just a line you didn't need to type.
for (my $i = 0; $i @ARGV; $i++) {
$counter++;
}
## This whole loop is not needed. If you use the @ARGV variable in a
Scalar context, it will report how many elements it has
my
SNIP
#!/bin/perl -w
use strict;
## you should:
use warnings;
## it will help you in the future
SNIP
Oops! I just realized your using that '-w' switch to perl up there.
That IS using the warnings pragma, I believe. Sorry about that!
--Errin
--
To unsubscribe, e-mail:
Christopher Spears wrote:
I'm trying to automate g++ through a Perl script.
Here is what I have written so far:
#!/bin/perl -w
use strict;
my $counter;
$counter = 0;
for (my $i = 0; $i @ARGV; $i++) {
$counter++;
}
You don't need a loop for that as an array in scalar context returns
Hi,
Why my code below fail to open and
print the file contents
when I do:
perl mycode.pl -f filename
Regards,
Edward WIJAYA
SINGAPORE
__BEGIN__
use strict;
use warnings;
use Getopt::Std;
use vars qw($f);
getopts('f:');
my $f = $ARGV[0];
open ( INFILE, '', $f)
or die $0 : failed to open
, you should have declared opt_f here:
our $opt_f;
getopts('f:');
my $f = $ARGV[0];
open ( INFILE, '', $f)
or die $0 : failed to open input file $f : $!\n;
This is good, I especially like the 'die' statement in case it
fails. Good Job! It is relevant
to note that opening
Hi again, Edward!
Just so you know, you should CC the list when you reply!
On Tue, 28 Sep 2004 22:26:55 +0800, Edward Wijaya
[EMAIL PROTECTED] wrote:
Thanks Errin,
It works just as you suggested.
Thanks so much for your thorough
explanation. Glad that I learnt much from it.
Edward, I
On Tue, 28 Sep 2004, Errin Larsen wrote:
On Tue, 28 Sep 2004 18:51:12 +0800, Edward Wijaya
[EMAIL PROTECTED] wrote:
use vars qw($f);
The above is good, but is now obsolete.
That is debatable.
Gather round, and listen to the story of a log handling utility
written in perl,
On Tue, 28 Sep 2004 15:26:08 -0400 (EDT), Chris Devers
[EMAIL PROTECTED] wrote:
On Tue, 28 Sep 2004, Errin Larsen wrote:
On Tue, 28 Sep 2004 18:51:12 +0800, Edward Wijaya
[EMAIL PROTECTED] wrote:
use vars qw($f);
The above is good, but is now obsolete.
That is debatable.
argument
'filename' in that variable and *REMOVES* those arguments from @ARGV so that
@ARGV is now empty.
my$f = $ARGV[0];
Since @ARGV is now empty, $f is also empty (undef).
open ( INFILE, '', $f)
or die $0 : failed to open input file $f : $!\n;
close ( INFILE );
while ( )
Since
Errin Larsen wrote:
So, what was the justification for changing 'use vars' to 'our'?
I don't know, but I suspect it's because our is a complement to my. Same
syntax (no silly qw() business), same lexical scoping, etc.
You're correct. our() should be used and 'use vars' should be considered
On Tue, 28 Sep 2004, Errin Larsen wrote:
On Tue, 28 Sep 2004 18:51:12 +0800, Edward Wijaya
[EMAIL PROTECTED] wrote:
use vars qw($f);
The above is good, but is now obsolete.
That is debatable.
Please, beginners, recognize the above word, *debatable*!! I disagree
with the
On Tue, 28 Sep 2004, Wiggins d Anconia wrote:
On Tue, 28 Sep 2004, Chris Devers wrote:
On Tue, 28 Sep 2004, Errin Larsen wrote:
On Tue, 28 Sep 2004 18:51:12 +0800, Edward Wijaya
[EMAIL PROTECTED] wrote:
use vars qw($f);
The above is good, but is now obsolete.
, 2004 10:18 AM
To: 'Beginners (E-mail)'
Subject: RE: perl crashing at $image-Read (file= \*ARGV);
Wiggins d'Anconia wrote:
It appears that the docs for I::M are incorrect and that CRead and
CWrite must take a filehandle. Difficult to tell since all the code
is XS/C and I didn't feel like popping
);
undef $img;
}
}
Thanks for any help!
Brian
-Original Message-
From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 09, 2004 6:32 PM
To: Brian Volk
Cc: Beginners (E-mail)
Subject: Re: perl crashing at $image-Read (file= \*ARGV);
Please
Hi All,
I my perl script is crashing perl at this line;
$image-Read (file= \*ARGV);
I know that it is this line because I have commented out everything else
around it. When I just have the Read statment, perl will crash. Here is
the script, can someone please suggest what I am doing
Hi All,
I my perl script is crashing perl at this line;
$image-Read (file= \*ARGV);
I know that it is this line because I have commented out everything else
around it. When I just have the Read statment, perl will crash. Here is
the script, can someone please suggest what I am
will chime
in ...
http://danconia.org
-Original Message-
From: Wiggins d Anconia [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 09, 2004 12:28 PM
To: Brian Volk; Beginners (E-mail)
Subject: Re: perl crashing at $image-Read (file= \*ARGV);
Hi All,
I my perl script is crashing perl
: Thursday, September 09, 2004 12:28 PM
To: Brian Volk; Beginners (E-mail)
Subject: Re: perl crashing at $image-Read (file= \*ARGV);
Hi All,
I my perl script is crashing perl at this line;
$image-Read (file= \*ARGV);
I know that it is this line because I have commented out everything
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! :-)
- the start
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
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
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
I am a new perl user and I am running into a problem. I am trying to use
argv and it's not returning the correct response on my laptop, but it's
working fine on another machine. The only difference between the two
machines is that on my laptop, I first installed the perl AS package for
windows
On Wednesday 23 June 2004 10:22 am, PerlDiscuss - Perl Newsgroups and mailing
lists wrote:
I am a new perl user and I am running into a problem. I am trying to use
argv and it's not returning the correct response on my laptop, but it's
working fine on another machine. The only difference
: Thursday, June 03, 2004 5:30 AM
To: Larry Wissink
Cc: [EMAIL PROTECTED]
Subject: Re: Confused about supplying command line arguments and using
@ARGV
On Jun 2, Larry Wissink said:
I want to supply the name of a file on the command line when executing
a
script. Unfortunately, I'm getting an error
ActiveState on windoze requires some 'extra fiddling' to get the command
line params to actually make it into @ARGV
On my winnt box I followed the directions ActiveState provided under
'Windows Quirks' under the getting started section
Basicall you modify the .pl file extension from {full path
From: Dennis G. Wicks [EMAIL PROTECTED]
I just did extensive testing using ActiveState perl on XP-Pro
and I get the exact same results.
C:\DATAFI~1argv.pl testfile
gives the unitialized variable message but
C:\DATAFI~1perl argv.pl testfile
works as expected.
It ain't bug in
Hi,
I thought this would be simple...
I want to supply the name of a file on the command line when executing a
script. Unfortunately, I'm getting an error that says that @ARGV is
uninitialized.
How do you initialize @ARGV? How do you specify command line arguments?
I'm using Windows XP
On Jun 2, Larry Wissink said:
I want to supply the name of a file on the command line when executing a
script. Unfortunately, I'm getting an error that says that @ARGV is
uninitialized.
How do you initialize @ARGV? How do you specify command line arguments?
You don't initialize @ARGV
[EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: Larry Wissink [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Confused about supplying command line arguments and using
@ARGV
On Jun 2, Larry Wissink said:
I want to supply the name of a file on the command line when executing
On Tuesday, Dec 2, 2003, at 21:06 Europe/Brussels, John W. Krahn wrote:
Jerry Rocteur wrote:
Hi,
Hello,
I'm trying to use perl for most shell stuff and this is some of the
stuff I'm using for grep ..
perl -ne 'print $ARGV: $_ if /jerry/i ' *
perl -ne 'print if /jer{1,}y/i ' *
perl -ne 'print
Hi,
I'm trying to use perl for most shell stuff and this is some of the
stuff I'm using for grep ..
perl -ne 'print $ARGV: $_ if /jerry/i ' *
perl -ne 'print if /jer{1,}y/i ' *
perl -ne 'print unless /jer{1,}y/i ' *
I'm enjoying this as I can do a lot more than I can with the old egrep
Jerry Rocteur wrote:
Hi,
I'm trying to use perl for most shell stuff and this is some of the
stuff I'm using for grep ..
perl -ne 'print $ARGV: $_ if /jerry/i ' *
perl -ne 'print if /jer{1,}y/i ' *
perl -ne 'print unless /jer{1,}y/i ' *
I'm enjoying this as I can do a lot more than
Jerry Rocteur wrote:
Hi,
Hello,
I'm trying to use perl for most shell stuff and this is some of the
stuff I'm using for grep ..
perl -ne 'print $ARGV: $_ if /jerry/i ' *
perl -ne 'print if /jer{1,}y/i ' *
perl -ne 'print unless /jer{1,}y/i ' *
I'm enjoying this as I can do a lot
.
use strict;
my $filename = $ARGV[0];
open I, .$filename;
open O, .$filename..bak;
print O join(,I);
close(I);
close(O);
Joseph
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
: by typing its
name and then the program stops and asks you what file you want to specify.
But this does not happen. So how do you get the filename into the script?
use strict;
my $filename = $ARGV[0];
open I, .$filename;
open O, .$filename..bak;
print O join(,I);
close(I);
close(O
Dillon, John would like to recall the message, @ARGV.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
this that one
has a .pl file with the following script, execute it at c: by typing its
name and then the program stops and asks you what file you want to specify.
But this does not happen. So how do you get the filename into the script?
use strict;
my $filename = $ARGV[0];
open I, .$filename
= $ARGV[0];
The @ARGV array contains the contents of the command line after the
program name.
C:\ program.pl -f filename 2 3
# $0 contains 'program.pl' or 'c:\program.pl'
# #ARGV[0] contains '-f'
# #ARGV[1] contains 'filename'
# #ARGV[2] contains '2'
# #ARGV[3] contains '3'
open I, .$filename
ATM I can use @ARGV by forcing it to read specified files
(see sample below). But how can I turn it into a subroutine
that accepts any filenames and can be called within a script, eg:
myroutine(fileA,fileB) ?
thanks
Chris
#!/usr/bin/perl -Tw
@ARGV=(textfile,craig);
foreach $arg (@ARGV
---apologies if this turns out to be a double-posting---
ATM I can use @ARGV by forcing it to read specified files
(see sample below). But how can I turn it into a subroutine
that accepts any filenames and can be called within a script, eg:
myroutine(fileA,fileB) ?
thanks
Chris
#!/usr/bin/perl
cbgb wrote:
ATM I can use @ARGV by forcing it to read specified files
(see sample below). But how can I turn it into a subroutine
that accepts any filenames and can be called within a script, eg:
myroutine(fileA,fileB) ?
thanks
Chris
#!/usr/bin/perl -Tw
@ARGV=(textfile,craig
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
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
1 - 100 of 147 matches
Mail list logo