Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Dealing with split

by perl_99_monk (Novice)
on Feb 23, 2006 at 15:55 UTC ( [id://532300]=note: print w/replies, xml ) Need Help??


in reply to Re: Dealing with split
in thread Dealing with split

dsb I am using your command and need a little more help. If I want to get all the files that has an extension not just .c how can i specify that? In the command I see that .c is specified. Can I specify mutliple patterns or use a wild card so that it gets all the files with extension.I have few .c files, .java and .xml and some directories in the $str. I just want to filter out the directories and get the files. ie in addition to
'c:\temp\source\test\test.c@@main\com\etc c:\temp\source\test\test1.xm +l@@main\com\test c:\temp\source\test\test3\test2.c@@main\com\etc\test + c:temp\source c:\temp\source\java@@main\com\etc\test c:temp\source\ +java\test.java@@main\com\etc\test '
I want the out put to be
\test\test.c \source\test\test3\test2.c \test\test1.xml \source\java\test.java
THanks

Replies are listed 'Best First'.
Re^3: Dealing with split
by dsb (Chaplain) on Feb 23, 2006 at 16:10 UTC
    You can tweak the regex to match all extensions or feed it an alternation that will find only certain extensions.
    # match any file extension print map {"$_\n" if s/c:\\temp(.*?\.(?:\w|\d)+?)/$1/} split(/\s+|\@+/ +,$str); # match only a few extensions print map {"$_\n" if s/c:\\temp(.*?\.(?:c|xml|java|etc))/$1/} split(/\ +s+|\@+/,$str);
    I think you'd be better of using runrig's snippet at Re: Dealing with split, though.


    dsb
    This @ISA my( $cool ) %SIG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-24 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found