For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > March 2004 > hashes , use strict readParse









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author hashes , use strict readParse
p cooper

2004-03-27, 11:58 pm

I seem to be in a muddle over the above.
my scripts seem to fall over using

&ReadParse(*input)

with use strict;

#!/usr/bin/perl
use CGI;
use strict;
my % input;
ReadParse(*input)

and i get a blank page when trying to do anything wih the hash key/values.

I cant find how use strict fits together with ReadParse(*input) and then
using the hash.



p cooper

2004-03-27, 11:58 pm

the preoblem seems to be when im trygin to produce different pages with the
same script

eg
if $ENV{HTTP_REFERER} =~/page1.htm/
{ do page two stuff }
elsif $ENV{HTTP_REFERER} =~/page2.htm/
{ do page 3 stuff}

use strict appears to break things doesnt work going round for the second
time.
Dont know if this something with use strict ans hashes that i dont know or
its a probem somewhere else.
Gunnar Hjalmarsson

2004-03-27, 11:58 pm

p cooper wrote:
> I seem to be in a muddle over the above.
> my scripts seem to fall over using
>
> &ReadParse(*input)
>
> with use strict;
>
> #!/usr/bin/perl
> use CGI;
> use strict;
> my % input;
> ReadParse(*input)
>
> and i get a blank page when trying to do anything wih the hash
> key/values.


Try making %input a package global:

our %input;

You also need to either import 'ReadParse' or call the function with
the fully qualified name, even if that has nothing to do with
strictures. But by enabling warnings, Perl would have told you about
that mistake.

use warnings;

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com