Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
The OP won't understand it (heck even I don't)
Want a spoiler?
+($\=\1)-$\ evaluates to zero, so we can take those out.
+($/=\1)-$/ evaluates to zero too, just we need one of them to set the input separator $/ to 1 (bytewise reading).
We can also take out the subsequent commas from the join (since they do nothing), so the first line becomes:
open OUTPUT, join "", map chr,112,114,116,51,46,116,120,116; $\=""; $/=\1;
The numbers are the ordinals of the single chars of the filename "part3.txt".

Now for the while loop. If we write it clearer it looks like
while(<OUTPUT>) { $\="$\$_"; $_=$\; $\ = substr((push @w,$\),0,0) if $\=~ /\s$/msg; }
$\="$\$_"; simply concatenates the read char with $\.
$_=$\; has no effect.
$\ = substr((push @w,$\),0,0) if $\=~ /\s$/msg; pushes $\ to an array if the last char of $\ is a whitespace or newline, thus a "word".
In the same statement $\ is cleared because the return value of substr(something, 0,0) is empty.

The last part is a simple grep of the array we built. We can safely leave out the eval so it becomes:
print grep{ /^\b.*(p).*$/msgi } @w
Alter the regex here to your liking.

holli, /regexed monk/

In reply to Re^3: Pattern matching by holli
in thread Pattern matching by Stud_Perl

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2022-05-19 23:00 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (72 votes). Check out past polls.