Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi people, I keep getting an internal server error in my perl script and I have narrowed the error down to the following bit of code. It seems to work when i take this code out. Can anyone tell me what is wrong here, i am at a dead end :(

foreach $r(@write) { if ($url=~list$r=1) { print "hello"; } }

Thanks a lot

2001-03-11 Edit by Corion: Added <CODE> tags

2001-03-11 Edit by tye: Changed title from "Perl problem"

Replies are listed 'Best First'.
Re: Perl Problem
by Corion (Patriarch) on Mar 11, 2001 at 06:10 UTC

    If this is the exact code you used on your server, then the error is because if ($url=~list$r=1) is not valid Perl code. Help for such stuff can be found in many a way :

    • Have a look at /ver/log/httpd/errors.log or whatever your httpd logfiles are called
    • use CGI::Carp
    • Test your scripts outside of your browser; using CGI.pm greatly eases offline testing.

Re: Perl Problem
by Tuna (Friar) on Mar 11, 2001 at 06:15 UTC
    I'm not sure what you're trying to do, but if I'm reading into this correctly:
    #!/usr/bin/perl -w use strict; my @write = qw(my your); my $url = "list is your list"; foreach my $r (@write) { if ($url =~ /list/ ) { $r = 1; print "hello\n"; print "My R is $r\n"; } }
    This only demonstrates what I "think" you're trying to do, which is create a regex to match "list".
Re: Perl Problem
by Anonymous Monk on Mar 11, 2001 at 06:10 UTC
    OK I fixed that prob by adding "" Duh !

    I am not at another problem, What I am trying to do is put a URL in an email...then get the $ENV{'QUERY_STRING'} and process that, but when i am entering

    print "$ENV{'QUERY_STRING'}";

    I am not getting anything. Can you not do this directly from a link or does this have to be done via a form ?
      Your form's action type could be set to POST (instead of GET), in which case yer data should be read from STDIN, not $ENV{QUERY_STRING}

      But please, make the world a better place; use CGI;

      [ar0n]