I dont' think I'm splitting the data right. I don't think I should push the data but I don't know how else to do it. Here is my main program with the test.dat (data file) below. I really need help this is due tomorrow! ################################
#sort.pl #!/usr/bin/perl #use IO::Socket; my $datafile = "test.dat"; open fh, $datafile or die "Can't open $datafile: $!"; my %report; # for report info my %list; while (<fh>) { # skip blank and commented lines next if /^\s*#/; next if /^\s*$/; # We'll look for lines that describe a report: if (s/^\s*report:\s+//i) { # line is a report description chomp; @report{qw(sort list)} = split; # set defaults $report{sort} ||= 'source'; $report{acl} ||= 'all'; } else { my ($log_source,$time,$source_ip,$source_port,$dest_ip,$dest_port, $repeats,$acl_number,$log_number) = (split/,/); push @{$list($_)},(site => $log_source,time =>$time, sip=>$source_ip, sport =>$source_port, dip => $dest_ip, dport =>$dest_port, hits =>$repeats, acl =>$acl_number, lnum =>$log_number); } close fh; if ( $report{acl} eq 'all' ) { for ( sort keys %list ) { list_by_sort($_,$_,$_,$_, \%list) if $report{sort} eq 'sort'; } } else { list_by_sort($report{list}, \%list) if $report{sort} eq 'sor +t'; } sub list_by_sort($_,$_,$_,$_,\%list) { #input from the report line of the data my $field1 = shift; my $field2 = shift; my $field3 = shift; my $field4 = shift; my $date = localtime; $date =~ s/ /-/g; my $report_file_name = "$date.SORT"; ###stores report data in file open OF, ">$report_file_name" or die "Can't Open $report_file_ +name: $!"; print OF " REQUEST FOR SORTING\n\n"; print OF "FILE WAS GENERATED ON: $date \n"; #know I don't know how to compare the fields and do the sorts #the -a is for asc. and -d for descending } test.dat--The data looks like this: report: sort site-a,time-a,sport-d,hits-a Monmouth,2000-05-2000:00:09-04,192.35.75.69,138,192.100.255,66,2,101,1 +234 Jackson,2000-04-2100:00:10-05,192.35.12.03,144,192.67.29,134,8,101,148 +7 Meade,2001-01-0500:00:11-04,213.132.32,175,184.57.62.35,151,12,101,153 +2

In reply to Re: Re: Multiple Sorts by pmonk
in thread Multiple Sorts by pmonk

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.