Hi Monks,

I have a problem with the following code.Can anybody help

The code may be wrong since I am still developing , but the error confuses me.

use warnings; use strict; &readfile; sub readfile{ my $input_FL;my @file_row;my @row_text;my $row_data;my $row_text; my $line =0; my $status;my $soc; my $subscriber; my @ar_OR_STA;my @ar_OR_SOC;my @ar_OR_SUB; $input_FL = "C:\\taj.txt"; chomp $input_FL; #remove enter key or any spaces open(IN_FL, $input_FL) || die ("unable to open directory"); while (<IN_FL>){ @file_row=<IN_FL>; print $#file_row; }#while close IN_FL; foreach(@file_row) { while ($line < $#file_row +1){ $row_data =$file_row[$line]; chop ($row_data); next unless /\S/; # only use lines that contain +something else + than spaces #print "$row_data\n"; if ($row_data =~ /^[d]/) { $status = $row_text[0]; $status =~ s/(\W+)/ /gs; #Eliminate all non-+word charac +ters followed by space. #$ar_OR_STA[$i]=$status; #Here $=1, so @ar_STA[0] does no +t have any value. Original Array of Status push (@ar_OR_STA,$status); print "@ar_OR_STA\n"; $soc = $row_text[1]; $soc =~ s/(\W+)/ /; #Eliminate all non-word characters f +ollowed by space. #$ar_OR_SOC[$i-1]=$soc; #Here $=1, so @ar_STA[0] does no +t have any value. Original Array of Status $subscriber = $row_text[3]; $subscriber =~ s/(\D+)/ /; #Eliminate all non-digits foll +owed by space. #$ar_OR_SUB[$i-1]=$subscriber; #Here $=1, so @ar_SUB[0] +does not have any value.Original Array of Subscriber } else { print " File is invalid\n"; } $line++; }#while }#foeach }
Here, I get Uninitaialized value in substitution(s///) in the following lines?Anybody Know why?
$status =~ s/(\W+)/ /gs; $soc =~ s/(\W+)/ /; $subscriber =~ s/(\D+)/ /;
and
use of initialized value in join or string at print "@ar_OR_STA\n";
Any help appreciated

In reply to Use of Uninitialized value in substitution (s///) by taj

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.