On Sat, 6 Sep 2003, Devon Young wrote:

> What does this mean?? I'm thoroughly puzzled and I've been scouring the net
> for an answer. I've been assuming it means I'm not putting strings together
> correctly, but I can't figure out how to fix it. Here's the errors I'm
> getting, followed by the peice of code that the error is apparently in. I
> can't see what's wrong though. The code looks fine to me...
>
> Use of uninitialized value in substitution (s///) at
> C:\perl_stuff\artists.pl line 120.
> Use of uninitialized value in concatenation (.) or string at
> C:\perl_stuff\artists.pl line 122.

[many additional error messages deleted]

>
> And the code...
>
>
> my $counter = $_[0];
> my $x = 1;
> while ($counter < ($_[0]+11)) {
>               # must escape double quotes, so there won't be JS errors.
>       $artist[$counter][5] =~ s/"/\\"/g;  # line 120
>
>       print BLAH "band[$x][1] = \"$artist[$counter][0]\"\;\n";
>       print BLAH "band[$x][2] = \"$artist[$counter][1]\"\;\n";
>       print BLAH "band[$x][3] = \"$artist[$counter][2]\"\;\n";
>       print BLAH "band[$x][4] = \"$artist[$counter][3]\"\;\n";
>       print BLAH "band[$x][5] =
> \"magnet:?xt=urn:sha1:$artist[$counter][4]&amp;dn=$artist[$counter][10]&amp;xs=http://web1.freepeers.net/uri-res/N2R?urn:sha1:$artist[$counter][4]&amp;dn=$artist[$counter][10]&amp;xs=http://web2.freepeers.net/uri-res/N2R?urn:sha1:$artist[$counter][4]&amp;dn=$artist[$counter][10]\"\;\n";;
>       print BLAH "band[$x][6] = \"$artist[$counter][5]\"\;\n";
>       print BLAH "band[$x][7] = \"$artist[$counter][6]\"\;\n";
>       print BLAH "band[$x][8] = \"$artist[$counter][7]\"\;\n";
>       print BLAH "band[$x][9] = \"$artist[$counter][8]\"\;\n\n";
>       $counter++;
>       $x++;
> }
>
When you say:

....=\"$artist[$counter][0]\"\;\n";

It appears that the specific error you are getting is:
use of an unititialized value in string, your examples
did not seem to be using the concatenation (.) operator.
Are you sure that $artist[$counter][0] is defined and
is not null ('')? You should probably be doing conditional
assignments, e.g.

 if (defined $artist[$counter][0] && $artist[$counter][0]) {
     .....= '"' . "$artist[$counter][0]" . '"' . ";\n";

It might be a little more efficient to do:

$stuff=$artist[$counter][0];
if (defined $stuff && $stuff) {
   ....= qq{"$stuff"} . ";\n"; }

Also note you are generating a reference to a string. Don't try to escape
enclosing quotes with a \. This is what the qq function was invented for.
Otherwise if you don't want to use the quoting functions then at least do:
.... = '"' . "$artist[$counter][0]" . '"' . ";\n";
However, that too will produce a run-time error unless
$artist[$counter][0] is defined and not null.

**** [EMAIL PROTECTED] <Carl Jolley>
**** All opinions are my own and not necessarily those of my employer ****



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to