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

Re: [PBML] %ENV hash problems

Expand Messages
  • Charles K. Clarkson
    Jeff Eggen ... Most likely this is because the other user doesn t have a $PS1 environment variable. strict doesn t like undefined
    Message 1 of 3 , Nov 1, 2001
    • 0 Attachment
      "Jeff Eggen" <jeggen@...>

      : Hello group,
      :
      : Does anyone know why the following line of code:
      :
      : my $lastchar = substr("$ENV{PS1}", length("$ENV{PS1}") - 2);
      :
      : Would properly extract the last 2 characters of my
      : $PS1 environment variable, but not that of another
      : user? I can run this fine, but when another user
      : tries they get the error:
      :
      : Use of uninitialized value in string at ./script.pl
      : line 26.
      :
      : Well, actually they get it twice.
      :
      : I thought the difference might be that the other
      : user has a prompt that ends in "$ ", as opposed
      : to my "> ", but I changed mine and I can still
      : run it okay.
      :

      Most likely this is because the other user
      doesn't have a $PS1 environment variable. strict
      doesn't like undefined variables. try (untested):

      my $lastchar = substr($ENV{PS1}, length($ENV{PS1}) - 2)
      if exists $ENV{PS1};

      Or (also untested):

      my $lastchar;
      if ( exists $ENV{PS1} ) {
      $lastchar = substr($ENV{PS1}, length($ENV{PS1}) - 2)
      }

      HTH,
      Charles K. Clarkson
      Clarkson Energy Homes, Inc.



      Most people truly want to help.
      Unfortunately, most people truly suck at it.
    • Jeff Eggen
      ... Thanks Charles. That was kind of the problem, but it s all figured out now. But, along the same thread, I m having problems getting a telnet connection
      Message 2 of 3 , Nov 1, 2001
      • 0 Attachment
        >Most likely this is because the other user
        >doesn't have a $PS1 environment variable. strict
        >doesn't like undefined variables. <snip>

        Thanks Charles. That was kind of the problem, but it's all figured out now. But, along the same thread, I'm having problems getting a telnet connection to accept a prompt where the last two characters are "$ ". I tried changing my prompt match operator from "/.*$lastchar/" to "/.*\\$lastchar/" for this case, where $lastchar is set in the code from the previous email:

        $lastchar = substr $ENV{PS1}, (length $ENV{PS1}) - 2;

        But this still isn't matching. Any thoughts?

        Thanks,
        Jeff
      Your message has been successfully submitted and would be delivered to recipients shortly.