Er1kW has asked for the wisdom of the Perl Monks concerning the following question:
Switch name|Up|VCC||||||||||||||| RTC2||50.1|13|1|376|510|UBR|7|2|65|65|10|384|384|0|3|Off RTC1||50.2|3|2|23|191/3|UBR|7|2|65|65|10|38|38|40665|3|Off Switch name|Up|VCC||||||||||||||| RTC2||50.1|9|1|14|201|UBR|7|2|65|65|10|64|64|320|3|On RTC1||50.2|3|2|23|435/7|UBR|7|2|65|65|10|38|38|40665|3|Off Switch name|Up|VCC||||||||||||||| Switch name complete|Up|VCC| RTC2||50.1|12|1|411|16|VBR(NRTime)|3|2|65|65|10|128|128|128|1|On RTC1||50.2|3|2|23|106/9|UBR|7|2|65|65|10|38|38|40665|1|Off Switch name|Up|VCC||||||||||||||| Switch name complete|Up|VCC| RTC2||50.1|12|1|411|16|VBR(NRTime)|3|2|65|65|10|128|128|128|1|On RTC1||50.2|3|2|23|106/9|UBR|7|2|65|65|10|38|38|40665|1|Off
#!/usr/bin/perl<br> <br> my %current = ();<br> my @fline = ();<br> my $original = "";<br> open (DATA, "/export/home/webadm/scripts/backup_scripts/backup_data/1s +tnodupe"); while (<DATA>) { my @line = split(/\|/); # split on | @current{qw/name var1 var2 var3 var4 var5 var6 var7 var8 var9 var1 +0 var11 var12 var13 var14 var15 var16 var17 var18/} = @line; #------------------------------ # process first two lines #----------- if ($line[0] =~ /^\S/) { # if line = Non-White Space Charac +ter (equal to first line in 3 line data) if (keys %current) { print; @fline = @line; $original = $line[0]; } } #--------------------------- # process overflow #--------- elsif ($line[0] =~ /^ (.*)/) { my $new = $line[0]; @next = split(/ /, $new); $overflow = $original.$next[1]; print "$overflow\|$fline[1]\|$fline[2]\|\n"; } #------------------------ # process rtc1 and rtc2 #----------- else { print; # print rest of lines } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: printing needed info only
by eejack (Hermit) on May 03, 2001 at 07:22 UTC | |
|
Re: printing needed info only
by cLive ;-) (Prior) on May 03, 2001 at 13:12 UTC | |
by Er1kW (Initiate) on May 03, 2001 at 22:51 UTC | |
|
Re: printing needed info only
by Er1kW (Initiate) on May 03, 2001 at 07:08 UTC |