The values of $status, $soc, and $subscriber are based on @row_text, but that array is never populated. Each of those scalars will be undef.

For other interested monks, here's my feeble attempt at reformatting:

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 char +acters followed by space. #$ar_OR_STA[$i]=$status; #Here $[=1, so @ar_STA[0] doe +s not 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 + followed by space. #$ar_OR_SOC[$i-1]=$soc; #Here $[=1, so @ar_STA[0] does + not have any value. Original Array of Status $subscriber = $row_text[3]; $subscriber =~ s/(\D+)/ /; #Eliminate all non-digits f +ollowed 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 follow +ing lines?Anybody Know why? $status =~ s/(\W+)/ /gs; $soc =~ s/(\W+)/ /; $subscriber =~ s/(\D+)/ /; # and use of initialized value in join or s +tring at print "@ar_OR_STA\n";

As an aside, I think changing the value of $[ could have some very confusing unwanted consequences later in this code's life. (I quote perlvar: "Its use is highly discouraged.") If you must go through with that, use local to limit the scope (although I can't tell that you haven't from the code you posted).


In reply to Re: Use of Uninitialized value in substitution (s///) by kyle
in thread 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.