In my attempt to use strict I get errors with unitialized variables .Here's the sample data:
testuser Authentication-Type = Unix-PW
User-Service = Framed-user,
Ascend-Idle-Limit = 600,
Framed-Protocol = PPP,
Framed-Address = 222.222.222.222,
Framed-Netmask = 255.255.255.255,
Ascend-Route-IP = Route-IP-Yes,
Ascend-Metric = 3
test2user Password = "Testpassword"
Framed-Protocol = PPP,
Ascend-Idle-Limit = 600
I just wanted to parse the file to get all the values.
#!/usr/bin/perl -w
#
#
#####################################################################
use strict;
open (FILE,"<users.merit") or die ("users_merit nie ge-opend");
my ($login,$password,$user_service,$framed_protocol,$framed_address,$f
+ramed_netmask,$ascend_route_IP,$ascend_metric,$ascend_idle_limit);
while(<FILE>){
next if /^#/;
chomp;
if($_ =~ /^\w/){
m/(.*)(Password = |Authentication-Type = )(.*)/;
($login,$password) = ($1,$3);
$login =~ s/\s+$//;
$password =~ s/\"//g;
}elsif($_ =~ /^\s/){
if($_ =~ /(User-Service = )(.*)(,)/){
$user_service = $2;
}
if($_ =~ /(Framed-Protocol = )(.*)(,)/){
$framed_protocol = $2;
}
if($_ =~ /(Framed-Address = )(.*)(,)/){
$framed_address = $2;
}
if($_ =~ /(Framed-Netmask = )(.*)(,)/){
$framed_netmask = $2;
}
if($_ =~ /(Ascend-Route-IP = )(.*)(,)/){
$ascend_route_IP = $2;
}
if($_ =~ /(Ascend-Metric = )(.*)(,)/){
$ascend_metric = $2;
}
if($_ =~ /(Ascend-Idle-Limit = )(.*)(,)/){
$ascend_idle_limit = $2;
}
}
print "$login:$password\n";
print "$user_service\n";
print "$framed_protocol\n";
print "$framed_address\n";
print "$framed_netmask\n";
print "$ascend_route_IP\n";
print "$ascend_metric\n";
print "$ascend_idle_limit\n\n";
}
close FILE;
I get always undefined values because I try to print out variables that haven't a value. Erm this is what I think is the problem.
error:Use of uninitialized value in string