> -----Original Message-----
> From: Francesco Scaglioni [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 29, 2001 8:00 AM
> To: [EMAIL PROTECTED]
> Subject: uninitialised value strings
>
>
> Hi,
>
> I have been playing around with the rat book but have the following
> problem:
>
> The attached snippet of code produces errors of unitialised value
> strings for the lines I have marked. The script compiles OK. What
> obvious newbie thing am I missing?
>
> Cheers & Thanks
>
> Francesco
>
> #!/usr/bin/perl -w
> #
> # add taint check later
>
> use CGI qw(:standard);
> use strict;
> use CGI::Carp qw(fatalsToBrowser); # remove later
> use Fcntl qw(:flock);
>
> my $filename = param('filename');
> my $subject = param('subject');
> my $action = param('action');
>
> my @subjects = ( 'running', 'computers', 'med_pol', 'med_clin',
> 'misc', 'links' );
> my $DATA_DIR = ( "../data/$subject" ); # USE OF UNINITIALISED VALUE IN
> # CONCATENATION (.)
> my $COMMENT_DIR = ( "../data/$subject/.comments" ); # USE OF
> UNINITIALISED
> # VALUE IN
> CONCATENATION
>
> ( my $today = localtime ) =~ s/ +\d+:\d+:\d+/,/;
>
>
> #( $filename ) = ( $q->param('filename') =~ /^(\d+)$/ );
> #( $subject ) = ( $q->param('subject' ) =~ /^(\w+)$/ );
> #( $action ) = ( $q->param('action ' ) =~ /^(\w+)$/ ) || 'start' ;
You do not have a variable '$q' initialized to any value (perl should be
complaining about calling an invalid method). You are using it as if you
have assigned it a reference to a CGI object. However, you can just get
rid of the '$q->' all together, because you've imported the 'param'
function with the call to 'use CGI qw(:standard)'.
Side Note:
When you get more involved with Perl, take a look at the module
CGI::Application.
It is a framework for doing CGI Applications based on run modes (which you
are
doing with your '$action' variable).
>
>
> if ( $action eq 'start' ) { start(); } # USE OF
> UNINITIALISED VALUE
> # IN STRING
> elsif ( $action eq 'list' ) { list() ; }
> elsif ( $action eq 'display' ) { display(); }
> elsif ( $action eq 'comment' ) { comment(); }
> else { start(); }
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]