bh_perl has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have some problem here, I can't skip/read/get/replace null/empty variable/parameters here and the error message was displayed as below. Otherwise, a details program or others information can be reas as below :

Error Message

Use of uninitialized value in substitution (s///) at ./alc_test.pl lin +e 40. Use of uninitialized value in pattern match (m//) at ./alc_test.pl lin +e 41. Use of uninitialized value in concatenation (.) or string at ./alc_tes +t.pl line 47. IROUTE: [6005494c523142] (ILR1B) === OROUTE: [] (THANKS) Use of uninitialized value in substitution (s///) at ./alc_test.pl lin +e 31. Use of uninitialized value in pattern match (m//) at ./alc_test.pl lin +e 32. Use of uninitialized value in substitution (s///) at ./alc_test.pl lin +e 40. Use of uninitialized value in pattern match (m//) at ./alc_test.pl lin +e 41. Use of uninitialized value in concatenation (.) or string at ./alc_tes +t.pl line 47. Use of uninitialized value in concatenation (.) or string at ./alc_tes +t.pl line 47. Died at ./alc_test.pl line 26.
Test.txt files :
Name : >Mick< [Mick] IC : '91919191929' (9191919129) PC : 123 (123) Number : >1960132400000< (1960132400000) Location : >000e 0036< (000e 0036) extension : >< Capability : >"CARES< ("CARES) Info : >6005494c523142< (6005494c523142) Name : >Nick< (Nick) IC : '1235467000' (1235467000) PC : 124 (124) Number : >1960192500000< (1960192500000) Location : >000f 0034< (000f 0034) extension : >< Capability : >< Info : ><
Program is here:
#!/usr/bin/perl -w use constant INROUTE => "THANKS"; my $iroute = "XXX"; my $oroute = "YYY"; while (1) { $/ = ""; @entries = (); open (F, "cat test.txt |") or warn ("Can't open test.txt"), ne +xt; while (<F>) { next unless $_ !~ /^#/; s/\s+:/:/g; s/(\'|<|>|\")//g; my $ref_entry = {}; foreach (split /\n/) { $$ref_entry{$1} = $2 if /^(.*):\s+(.*)\((.*)\) +$/; } push @entries, $ref_entry; } close (F); printreport() if scalar(@entries) > 1; die; } sub printreport { foreach $ref (@entries) { ($iroute = $$ref{"Info"}) =~ s/\s+//g; if ( $iroute !~ /""|\.|^$|^\s+$/ ) { @str1 = unpack ("x4 A2 A2 A2 A2 A2", $iroute); $tmproute = join ('', map {chr hex} @str1); ($inroute = $tmproute) =~ s/\s+//g; } else { $inroute = INROUTE; } ($oroute = $$ref{"Required Bearer Capability"}) =~ s/\ +s+//g; if ( $oroute !~ /^$|""|^\s+$/ ) { $outroute = $oroute; } else { $outroute = INROUTE;<br> } print ("IROUTE: [$iroute] ($inroute) === OROUTE: [$oro +ute] ($outroute)\n"); } } Hopefully, somebody can give me some advise. Thanks you, bh_perl

update (broquaint): added <code> tags and drop '=' separators

Replies are listed 'Best First'.
Re: How to read/replace null value/parameters
by Abigail-II (Bishop) on Jul 09, 2003 at 08:27 UTC
    It seems like $$ref{"Required Bearer Capability"} either doesn't exist, or is undefined. That explains the warnings. It also hints what you can do to fix it.

    Abigail

      Thank, Actually, That from my original assignment, I miss it, Thank you.
      By the way, I have changed it to $oroute = $$ref{"Capability"}) =~ s/\s+//g; and the error are :

      IROUTE: 6005494c523142 (ILR1B) === OROUTE: CARES (CARES)
      Use of uninitialized value in substitution (s///) at ./alc_test.pl line 31.
      Use of uninitialized value in pattern match (m//) at ./alc_test.pl line 32.
      Use of uninitialized value in substitution (s///) at ./alc_test.pl line 40.
      Use of uninitialized value in pattern match (m//) at ./alc_test.pl line 41.
      Use of uninitialized value in concatenation (.) or string at ./alc_test.pl line 47.
      Use of uninitialized value in concatenation (.) or string at ./alc_test.pl line 47.
      IROUTE: [] (THANKS) === OROUTE: [] (THANKS)
      Died at ./alc_test.pl line 26.

      I found that this case only happened when the $iroute or $oroute is blank/null.