Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] Uninitialized value in concatination or string error question

Expand Messages
  • Electron One
    Well that s strange. Ok, here is my COMPLETE code. This code has the $1 included in both the if and the else statement. You should get the same error I
    Message 1 of 4 , May 1 5:16 PM
    • 0 Attachment
      Well that's strange. Ok, here is my COMPLETE code. This code has the $1
      included in both the if and the else statement. You should get the same
      error I mentioned in my first email, but if you take out $1 in the if(still
      leaving it in else), the error goes away. Why?

      ________________________________________________________________________________

      #!/usr/bin/perl

      use strict;

      my $Value;
      my $File;

      $Value = 0;


      foreach $File(@ARGV){

      open(FUT,"<$File") or die "Couldnt open $File $!";



      while(<FUT>){
      chomp;
      if(/^\s*$/){
      next;
      }
      if($Value=~ /[LH]/){
      if(/(\S+)\s+PIN\?\s(L|H)/){
      if($Value =~ /$2/){
      print "\nOh yeah $1 matched";
      }else{
      print "\nError $1 does NOT match in file $File!";
      }
      }else{

      chop($Value);
      redo;
      }
      next;
      }

      if(/PIN_(L|H)/){
      if($1 eq 'H'){
      $Value = 'H';
      next;

      }elsif($1 eq 'L'){
      $Value = 'L';
      next;

      }else{

      print "\nError in code."; #Should never arrive here
      }
      }
      }


      close(FUT);

      }
    • Charles K. Clarkson
      ... At this point $1 and $2 are defined. ... At this point $1 and $2 are undefined. Because of the last match was successful and didn t contain parenthesis.
      Message 2 of 4 , May 1 5:49 PM
      • 0 Attachment
        Electron One <electron1@...> wrote:
        : while(<FUT>){
        : chomp;
        : if(/^\s*$/){
        : next;
        : }
        : if($Value=~ /[LH]/){
        : if(/(\S+)\s+PIN\?\s(L|H)/){

        At this point $1 and $2 are defined.

        : if($Value =~ /$2/){
        : print "\nOh yeah $1 matched";

        At this point $1 and $2 are undefined. Because
        of the last match was successful and didn't contain
        parenthesis.

        : }else{
        : print "\nError $1 does NOT match in file $File!";

        At this point $1 and $2 are defined. Because of
        the last match was unsuccessful.

        : }
        : } else {


        HTH,

        Charles K. Clarkson
        --
        Head Bottle Washer,
        Clarkson Energy Homes, Inc.
        Mobile Home Specialists
        254 968-8328
      Your message has been successfully submitted and would be delivered to recipients shortly.