#!/usr/bin/perl -T use strict; %ENV = ( PATH => '/usr/bin' ); open my $filehandle, "< :utf8", "test.bin" or die $!; my $word = readline $filehandle; my ($untainted) = $word =~ /^(\w+)$/; if ($untainted) { # It passed the regex, so it is "safe". system "echo $untainted"; }