your code seems to be more relevant to my problem....I implemented the technique and heres my edited code...
#!/usr/bin/perl use strict; use warnings; # source file directory my $srcdir = "../source"; # source file name my $srcfile = $srcdir."/vol.dat"; # Open source file. open (READ, "< $srcfile") || die "Can't find the DAT file\n"; my $epochToday = time; $epochToday = $epochToday - 2592000; my ($year, $month, $day) = (localtime($epochToday))[5,4,3]; $month++; $year+=1900; my $startdate = $year."-".$month."-".$day; my $x=0; my $info; my @input; while ($info = <READ>) { chomp $info; my @data = split (/,/, $info); push @input, [@data]; $x++; } close READ || die "Couldn't close the DAT file"; @ordered_input); my $desdir = "../target"; my $desfile = $desdir."/total_volume.csv"; open (WRITE, "> $desfile") || die "Can't find the CSV file.\n"; my @headers = ("Date",",","Total_Volume"); print WRITE @headers,"\n"; my $printout; while (@input) { my $start = $startdate; my $end = "eof"; if ( /^$start/../^$end/ ) { chomp; my (@items) = split /,/; $printout .= "%s,%d\n", $items[0], $items[1] + $items[2]; } } print WRITE $printout; close WRITE || die "Couldn't close the CSV file"; exit 0;
but im getting and infinite loop error:
Use of uninitialized value $_ in pattern match (m//) at basic.pl line +63. Use of uninitialized value $_ in pattern match (m//) at basic.pl line +63. Use of uninitialized value $_ in pattern match (m//) at basic.pl line +63. Use of uninitialized value $_ in pattern match (m//) at basic.pl line +63. Use of uninitialized value $_ in pattern match (m//) at basic.pl line +63. Use of uninitialized value $_ in pattern match (m//) at basic.pl line +63. Use of uninitialized value $_ in pattern match (m//) at basic.pl line +63. Use of uninitialized value $_ in pattern match (m//) at basic.pl line +63. Use of uninitialized value $_ in pattern match (m//) at basic.pl line +63. Use of uninitialized value $_ in pattern match (m//) at basic.pl line +63. Terminating on signal SIGINT(2) Terminating on signal SIGINT(2)
kindly help in this matter..

Thanks
AvantA

In reply to Re^2: copying records from one file to another with filter. by avanta
in thread copying records from one file to another with filter. by avanta

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.