Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^3: Help with a regular expression for file name parsing

by bontchev (Sexton)
on Dec 09, 2011 at 08:26 UTC ( #942596=note: print w/replies, xml ) Need Help??

in reply to Re^2: Help with a regular expression for file name parsing
in thread Help with a regular expression for file name parsing

Sigh, the site mangled the code I posted. :-( I guess I've used the wrong tag. Let's try again:

use strict; use warnings; while (my $data = <DATA>) { if ($data =~ /\@include/i) { $data =~ m/\@include\s+('[^']+'|"[^"]+"|.+?(?<!\\))\s/gi; my $fname = $1; $fname =~ s/\\([rnt'"\\ ])/"qq|\\$1|"/gee; $fname =~ s/^"(.*)"$/$1/s or $fname =~ s/^'(.*)'$/$1/s; print "File name: <$fname>\n"; } } __DATA__ #some "random stuff" @include "some file" did you parse that? #more 'random' stuff @include 'another file' you sure? #and more random stuff @include yet\ another\ file positive? #@Include file # @include "\"another one\"" hmmm... # some stuff

Replies are listed 'Best First'.
Re^4: Help with a regular expression for file name parsing
by BrowserUk (Pope) on Dec 09, 2011 at 09:35 UTC

    Ah. So my regex wasn't so useless to you after all.

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942596]
[Corion]: I hope all is well marto! ;) My godson had a surprise visit to the hospital yesterday because he fell and had cut his skin besides his eye, but everything was glued together again and all is well
[marto]: good grief, that's not fun, glad to hear all is as well as could be :)
[Corion]: marto: Yeah - their mother picked all three of them up at the kindergarden to then go to the hospital, and all three of them were well behaved, and all also were quite obedient when they came home, so they recognized the situation

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2016-12-08 09:20 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (137 votes). Check out past polls.