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

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

by sk (Curate)
on Oct 14, 2005 at 16:53 UTC ( #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


Comment on Re: Is there any way to make an array non-greedy?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2015-07-05 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls