[tpm] Array slice using a variable question
mfowle at navicominc.com
Fri Jul 11 13:00:28 PDT 2008
Eval was my first thought but I'm not getting anywhere with it.
The input it fully tested in the real program, which runs in taint mode,
but thanks for the reminder.
From: David Golden [mailto:xdaveg at gmail.com]
Sent: Friday, July 11, 2008 3:57 PM
To: Mark Fowle
Cc: Toronto Perl Mongers
Subject: Re: [tpm] Array slice using a variable question
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>
> 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
> 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