Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
... # Read the last 2 lines of a log file my $log = "log.log"; # if this file is still empty by the time the co +de runs. my $line = do { open my $line, '-|', tail => -2, $log or die "Can't spawn tail: $!\n"; <$line>; }; $line =~ s/[\r\n]+$//; my $show = ''; # <<<< happens here, uninitial +ized value if ($line =~ /(\bTest\b\s+.+\s+\baccount\b)?/) { #<<<< happens here, + uninitialized value $show = $1 || ''; } ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Preventing Use of uninitialized value.
by 1nickt (Canon) on Dec 12, 2018 at 18:58 UTC | |
by choroba (Cardinal) on Dec 13, 2018 at 17:05 UTC | |
by 1nickt (Canon) on Dec 13, 2018 at 18:27 UTC | |
|
Re: Preventing Use of uninitialized value.
by Laurent_R (Canon) on Dec 12, 2018 at 23:37 UTC | |
|
Re: Preventing Use of uninitialized value.
by hippo (Archbishop) on Dec 12, 2018 at 23:49 UTC | |
|
Re: Preventing Use of uninitialized value.
by tobyink (Canon) on Dec 12, 2018 at 21:27 UTC | |
by stevieb (Canon) on Dec 12, 2018 at 22:23 UTC | |
by tobyink (Canon) on Dec 13, 2018 at 09:13 UTC | |
by 1nickt (Canon) on Dec 13, 2018 at 18:26 UTC |