Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 contemplating the Monastery: (6)
As of 2014-08-28 05:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (257 votes), past polls