blackadder has asked for the wisdom of the Perl Monks concerning the following question:
From that data, I need to grab it in a record form. Each record starts with a record number 1,2,3,...50000..etc1 adriaanf Europe Local _Default Different Owner For Target Machin +e HA050069 OYWVM1237 LN-CS/06 Technology XP DESKTOP Dell OptiPlex G +X270 (0151) Pentium 4 (1 x 2793) 1023 38146 11147 N/A N/A OYWVM1237 Technology LN-OY/02 VIRTUAL (OYWVH161) VMWare VMWare For D +esktop Not Defined (1 x 3065) 767 20473 8209 23/11/2004 11:10:02 N/A + N/A N/A N/A 2 adriaanf Europe Local _Default Different Owner For Target Machin +e HA050069 OYWVM1262 LN-CS/06 Technology XP DESKTOP Dell OptiPlex G +X270 (0151) Pentium 4 (1 x 2793) 1023 38146 11147 N/A N/A OYWVM1262 Technology LN-OY/06 VIRTUAL (OYWVH159) VMWare VMWare For D +esktop Not Defined (1 x 3064) 767 20473 7800 07/12/2004 10:50:32 N/A + N/A N/A N/A 5 adrianst Europe Local ER_LN_WAR Different Owner For Target Machi +ne CW041698 OYWVM1263 LN-CW/04 Research XP DESKTOP Compaq Evo D510 +(07E8h) Small Form Factor Pentium 4 (1 x 2259) 511 38154 10740 N/A N +/A OYWVM1263 Technology LN-OY/02 VIRTUAL (OYWVH138) VMWare VMWare For D +esktop Not Defined (1 x 3065) 767 20473 7788 06/12/2004 18:24:34 N/A + N/A N/A N/A 6 adrianst Europe Local ER_LN_WAR Different Owner For Target Machi +ne CW041698 OYWVM1230 LN-CW/04 Research XP DESKTOP Compaq Evo D510 +(07E8h) Small Form Factor Pentium 4 (1 x 2259) 511 38154 10740 N/A N +/A OYWVM1230 Technology LN-OY/06 VIRTUAL (OYWVH133) VMWare VMWare For D +esktop Not Defined (1 x 3065) 767 20473 6921 06/12/2004 17:48:37 N/A + N/A N/A N/A
It does grab the first line of that data, but I am not sure on how to code the regex so that it grabs all lines until the next record number, where start of a new record begins.#! c:/perl/bin/perl.exe -slw $|++; use strict; use vars qw/%data/; open (LST, "$ARGV[0]") or die "\n$0 Error => $^E\n"; chomp (my @unclean = <LST>); print"size : $#unclean"; for (@unclean) { if ($_ =~ /^\d+\s+/) { print "First 1 : $_\n"; #print "Line 2 #print "Line 3 #print "Line 4 print "____________________________________\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Capturing Multiple lined data with regex.
by duff (Parson) on Dec 08, 2004 at 15:25 UTC | |
by blackadder (Hermit) on Dec 08, 2004 at 22:00 UTC | |
|
Re: Capturing Multiple lined data with regex.
by conrad (Beadle) on Dec 08, 2004 at 15:30 UTC | |
by blackadder (Hermit) on Dec 08, 2004 at 21:50 UTC |