CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Question using ARGV in a foreach loop??

 



imillard
Deleted

Feb 22, 2001, 7:28 AM

Post #1 of 3 (229 views)
Question using ARGV in a foreach loop?? Can't Post

%pref is taken from another script that has the info.(require "$cgidir/source_def.pl";)

foreach $id ( keys %pref ) {
next if $id ne $ARGV[0] && $ARGV[0] && $ARGV[0] ne "all";
undef (%visited_urls);
$stop_url = "$pref{$id}->{urls}[0]";
#$stop_url = "$pref{$id}->{monitor}" if $pref{$id}->{monitor};
$url = "$pref{$id}->{urls}[0]";

unless ( &can_follow($url) ) {
print "\ncan't follow $url\n";
next ;
}

I am getting an error in this statement:

next if $id ne $ARGV[0] && $ARGV[0] && $ARGV[0] ne "all";

The error is: Use of uninitialized value.
Am I using the right ARGV statement in my foreach loop?





Jean
User


Feb 25, 2001, 5:25 AM

Post #2 of 3 (215 views)
Re: Question using ARGV in a foreach loop?? [In reply to] Can't Post

Maybe you mean to use the $0 (Name of the script)?


Jean Spector
QA Engineer @ Extent Technologies, Ltd.
mage@lycosmail.com


japhy
Enthusiast

Feb 25, 2001, 9:11 AM

Post #3 of 3 (212 views)
Re: Question using ARGV in a foreach loop?? [In reply to] Can't Post

You should move the $ARGV[0] test to the front.


Code
next if $ARGV[0] and $id ne $ARGV[0] and $ARGV[0] ne 'all';

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives