Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^4: Robocopy log parsing

by bit5nip3r (Initiate)
on May 28, 2012 at 16:25 UTC ( #972841=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Robocopy log parsing
in thread Robocopy log parsing

Still does not work. can't extract text from a line based on a regexp. It does not get assigned to $dir. What do I need to do to re-write so that for each New File there is a corresponding folder path?


Comment on Re^4: Robocopy log parsing
Re^5: Robocopy log parsing
by ww (Bishop) on May 28, 2012 at 19:14 UTC
    Pointer re choroba's answer: perlre, perlretut, etc. As you've written the regex, it's effectively a noop because you haven't assigned a value to $dir.

    Beyond that, it may be that your intent and the regex's behavior don't agree. The \n is the wrong way to tackle the end of a line -- if, in fact, you need to anchor to an EOL... but you haven't offered any information to suggest it's needed at all.

    So, perhaps you want something like this (after assigning a value to $dir):

    $dir =~ m/([a-z:]+).*?/; $dir = $1; print $dir;

    The parens capture to $1 the content matching a-z & colon more than one time... for ex, "C:"

      Thanks for this. "Example" - is a typical log file entry I have:

      New Dir 16 x:\xxxxxx\xxx\ New File 126862 xxxxxxxxxxxxxxxxxxxxxxx.xxx New File 48640 xxxxxxxxxxxxxxxxxxxxxxxxx.xxx New File 96494 xxxxxxxxxxxxxxxxxxxxxx.xxx New File 105466 xxxxxxxxxxxxx.xxx New File 653655 xxxxxxxxxx.xxx New File 542396 xxxxxxxxxxxxxx.xxx New Dir 6 y:\yyyyyyyyy\yyyyyyyyyyy\yyyyyyy\ New File 41984 yyyyyyyyyyyyyyyyyy.yyy New File 10007 yyyyyyyyyyyyyyy.yyy New File 1.3 m yyyyyy.yyy

      "Result" - what I want to achieve is this:

      New Dir 16 x:\xxxxxx\xxx\ New File x:\xxxxxx\xxx\ 126862 xxxxxxxxxxxxxxxxxx +xxxxx.xxx New File x:\xxxxxx\xxx\ 48640 xxxxxxxxxxxxxxxxxx +xxxxxxx.xxx New File x:\xxxxxx\xxx\ 96494 xxxxxxxxxxxxxxxxxx +xxxx.xxx New File x:\xxxxxx\xxx\ 105466 xxxxxxxxxxxxx.xxx New File x:\xxxxxx\xxx\ 653655 xxxxxxxxxx.xxx New File x:\xxxxxx\xxx\ 542396 xxxxxxxxxxxxxx.xxx New Dir 6 y:\yyyyyyyyy\yyyyyyyyyyy\yyyyyyy\ New File y:\yyyyyyyyy\yyyyyyyyyyy\yyyyyyy\ 41984 + yyyyyyyyyyyyyyyyyy.yyy New File y:\yyyyyyyyy\yyyyyyyyyyy\yyyyyyy\ 10007 + yyyyyyyyyyyyyyy.yyy New File y:\yyyyyyyyy\yyyyyyyyyyy\yyyyyyy\ 1.3 m + yyyyyy.yyy

      It's almost there except I can't get the full folder path to match its associated file(s)

      To get $dir to work, does that go within my loop?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://972841]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-12-27 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls