Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

RE: RE: Re: searching backwards in a string

by plaid (Chaplain)
on Jun 14, 2000 at 20:58 UTC ( #18138=note: print w/replies, xml ) Need Help??

in reply to RE: Re: searching backwards in a string
in thread searching backwards in a string

The code snippit does not loop infinitely, regardless of loop body. As stated, the result is in $1. It then becomes trivial to write a test program to see how it works. In fact, I'll take care of it for you.
use strict; my $text = "This is a long line that I am typing to demonstrate". " the way that my regular expression works and it's a". " run-on sentence too but I don't really care."; print $1, "\n" while($text =~ /(.{0,20})\s+/g);
Has a slight problem of not grabbing the last line, but it's 99% of the way there, and besides, that's why you should use a module in the first place:)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2022-01-27 21:24 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (71 votes). Check out past polls.