On Tue, 14 Sep 2004, c r wrote:

> Can the perl split function split a random 40 character string into 
> five 8 character strings?
>
> With random I mean that there is no special pattern in the 40 
> character string that can be used as split markers.

Wouldn't substr make more sense, or a regex?

    $ cat ~/bin/test.pl
    #!/usr/bin/perl -w
    
    use strict;
    
    my $string = qq[a2345678b2345678c2345678d2345678e2345678];
    
    my ($a,$b,$c,$d,$e) = $string =~ m/(.{8})(.{8})(.{8})(.{8})(.{8})/;
    
    print qq[
        \$string = $string
        
        \$a = $a
        \$b = $b
        \$c = $c
        \$d = $d
        \$e = $e
    
    ];

    $ perl ~/bin/test.pl
    
        $string = a2345678b2345678c2345678d2345678e2345678
        
        $a = a2345678
        $b = b2345678
        $c = c2345678
        $d = d2345678
        $e = e2345678
    
    $


This seems to be what you want, right ?


-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to