Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Is there any way to make an array non-greedy?

by sk (Curate)
on Oct 14, 2005 at 16:53 UTC ( [id://500301]=note: print w/replies, xml ) Need Help??


in reply to Is there any way to make an array non-greedy?

Did you mean to do this?

use strict; use warnings; my $string = join('x', ('a')x20); ### NOTE the ()'s print $string,$/; my (@foo, $foo); (@foo[0..18], $foo) = split('x', $string); print $foo[0],$/; print "Success!\n" if $foo eq "a"; __END__ axaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxa a Success!

I don't quite understand your  join('x', 'a'x20); otherwise. Why join a scalar?

cheers

SK

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2024-04-18 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found