Hello monks! I'm a little new to this and I can't figure
out a way to parse off of a back slash? My current output
is:
6/21/2001 11:55:04 Object Name: \Device\HarddiskDmVolumes\PhysicalDmVolumes\BlockVolume2\CISER\ArchiveData^ Primary User Name: jch6^
but I want it to look like this:
6/21/2001 11:55:04 \CISER\ArchiveData Primary User Name: jch6
Current code is a mess and I'm sure it could be handled better
#!/user/bin/perl -w
use win32;
#use strict;
use warnings;
my $infile="dump1.txt";
my $outfile="newdump.txt";
my @x=();
open(FILE, $infile) or die "log560.pl can't open $infile for reading:
+$!";
open(OUTPUT,">$outfile") or die "log560.pl can't open $outfile for wri
+ting: $!";
#Look only at the summary lines where $_ == 560
while (defined ($_ = <FILE>)) {
next unless ($_ =~ /560/); #we only want the files with 560
$_ =~ s/`/,/g; #this is here to get the user name because ' i
+s after name
@x=split(/,/);
if (!($x[16] =~ /Primary User Name: CISERFS1/)) { #dont want t
+he details from the sytem
my $date=$x[1]; #good
my $time=$x[2]; #good
my $disk=$x[12]; #good
my $user=$x[16]; #good
print OUTPUT "$date $time $disk $user \n"; #good
} #end if the one WAY up there the one for ciserf1
} # end while
close FILE;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.