> -----Original Message----- > From: JupiterHost.Net [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 02, 2004 10:56 AM > To: Perl List (E-mail) > Subject: Re: Working with Environment Variables > > > Hello Dave, > > > #!/usr/bin/perl > > > > use strict; > > use warnings; > > > > my $from1 = $ENV{'SIP_HF_FROM'}; > > > > print $from1; > > > > __END__ > > > > I get: Use of uninitialized value in print at test.pl line 8. > > > > When I type "set" at the command line, I do see the > variable SIP_HF_FROM ... > > ... > > SHLVL=1 > > SIP_HF_FROM=sip:+16364424593 > > SIP_RURI=BLAH2 > > ... > > > > Is it that there is a bad character in the variable that I > dont know about? Any help is appreciated as always. I hope I > explained myself well enough. > > No the error means its not initialized :) > > Try seeing what %ENV is: > > #!/usr/bin/perl > > use strict; > use warnings; > use Data::Dumper; > > pritn Dumper \%ENV; > > To see what %ENV looks like to perl. > > or even quicker: > > perl -mstrict -MData::Dumper -we 'print Dumper \%ENV;' > > You can avoid the error by initializing it: > > $ perl -mstrict -we 'print $ENV{SIP_HF_FROM};' > Use of uninitialized value in print at -e line 1. > $ perl -mstrict -we '$ENV{SIP_HF_FROM} = "" if !defined > $ENV{SIP_HF_FROM};print $ENV{SIP_HF_FROM};' > $ > > > Thanks in advance, > > No problem :) > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > Oops, originally sent this to just Lee... here goes again ...
Thanks for the response, but I still cant seem to get it to work. I have added this to my code .. <snip> # Export $SIP_HF_FROM and $SIP_RURI from then environment so Perl will see it print `export SIP_HF_FROM; export SIP_RURI; echo "BUTT"`; # Assign Environment variables from SER to real variables $uri_from = $ENV{'SIP_HF_FROM'}; $uri_to = $ENV{'SIP_RURI'}; # This will assign variables $1, $2, and $3 to the different parts of the phone number $uri_from =~ m/\+1(\d\d\d)(\d\d\d)(\d\d\d\d)/ ; # <----- Line 50 <snip> When I try to run the regex on $uri_from, I get: Use of uninitialized value in pattern match (m//) at lcr.pl line 50. If I try to print that variable, it returns nothing. When I take Jupiter's advice, and run the Data::Dumper, SIP_HF_FROM appears in the list of exported variables. SIP_OURI does not though. Am I going about this the wrong way? I added the export line to make sure that the variable is exported, but it still doesnt seem to export it. I wont know ahead of time what that variable will be so I cannot set it each time to something statically. Thanks again for any help, Dave Kettmann NetLogic 636-561-0680 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>