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

In reply to strict by toadi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.