in reply to returning data from a for() loop?

How 'bout this:
push @x,substr($i,$_,1) for(0 .. length $i);

Update:Or this (uses map):

@x = map{substr($i,$_,1)}0 .. length $i;


The 15 year old, freshman programmer,
Stephen Rawls

Replies are listed 'Best First'.
Re: Re: returning data from a for() loop?
by strfry() (Monk) on Jun 08, 2001 at 23:26 UTC
    the first one worked just fine, with a tiny tweak:
    #!/usr/bin/perl -w use strict; my $hi = "flux"; print &scroll($hi); sub scroll { my ($i) = @_; my @x; push @x,substr($i,$_,1),"\n" for (0 .. length $i); return @x; }
    (:
    strfry()