in reply to Re: What's your favourite method of untainting?
in thread What's your favourite method of untainting?

thanks for this. As it now issues the warning (perl v5.36.0):

each on anonymous hash will always start from the beginning

I propose this variation: ($foo) = keys %{{$foo,0}}

Also, here is a test script using Test::Taint to check taintness:

#!perl -T use strict; use warnings; use Test::More; use Test::Taint; my $foo = "ababab"; taint($foo); tainted_ok($foo, "foo is tainted"); ($foo) = keys %{{$foo,0}}; untainted_ok($foo, "foo is now untainted"); done_testing;

bw, bliako

Replies are listed 'Best First'.
Re^3: What's your favourite method of untainting?
by ysth (Canon) on Oct 09, 2024 at 19:50 UTC
    Or $foo = (keys %{{$foo,0}})[0]
    --
    A math joke: r = | |csc(θ)|+|sec(θ)| |-| |csc(θ)|-|sec(θ)| |