Re: if statement does not work, help please
Malcolm Debono wrote: > Can someone tell me why the 'if statement' below will not work. > What I am trying to achieve is if the $pagecontent = "" then call sub > routine &no_tags. (If it is reading something in the variable $meta could > someone please explain?) > > Thanks in advance > > Malcolm > > > #!C:\Perl\bin\perl > > use CGI; # Use the CGI.pm module > use strict; > use CGI qw/:standard/; > > my $q = new CGI; > my $url = param('url'); > my ($html,$meta,$lockit,$lines,$path_to_input_file,@metas,@lines); > > use LWP::Simple; > my $pagecontent = get ("$url"); > > # Get rid of all the \r and \n > $pagecontent =~ s/[\r\n]+//g; > @metas = $pagecontent =~ /(]+>)/gi; > > #THIS OPENS A FILE TO WRITE THE HTML TO > open (RECORD, ">read.dat") || die "Error - cannot open read.dat: $!"; > if($lockit){flock(RECORD,2);} > foreach $meta(@metas) > { > chomp($meta); > if ($meta ne "") > > print RECORD "$meta\n"; > }else{ > &no_tags; > } > } > if($lockit){flock(RECORD,8);} > close (RECORD); $lockit is never set and you don't need the unlock part (close will unlock it). Your tabbing is atrocious. :) -- ,-/- __ _ _ $Bill Luebkert ICQ=162126130 (_/ / )// // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl) -/-' /___/_<_http://www.todbe.com/ ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: if statement does not work, help please
Malcolm Debono [mailto:[EMAIL PROTECTED]] wrote: > #!C:\Perl\bin\perl > > use CGI; # Use the CGI.pm module > use strict; > use CGI qw/:standard/; > > my $q = new CGI; > my $url = param('url'); > my ($html,$meta,$lockit,$lines,$path_to_input_file,@metas,@lines); > > use LWP::Simple; > my $pagecontent = get ("$url"); > > # Get rid of all the \r and \n > $pagecontent =~ s/[\r\n]+//g; > @metas = $pagecontent =~ /(]+>)/gi; > > #THIS OPENS A FILE TO WRITE THE HTML TO > open (RECORD, ">read.dat") || die "Error - cannot open read.dat: $!"; > if($lockit){flock(RECORD,2);} > foreach $meta(@metas) > { > chomp($meta); > if ($meta ne "") > print RECORD "$meta\n"; > }else{ > &no_tags; > } > } > if($lockit){flock(RECORD,8);} > close (RECORD); You're missing the beginning of the first block in you if-statement. Try running with perl -w, use strict; use warnings; and see what you get... HTH, Ricky ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs