Dalin has asked for the wisdom of the Perl Monks concerning the following question:
This is the code I'm using to grab lines that have the region numbers in them. The line that has the sub region_info was one of my many attempts at accomplishing what I'm trying to do here. If anyone can help me out I would greatly appreciate it. Thanks in advance, Bradley Where ever there is confusion to be had... I'll be there.#!/usr/local/bin/perl -w # # # #### use strict; #### # # # #### my $past_file = "pastinv.txt"; open(PFILE,"$past_file") || die "$past_file,$!"; my @pinv1 = <PFILE>; close PFILE || die "$past_file,$!"; #### # # # # #### my @tmp_pinv = "@pinv1"; my $count = @pinv1; my ($i,@sue,@mike,@steve); for ($i = 0; $i<= $count -1; $i++) { my $line = shift(@pinv1); chomp $line; if ( $line =~ /Region/ ) { $line =~ s/\s+/ /g; my($region,$reg_num,@name) = split(/ /,$line); if ( $reg_num =~ /(7A)/ ) { unshift(@steve,$region,$reg_num,@name); print "@steve\n"; #region_info(\@steve,\@tmp_pinv); }elsif ( $reg_num == 7 ) { unshift(@sue,$region,$reg_num,@name); print "@sue\n"; }elsif ( $reg_num == 8 ) { unshift(@mike,$region,$reg_num,@name); print "@mike\n"; } }else{ next; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Report parsing
by AidanLee (Chaplain) on Jan 24, 2002 at 20:22 UTC | |
by Dalin (Sexton) on Jan 24, 2002 at 20:42 UTC | |
by AidanLee (Chaplain) on Jan 24, 2002 at 20:54 UTC | |
|
Re: Report parsing
by talexb (Chancellor) on Jan 24, 2002 at 20:27 UTC | |
by Dalin (Sexton) on Jan 24, 2002 at 20:45 UTC |