The subroutine is rather lengthy, so let me just post the relevant parts:
sub PRINT_INFO { my ($netid, $sitename, $sector) = @_; $DAILY_HEAD= "Date Total"; $,="\t"; #Output Field Separator $query_string="netid=$netid-$sitename-$sector&report_type=Daily+Totals +&market=PHL"; $query_string =~ s/[=&]/ /g; @query_string=split(' ', $query_string); $network_element=$query_string[1]; $report_type=$query_string[3]; $MARKET=$query_string[5]; @network_element=split(/-/, $network_element); $id=$network_element[0]; $name=$network_element[1]; $sector=$network_element[2]; ###################################################### $DAILY_PATH="/data1/$MARKET/reports"; $BUSY_PATH="/data1/$MARKET/bhreports"; $PKD_PATH="/data1/$MARKET/pkdreports"; $MISC_PATH="/data1/$MARKET/miscreports"; $MDG_PATH="/data1/$MARKET/mdgreports"; $cellname="$network_element[1] Sector $network_element[2]"; $search_string="\Q($id)"; print "$cellname\n"; @all_readable_files=grep !/\.Z/, `ls -t $DAILY_PATH | head -95`; #@all_readable_files=grep !/\.Z/, `ls -t $DAILY_PATH`; print "$DAILY_HEAD\n"; foreach $file(@all_readable_files) { chomp($file); @date = split /_/, $file; $date = $date[0]; open(FILE, "$DAILY_PATH/$file"); @DATA=<FILE>; @result = grep /$search_string/, @DATA; $hits = grep /$search_string/, @DATA; for ( $i = 0; $i < $hits; $i++ ) { @_=split(' ', $result[$i]); chomp @_; print $date[0],$_[7]; print "\n"; } close FILE;
Now, the only problem is that $cellname isnt printing correctly. This is what i should get as the titles:
0040 Sector 1 0040 Sector 2 5228 Sector 1 5228 Sector 2 5458 Sector 1 0473 Sector 3 5335 Sector 1 5335 Sector 2 0267 Sector 3 0314 Sector 1 0314 Sector 3 5268 Sector 1 5268 Sector 2

This is what i do get
0040 Sector 1 5228 Sector 1 5228 Sector 1 5228 Sector 1 5228 Sector 1 5228 Sector 1 5228 Sector 1 5228 Sector 1 5228 Sector 1 5228 Sector 1 0040 Sector 2 0040 Sector 2 0040 Sector 2
I know the netid's that the sunroutine gets are being processed correctly, its the titles that are causing the problems. 0040 Sector 1 0040 Sector 2 5228 Sector 1 5228 Sector 2 5458 Sector 1 0473 Sector 3 5335 Sector 1 5335 Sector 2 0267 Sector 3 0314 Sector 1 0314 Sector 3 5268 Sector 1 5268 Sector 2

Kilinrax - I also did try a for loop, but it took forever to run. this one takes about 2 mins, the other.. i dont even it remember finishing.

arturo - to answer your question: the $index was used for the forloop, i just forgot to delete it, thanks much.

I hope this helps.

Dipul

In reply to Re: Re: Foreach Complications by ImpalaSS
in thread Foreach Complications by ImpalaSS

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.