Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: File regex question

by pzbagel (Chaplain)
on Sep 16, 2003 at 07:32 UTC ( [id://291749]=note: print w/replies, xml ) Need Help??


in reply to File regex question

I believe this code will work. I assume that the filename is the last thing on the line so I split on the :/ after the drive letter (notice it handles both types of slashes) and then it substitutes spaces anywhere after that in the string:

#!/usr/bin/perl -w use strict; + while(<DATA>) { my @line=split /(:[\\\/])/; $line[2]=~s/ /_/g; print join "", @line; } __DATA__ 124334 2323 c:\program files\somefile 124334 2323 c:\program files\somepath\somefile 124334 2323 c:\program files\with space/somefile 124334 2323 c:\program files\with space/with another space/somefile

HTH

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-28 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found