[tpm] Array slice using a variable question
xdaveg at gmail.com
Fri Jul 11 12:57:10 PDT 2008
But be sure you can trust the string before you do that.
On Fri, Jul 11, 2008 at 3:45 PM, Mark Fowle <mfowle at navicominc.com> wrote:
> I want to slice an array using info passed in a text string (in my
> example $slice).
> Maybe it's because its Friday, but my forehead is starting to hurt from
> the banging.
> Any help would be appreciated.
> Thanks in advance.
> ---- Snipit ----
> use strict;
> use warnings;
> my $slice = "1..3";
> my @in = qw(a b c d e f g h);
> my @out = $in[$slice];
> my $p = join(" ", at out);
> print "$p\n";
> ---- Output ----
> Argument "1..3" isn't numeric in array slice at ./test.pl line 7.
> ---- I wanted ----
> b c d
> toronto-pm mailing list
> toronto-pm at pm.org
More information about the toronto-pm