CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Use of uninitialized value in concatenation

 



themali
New User

Apr 10, 2011, 3:12 PM

Post #1 of 2 (633 views)
Use of uninitialized value in concatenation Can't Post

Keep getting:
Use of uninitialized value in concatenation (.) or string at line 21.
Use of uninitialized value in concatenation (.) or string at line 21.

I think it has something to do with $_ and $data{$_} not passing the information correctly I just don't know how to fix it. I tried all kinds of things to get around this error only to end up at the same point. Any help is appreciated.


Code
<td height="25" class="td">&nbsp;Downstream Power</td>  
<td class="td">&nbsp;-5.3 dBmV</td>
</tr>
<tr>
<td height="25" class="td">&nbsp;SNR</td>
<td class="td">&nbsp;32.8 dB</td>
</tr>



Code
#!/usr/bin/perl -w 
use strict;
use LWP::Simple;

my $http = "http://192.168.100.1/RgConnect.asp";

my %data;

my @keys = qw(DownPower DownSNR);

my $content = LWP::Simple::get($http)
or die "Couldn't get it!";

$content =~ s/\&nbsp;|\n//g;

if ($content =~ /Downstream Power (.+?) dBmV/) { $data{DownPower} = $1; }

if ($content =~ /SNR (.+?) dB/) { $data{DownSNR} = $1; }

for (@keys) {
print "$_:" . $data{$_} . " ";
}

print "\n";



(This post was edited by themali on Apr 10, 2011, 3:12 PM)


BillKSmith
Veteran

Apr 10, 2011, 3:52 PM

Post #2 of 2 (627 views)
Re: [themali] Use of uninitialized value in concatenation [In reply to] Can't Post

Both of your regular expressions fail because of the whitespace character after 'Downstream Power' and 'SNR'. There is no corresponding space in your data. I have not verified that this is the only problem.
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives