hi,

i suppose you have some file for which you wish to iterate over. so one possible way to go would be

use strict; #use warnings; my @array; my $count = 0; my $count_big = 0; while(<DATA>){ chomp($_); my @arraytmp = split(' ',$_); if ($count == 1){for(1..4){shift(@arraytmp)}} $arraytmp[1]=~ s/M/000000/g if ($count == 1); push(@{$array[$count_big]},@arraytmp); $count++; $count = 0 if ($count == 2); $count_big++ unless ($count); } __DATA__ QR No N/A 1 1 1 0 0 0 0 0 0 QR 1 1 1 0 157M 23:09:15.190448 00:42:28.205336 00:40:04.086054
i think the code is straightforward and should work on large files.

also i would always import the changes after the split to array.

update:

i totally missed the point!

if ($arraytmp[1]=~ s/M//g && $count == 1){$arraytmp[1] *= 1000000}
but i admit that ikegami's solution is more elegant :)

In reply to Re: Find and change value. by baxy77bax
in thread Find and change value. by pcs305

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.