Hey everyone,
I am in a bit of a twist here since i am new to perl, Let me give you what the problem is first then following the problem I am pasting the script and output below.
Here is what I am trying to accomplish, I am parsing a directory which contains files, and getting some values and pushing those values in an array, Now this array contains duplicate values, which I get the count of each time a duplicate value has occured in the array, after that I remove the multiple values of an array so that my array doesn't have duplicate values.
Now for each value in the array I need to parse a file , find that element and grab another value say transport, which I am able to do ...BUT NOW THE TRICKY part for me is to display all that in the following output:
ELEMENT OF ARRAY | NUMBER OF TIMES | TRANSPORT
I can display the values like below
ELEMENT OF ARRAY | NUMBER OF TIMES
once that output is done then the other output which follows is below
ELEMENT OF ARRAY | TRANSPORT
can anyone help me out here .. please do note i am really new to perl
thanks
below is my script
below is the output#!/usr/bin/perl use Getopt::Long; &GetOptions('date=s' => \$date, 'dir=s' => \$directory, 'help' => \$help); if ( defined $help ) { usage(); } unless ( defined $date ) { usage(); } ####################################### # Declaring my variables below for # # the script # ####################################### my $PATH = "/Ack/$date/"; my $ID; my $TRANSPORT; my $ftpoutbound = "/homes/ftpoutbound.db"; my %count; my @id; my $temp; opendir (DIR, $PATH) || die print "can't open dir $PATH at line 62 : $ +!\n"; my @FileList = readdir(DIR); close (DIR); foreach $FileList(@FileList) { if ( ($FileList eq ".") || ($FileList eq "..") ) { next; } else { chomp $FileList; open (FILE, "$PATH$FileList") or die ("can't open $PATH$FileList + :$!\n"); @LINES=<FILE>; close FILE; foreach $LINES(@LINES) { @Fields = split (/[\|\*~]/, $LINES); if ( $Fields[5] =~ /^ZZ$/ ) { $ID = $Fields[6]; push (@id, $ID); } } } } $count{$_}++ for @id; print "$_ => $count{$_}\n" for keys %count; %temp = (); @id = grep ++$temp{$_} < 2, @id; open (File, "$ftpoutbound") or die ("can't open $ftpoutbound at line * +* : $!\n"); @FTP_Lines=<File>; close File; foreach $id(@id) { $id =~ s/\s+//; foreach $FTP_Lines(@FTP_Lines) { chomp $FTP_Lines; @FTP_fields = split (/\;/, $FTP_Lines); if ( $FTP_fields[0] eq $Clec_id ) { $TRANSPORT = $FTP_fields[7]; #print "C => $id and TRANSPORT => $TRANSPORT\n"; } } print ("$id uses $TRANSPORT as transport\n"); } # help/usage message and exits sub usage { print "Usage: \n"; print "This program requires one argument, w/ an optional help argum +ent.\n"; print "Options should be specified as follows: \n"; print "--date REQURIED Takes in the mmddyyyy format on +ly\n"; print "--help OPTIONAL Prints this message.\n"; print "example: ./TransactionsPerDay.pl --date 09152003 \n"; exit(1); }
Below is the desired output I wantRHYTHMSIAVZSP => 117 ALGXSOULSOG5 => 1 SPNTVRZPRD => 69 2037721000SORD => 1 NEXTXOVENORDIAP => 5 VZEAPIPO => 27 VZELFLPO => 2 SGWEASTPROD => 41 TALKLSOG5 => 406 VZAPRODBAN => 21 gntftp5p => 98 NVEECIPO => 3 NVEDLCPO => 15 NVEIGCPO => 6 VZAPRODBAS => 24 VORDBAN2 => 234 VORDBAN2 uses SSL as transport COVADVZESORDP uses yes as transport ASHEESH uses yes as transport VORDBAS2 uses SSL as transport CMSTVZEORDP uses SSL as transport RHYTHMSIAVZSP uses SSL as transport TALKLSOG5 uses SSL as transport COVADVZENORDP uses yes as transport DSLNETBANORD uses yes as transport
I hope I have provided all the informationRHYTHMSIAVZSP 12 SSL COVADVZ 245 yes ATT 33 NDM
BazB edit, reformat/fix code tags. Add readmore.
In reply to Help on displaying the output of two arrays by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |