Programming in Perl - Need Some Help

qtipextra
5,000+ posts

The Original
Im dusting off my brain, trying to write a in Perl.

What I am doing is taking a log file and trying to return just the filename.

A line of the log file looks like this:

Code:
Error: SetupDecompressOrCopyFile() "C:\Documents and Settings\QTIP\Desktop\new\I386\BEEP.SYS" to "C:\UBCD4Win\BartPE\I386\SYSTEM32\DRIVERS\BEEP.SYS" 2: The system cannot find the file specified.
This is the code that I have so far. I am trying to use the split function to return the only the filename (the one listed first)

Code:
system ("cls") ;
open( FILE, 'log.log' ) or die( "Cannot open: $!" );
@log = <FILE> ;
close (FILE) or die ( "Cannot open: $!" );
foreach (@log) { @split = split (/Error:/, $_, 9999) ; }

print @split ;
And right now all this outputs is the last line of the log file, which is this:

Code:
Use the [<<] and [>>] buttons to jump to Error/Warning.
Anyone good with perl help me out?

 
So I had a DUH moment. I used the function in notepad "find and replace" to clear out all text before the file name, and eliminate "" 2: The system cannot find the file specified." on all lines, so now a line in the log.log looks like this:

Code:
BEEP.SYS" to "C:\UBCD4Win\BartPE\I386\SYSTEM32\DRIVERS\BEEP.SYS
I also forgot to use the push function to add each element back into the array, so I got back each line in the file.

I am, however, still having trouble splitting after the file name. Right now this will display each line in the file, without cutting anything out.

My script so far:

Code:
system ("cls") ;
open( FILE, 'log.log' ) or die( "Cannot open: $!" );
@log = <FILE> ;
close (FILE) or die ( "Cannot open: $!" );
foreach (@log) { 
split ( /M#"#/, $_) ; 
push (@output, $_) 
}

print @output ;
Any Ideas?

 
Activity
No one is currently typing a reply...

About this thread

qtipextra

5,000+ posts
The Original
Thread starter
qtipextra
Joined
Location
Idaho Falls, Idaho
Start date
Participants
Who Replied
Replies
2
Views
115
Last reply date
Last reply from
qtipextra
IMG_0710.png

michigan born

    May 14, 2026
  • 0
  • 0
IMG_0709.png

michigan born

    May 14, 2026
  • 0
  • 0

New threads

Top