You checked what? I asked for a regular expression - not for three pages of code and a link to somebody's totally irrelevant custom module!

Meanwhile, I figured out that the horrible BBoard software which this site uses simply mangles the posted code and to get the real stuff, you have to click on the "download" linke (which doesn't download!) and cut-and-paste from the page that opens.

So, I managed to make TJPride's script output something meaningful:

"some file" 'another file' yet\ another\ file

Unfortunately, it is also wrong. This is not the proper output. The proper output, which such data, would be:

some file another file yet another file

Furthermore, I don't want all the stuff loaded into some kind of an array and everything in that array matched simultaneously. I have to do other stuff with each line, you know? I want to process the file line-by-line and, for this particular problem, I need a regular expression that fetches the file name after the "@include" keyword.

Let's make this very simple, shall we? Consider this snippet of code:

my $data = SOME STRING; if ($data =~ SOME EXPRESSION) { print "File name: \"$_\"\n"; }

Question: What should SOME EXPRESSION be, so that if SOME STRING is

"\@include file"

or

"\@include \"some file\""

or

"\@include another\\ file"

the output is respectively

File name: "file"

or

File name: "some file"

or

File name: "another file"

Please do not answer, unless you have tested that your answer actually produces the desired output.


In reply to Re^4: Help with a regular expression for file name parsing by bontchev
in thread Help with a regular expression for file name parsing by bontchev

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.