Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

(joshua)Re: parsing a path

by joshua (Pilgrim)
on Jul 17, 2002 at 17:12 UTC ( [id://182517]=note: print w/replies, xml ) Need Help??


in reply to parsing a path

This might be easier than all that stuff you do with the array...
#!/usr/bin/perl -w use strict; my $path = '\nb\v5\srcccc\ans.cpp@@\main\\'; my ($dir, $subDir, $file) = $path =~ /^\\([^\\]+)\\([^\\]+).*?(\w+\.cp +p)/; print "$dir\n$subDir\n$file\n";
Joshua

Replies are listed 'Best First'.
Re: (joshua)Re: parsing a path
by Juerd (Abbot) on Jul 17, 2002 at 17:30 UTC

    /^\\([^\\]+)\\([^\\]+).*?(\w+\.cpp)/

    And you say that might be _easier_? :)

    Anyway, I think you missed a $ (or even better: \z) there... \foo\bar\baz.cpp.cpp.cpp.blah.cpp.

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

      Ah, good point. I was just building on kvale's code though.
        How about this way..
        #!/usr/bin/perl -w use strict; while (<DATA>) { my @a = split(/\\/); print "$a[1] $a[2] $a[4]\n"; } __DATA__ \nb\v5\srcccc\ans.cpp@@\main\ \nb\v5\srcccc\ans.cpp@@\main\ \nb\v5\srcccc\test.cpp@@\main\ \nb\v5\safe\test.cpp@@\main\ \nb\v5\safe\test.cpp@@\main\

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-25 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found