allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (03/02/91)
As quoted from <23315@well.sf.ca.us> by gregs@well.sf.ca.us (Greg Strockbine): +--------------- | #!/usr/bin/perl | while (<>) { | s/^ +[0-9A-F-]+ +//; #remove leading spaces and addresses | s/ .*$//; #remove trailing spaces and ASCII stuff | s/\n/ /; #replace newlines with space | @words = split(/ /); | print $words[0]; | } +--------------- faster: while (<>) { print (split(/ /, (s/^ +[0-9A-F-]+ +(.*) .*\n/$1 /)))[0]; } +--------------- | here is pmon.dmp: | 133548-56 0101 0013 A94C 0000 004B 0000 0064 0000 .....L.. .K...d.. | 133558-66 09AB 0000 0C1C 0013 334C 0003 0000 0050 ........ 3L.....P | 133568-76 0000 0067 0000 096E 0000 012A 0008 0013 ...g...n ...*.... | 133578-86 3540 0012 8774 0000 0000 0000 0000 01FF 5@...t.. ........ | 133588-8E 0095 0050 006A 3000 ...P.j0. | | here is the output: | 010109AB0000354000952 | | here is what I had expected the output to be: | 0101 +--------------- Yup. You're printing the first group of each line, without newlines. The print is inside the loop, so it executes once per line. Perhaps you want: while (<>) { push(@words, split(/ /, (s/^ +[0-9A-F-]+ +(.*) .*\n/$1/))); } print "$words[0]\n"; # this is presumably a test of the output This way @words is *added to* with each line. ++Brandon -- Me: Brandon S. Allbery VHF/UHF: KB8JRR on 220, 2m, 440 Internet: allbery@NCoast.ORG Packet: KB8JRR @ WA8BXN America OnLine: KB8JRR AMPR: KB8JRR.AmPR.ORG [44.70.4.88] uunet!usenet.ins.cwru.edu!ncoast!allbery Delphi: ALLBERY