Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Using split() to divide a string by length

by chibiryuu (Beadle)
on Apr 13, 2006 at 20:10 UTC ( [id://543211]=note: print w/replies, xml ) Need Help??


in reply to Using split() to divide a string by length

This doesn't use split, but is the first thing I think of:
my $string = join '', 'a'..'z'; my @fields = $string =~ /.{1,3}/g; my @fields2 = grep {$a=!$a} @fields;
Hmm, $string =~ /.{1,3}/g should even be faster than split /(?(?{pos() % 3})(?!))/, $string.  I guess not as fast as unpack, though.

Replies are listed 'Best First'.
Re^2: Using split() to divide a string by length
by Roy Johnson (Monsignor) on Apr 13, 2006 at 21:03 UTC
    What is your grep line all about?

    Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 17:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found