I have an archive file that has 300+ archives in this format
____________________________________________________
Archive[0]: d:\archives\piarch.012 (500MB, Used: 9.0%)
PIarcfilehead[$Workfile: piarfile.cxx $ $Revision: 114 $]::
Version: 5 Path: d:\archives\piarch.012
State: 4 Type: 0 (fixed) Write Flag: 1 Shift Flag: 1
Record Size: 1024 Count: 512000 Add Rate/Hour: 4118.3
Offsets: Primary: 25853/128000 Overflow: 491596/512000
Start Time: 1-Apr-08 22:02:38
End Time: Current Time
Backup Time: 2-Apr-08 02:01:07
______________________________________________________
and I need to extract the "Archive[x]... Start Time:... End Time:.... lines, printed on (1) SINGLE line
expected output: "Archive[x]...Start Time:...End Time:...
here's my code:
When I run this, it prints out: " ... ... End Time: " meaning, only the 3rd regular expression gets printed. Why won't the first and second Regular Expression print? all I get is a space.
Thank you in advance.
____________________________________________________
Archive[0]: d:\archives\piarch.012 (500MB, Used: 9.0%)
PIarcfilehead[$Workfile: piarfile.cxx $ $Revision: 114 $]::
Version: 5 Path: d:\archives\piarch.012
State: 4 Type: 0 (fixed) Write Flag: 1 Shift Flag: 1
Record Size: 1024 Count: 512000 Add Rate/Hour: 4118.3
Offsets: Primary: 25853/128000 Overflow: 491596/512000
Start Time: 1-Apr-08 22:02:38
End Time: Current Time
Backup Time: 2-Apr-08 02:01:07
______________________________________________________
and I need to extract the "Archive[x]... Start Time:... End Time:.... lines, printed on (1) SINGLE line
expected output: "Archive[x]...Start Time:...End Time:...
here's my code:
Code:
my $m1;
my $m2;
$filename = "PIDATA";
open( FILE, "< $filename" ) or die "Can't open $filename: $!";
print "PI Archive Record Extraction.\n";
print "Matthew R. Lambdin\n";
print "______________________________________________________\n";
while(<FILE>){
chomp;
if(/^\s*Archive\[\d+\].*/){
$m1 =~ $_;
}
if(/^\s*Start\s+Time.*/){
$m2 =~ $_;
}
if(/^\s*End\s+Time.*/){
print "$m1 ...$m2 ...$_\n";
}
}
When I run this, it prints out: " ... ... End Time: " meaning, only the 3rd regular expression gets printed. Why won't the first and second Regular Expression print? all I get is a space.
Thank you in advance.