Forum Moderators: coopster & phranque

Message Too Old, No Replies

Formication error messages

Can't get rid of error messages.

         

aerocan

4:54 pm on Oct 30, 2007 (gmt 0)

10+ Year Member



I do not know perl. Please help someone. I keep getting the same errors.

Use of uninitialized value in substitution iterator at formication.pl line 153.

Here is the code:

_____________________________________

1 #!/usr/bin/perl -wT

17
18 $¦ = 1;
19
20 open(STDERR, ">&STDOUT") ¦¦ die "Can't redirect stderr";
21
22 use CGI;
23 use CGI::Carp qw(fatalsToBrowser);
24 use POSIX qw(:fcntl_h);
25 use English;
26 use strict;
27
28 use vars qw($query $fcnfile $query_dir $fcntext %handlers
29 $response $errortext $location $delim $tag);
30 use vars qw($authorized_uid);
31
32

41 # this handles all form data for us...
42 $query = CGI->new;

108 # this is used to delimit substitutions in the body of various containers.
109 # it can be changed with the <replace> container.
110 $delim = "%";
111
112 # this is the main loop. find a tag, and call the appropriate handler
113 # if there is one.
114 while( $fcntext =~ m/<(\w+)(.*?)>/gsci ) {
115 $tag = lc($1);
116 $handlers{$tag} && &{$handlers{$tag}}($tag, $2);
117 }
118
119 # finish up... if we are to redirect the user, send a Location header,
120 # otherwise, send the response as text/html.
121 if($location) {
122 print("Location: $location\r\n\r\n");
123 } else {
124 print("Content-type: text/html\r\n\r\n");
125 print $response, "\n";
126 }
127
128 exit(0);
129
130
131 # GENERIC SUBROUTINES
132
133 # string getbody( string $tagname );
134 # this is called to retrieve the body of a container by the handler
135 # for that container. $tagname is the name of the container, and is
136 # used to find the closing tag.
137 sub getbody {
138 my($tagname) = shift;
139 if( $fcntext =~ m/\G(.*?)(<\/$tagname>)/gsci ) {
140 return $1;
141 }
142
143 return "";
144
145 }
146
147 # string substitute( string $text );
148 # this is used to replace all occurences of "%var%" in $text with
149 # the value of the submitted form variable "var".
150 sub substitute {
151 my($text) = $_[0];
152
153 $text =~ s/$delim(\w+)$delim/ $query->param($1) /ge;
154 return $text;
155
156 }

[edited by: jatar_k at 5:04 pm (utc) on Oct. 30, 2007]
[edit reason] reduced code dump [/edit]

jatar_k

5:01 pm on Oct 30, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld aerocan,

I think it's just a warning so you could remove the w from your shebang line

use
#!/usr/bin/perl -T

instead of
#!/usr/bin/perl -wT

perl_diver

6:02 pm on Oct 30, 2007 (gmt 0)

10+ Year Member



This is just a warning, if the script works OK then the warning can be ignored. If the script does not work OK, print the value of $text to the screen while the script runs so you can see what is going on.

On a side note, don't use the -w flag. Use the warnings pragma:

[perl]use warnings;[/perl]

then you can do this as needed in the script:

[perl]
sub my_function {
no warnings;
code here
}
[/perl]

which turns off warnings only for that block of code.

Avoid using this module:

[perl]use English; [/perl]

it can slow down your perl scripts considerably. See the English module docs for details:

[edited by: jatar_k at 6:03 pm (utc) on Oct. 30, 2007]

perl_diver

6:02 pm on Oct 30, 2007 (gmt 0)

10+ Year Member



Can't we post links anymore?

jatar_k

6:04 pm on Oct 30, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



when you use perl tags it blows the codes

[perldoc.perl.org...]

perl_diver

6:11 pm on Oct 30, 2007 (gmt 0)

10+ Year Member



OK. Can't that be fixed by the powers that be? I see that the perl tags are not documented. Are they a relic or an undocumented feature?

jatar_k

6:17 pm on Oct 30, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



bit of both but mainly a relic

aerocan

8:34 pm on Oct 30, 2007 (gmt 0)

10+ Year Member



Wow. I'm impressed. Realy quick reply.

I have used #!/usr/bin/perl -T
as suggested and still get the same warnings.

______________

[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
[Tue Oct 30 16:30:12 2007] formication.pl: Use of uninitialized value in substitution iterator at formication.pl line 153.
Content-type: text/html

aerocan

8:35 pm on Oct 30, 2007 (gmt 0)

10+ Year Member



Sorry.

Please ignore my last post.

I had modified the wrong file.

It works fine now.

Thanks to all of you...

Aerocan

phranque

11:06 pm on Oct 30, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, aerocan!