Ask a Question related to PERL Miscellaneous, Design and Development.
-
JS #1
how to do a simple check
I have a program called depstats.pl
which takes some files as input so I run it like:
../deptstats file1 file2 file3
and then loop through all those files using the construct:
while(<>)
How do I check if any files were supplied? Because if I just do :
../depstats.pl
the programs never ends until I CTRL-C it.
Thanks for the help.
JS.
JS Guest
-
Need Simple Answer to Simple Contribute/Firefox question
Hello all; I've tried the Adobe help in CS3, tech support, phone support, this forum, other forums, Mozilla, and nowhere can I get a straight... -
Spell Check and Grammer Check
Hello, Does anybody know about some good spell checker/grammer checker for html/asp pages? Thank you, Regards, Raj. -
Turning off Check in / Check out feature
How can I turn off the check in / check out feature? Can't seem to find it in the Contribute HELP. Thanks! -
Check to see if Check Boxes are Checked
How do I check to see if a checked box is check on the following page? This is what I have. What am I doing wrong? <%If... -
A simple problem with a really simple form
Hi there, I'm having a problem with designing a very small form in Dreamweaver. Its just a login form with username and password textfields - the... -
Bernard El-Hagin #2
Re: how to do a simple check
JS wrote:
> I have a program called depstats.pl
>
> which takes some files as input so I run it like:
>
> ./deptstats file1 file2 file3
>
> and then loop through all those files using the construct:
>
> while(<>)
>
> How do I check if any files were supplied? Because if I just do :
>
> ./depstats.pl
All of the script's arguments are stored in the special array @ARGV, so you
can simply make sure it's not empty. For more
perldoc perlvar
..
--
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
Bernard El-Hagin Guest
-
Gunnar Hjalmarsson #3
Re: how to do a simple check
Bernard El-Hagin wrote:
Or maybe:> JS wrote:>>> I have a program called depstats.pl
>>
>> which takes some files as input so I run it like:
>>
>> ./deptstats file1 file2 file3
>>
>> and then loop through all those files using the construct:
>>
>> while(<>)
>>
>> How do I check if any files were supplied?
> All of the script's arguments are stored in the special array
> @ARGV, so you can simply make sure it's not empty.
if (-e $ARGV[0])
--
Gunnar Hjalmarsson
Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
Gunnar Hjalmarsson Guest
-
JS #4
Re: how to do a simple check
Gunnar Hjalmarsson wrote:
Thanks for your help,> Bernard El-Hagin wrote:
>>>> JS wrote:
>>>>>>> I have a program called depstats.pl
>>>
>>> which takes some files as input so I run it like:
>>>
>>> ./deptstats file1 file2 file3
>>>
>>> and then loop through all those files using the construct:
>>>
>>> while(<>)
>>>
>>> How do I check if any files were supplied?
>>
>> All of the script's arguments are stored in the special array
>> @ARGV, so you can simply make sure it's not empty.
>
> Or maybe:
>
> if (-e $ARGV[0])
>
This worked:
usage() if ! $ARGV[0] ;
JS Guest
-
Bernard El-Hagin #5
Re: how to do a simple check
JS wrote:
[...]
> Thanks for your help,
>
> This worked:
>
> usage() if ! $ARGV[0] ;
Or
usage() unless @ARGV;
which seems a bit easier on the eye.
--
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
Bernard El-Hagin Guest
-
Tore Aursand #6
Re: how to do a simple check
On Mon, 08 Sep 2003 12:41:04 +0100, JS wrote:
There's always more than one way to do it, but please write> This worked:
>
> usage() if ! $ARGV[0] ;
usage() unless ( $ARGV[0] );
instead. That 'if !' is ugly, IMO.
--
Tore Aursand <tore@extend.no>
"Whenever I see an old lady slip and fall on a wet sidewalk, my first
instinct is to laugh. But then I think, what if I was an ant, and she
fell on me. Then it wouldn't seem quite so funny." -- Jack Handey
Tore Aursand Guest
-
Helgi Briem #7
Re: how to do a simple check
On Mon, 8 Sep 2003 12:03:21 +0000 (UTC), "Bernard El-Hagin"
<bernard.el-hagin@DODGE_THISlido-tech.net> wrote:
I use:>>> Thanks for your help,
>> This worked:
>> usage() if ! $ARGV[0] ;
>Or
>
> usage() unless @ARGV;
>
>which seems a bit easier on the eye.
die $usage if not @ARGV;
but in the end it's a matter of taste.
Helgi Briem Guest
-
Gunnar Hjalmarsson #8
Re: how to do a simple check
JS wrote:
Okay. Note that my suggestion includes a check of the file path. Only> Gunnar Hjalmarsson wrote:>>>
>> if (-e $ARGV[0])
> Thanks for your help,
>
> This worked:
>
> usage() if ! $ARGV[0] ;
you know if such a check would be useful.
--
Gunnar Hjalmarsson
Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
Gunnar Hjalmarsson Guest
-
Tad McClellan #9
Re: how to do a simple check
JS <vervoom@hotmail.com> wrote:
> I have a program called depstats.pl
>
> which takes some files as input so I run it like:
>
> ./deptstats file1 file2 file3
>
> and then loop through all those files using the construct:
>
> while(<>)
>
> How do I check if any files were supplied?
die "USAGE: deptstats <files...>\n" unless @ARGV;
> Because if I just do :
>
> ./depstats.pl
>
> the programs never ends until I CTRL-C it.
That is what <> is _supposed_ to do.
It is waiting for you to provide the input via the keyboard (STDIN).
Try typing some input, then mark the end of input with
a CTRL-D (CTRL-Z on Windows).
--
Tad McClellan SGML consulting
[email]tadmc@augustmail.com[/email] Perl programming
Fort Worth, Texas
Tad McClellan Guest
-
Tina Mueller #10
Re: how to do a simple check
JS wrote:
> This worked:only if the file isn't called "0"> usage() if ! $ARGV[0] ;
=)
regards, tina
--
[url]http://www.tinita.de/[/url] \ enter__| |__the___ _ _ ___
[url]http://Movies.tinita.de/[/url] \ / _` / _ \/ _ \ '_(_-< of
[url]http://www.perlquotes.de/[/url] \ \ _,_\ __/\ __/_| /__/ perception
- the above mail address expires end of december 2003 -
Tina Mueller Guest



Reply With Quote

