Re: unit messages



oryann9 wrote:
Please advise on the small amount of code b/c I am
getting the message as below, but the code is working
and output how I want it, just trying to rid of
messages.

thank you!


Use of uninitialized value in concatenation (.) or
string at
JFS_version_parser.pl line 20, <JFS> line 952 (#1)

Use of uninitialized value in concatenation (.) or
string at
JFS_version_parser.pl line 21, <JFS> line 952 (#1)

Use of uninitialized value in concatenation (.) or
string at
JFS_version_parser.pl line 21, <JFS> line 956 (#1)

Use of uninitialized value in concatenation (.) or
string at
JFS_version_parser.pl line 22, <JFS> line 956 (#1)


use strict;
use warnings;
use diagnostics;

my $jfsFile = qq(/tmp/onlinJFS_4_license_exp.txt);
my $CvsFile = qq(/tmp/onlinJFS_4_license_exp.cvs);
my $regexp =
qr/(host:\w+)|(onlinejfs.*)|(jfs\sversion.*)/is;

You are using three sets of capturing parentheses so either $1 will match and
$2 and $3 will be undef or $2 will match and $1 and $3 will be undef or $3
will match and $1 and $2 will be undef. You should change that to one set of
capturing parentheses:

my $regexp = qr/(host:\w+|onlinejfs.*|jfs\sversion.*)/is;


my ($host,$swlist,$kernel) = 0;

open (JFS, "+<$jfsFile") or die "file '$jfsFile' was
not opened $!";

while (<JFS>) {
s/^\s+|\s+$//g;
next if ! length $_;

if (/$regexp/) {
($host,$swlist,$kernel) = ($1, $2, $3);
print "\n$1";
print "\t$2";
print "$3\n";
}

With only one set of capturing parentheses change that to:

if (/$regexp/) {
print "\n$1\n";
}


}



John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
.



Relevant Pages

  • Re: syntax...
    ... B&D on the part of the language designer. ... probably handle concatenation of string literals by itself, ... bitwise XOR, or if not that, then exponentiation.) ...
    (comp.lang.misc)
  • Bugs in the Module::Dependency
    ... Manifying blib/man1/pmd_indexer.plx.1 ... Use of uninitialized value in concatenation or string at ... # Failed test in t/04grapher.t at line 81. ...
    (perl.dbi.users)
  • RE: Simple regex problem has me baffled
    ... I am writing a script to analyse a log file. ... Each pair of Request and Response calls have a unique ... Use of uninitialized value in concatenation or string at ...
    (perl.beginners)
  • Re: Literal concatenation, strings vs. numbers (was: Numeric literals in other than base 10 - wa
    ... Well my take on it is that this would not be the same as string ... concatenation, the series of digits would be parsed as a single token ... digit separation can superficially resemble string concatenation if ... I would favor _ as a digit separator in Python ...
    (comp.lang.python)
  • Re: Simple regex problem has me baffled
    ... I am writing a script to analyse a log file. ... Each pair of Request and Response calls have a unique ... Use of uninitialized value in concatenation or string at ./magic.pl ...
    (perl.beginners)