----- Original Message -----
From: "pelp" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 06, 2002 7:26 PM
Subject: how to fix "uninitialized value in subsitution" warning
> Hi -
>
> I'm unsure of how to patch the following warning message,
>
> "Use of uninitialized value in substitution (s///) at work.pl line 74"
Hmm, the code below didn't throw that warning, because:
1. It doesn't have a line 74
2. It doesn't enable warnings
3. It doesn't compile, due to the syntax error on line 4.
In general, you can take care of that warning by either:
a. Make sure the variable you're using is not undef
b. Suppress the warning by using (in Perl 5.6 or higher):
no warnings 'uninitialized';
see 'perldoc perllexwarn' for more details.
>
>
> Here's my code:
>
> #!/usr/bin/perl
>
> use strict;
> user IO::File;
s/b 'use', not 'user'
>
>
> my $FILE = new IO::File;
> my $change_on = "/FChangeBar Yes/";
> my $change_off = "/FChangeBar No/";
Are the strokes part of the data you wish to match?
>
>
> $FILE -> open(">test.mif") or die "can't open file";
>
> while ($FILE)
This is an endless loop, since $FILE doesn't change. Do you mean to be
reading $FILE? That won't work, since you've opened it for output above.
What are you trying to do?
> {
> if ($change_on)
Why the test? $change_on is true and you never change it.
> {
> s/$change_on/$change_off/;
Since $change_on and $change_off never "change" (no pun intended), you can
use /o modifier here to speed things up a bit.
> }
> }
>
> $FILE -> close;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]