in reply to Getting To Grips With Taint - And Picking Up Files

I would rewrite this. Here's one way:

#! /usr/bin/perl -wT use strict; use warnings; my $dir = 'var/log/accounts'; opendir DIR, $dir or die "Cannot opendir $dir:$!\n"; my @files = grep !/^\.{1,2}$/,readdir DIR; closedir DIR; for (@files) { my $file = "$dir/$_"; open IN,$file or die "Cannot open $file:$!\n"; while (<IN>) { next if not /,/; my ($fullname,$username,$password,$domain,$service,$email,$upd +ates,$ip_addr) = split(/,/, $_); next if not $ip_addr; print "$fullname\t$username\t$password\t$domain\t$service\t$em +ail\t$updates\t$ip_addr\n"; } close IN; }

-- Regards,
Helgi Briem
helgi AT decode DOT is

Replies are listed 'Best First'.
Re: Re: Getting To Grips With Taint - And Picking Up Files
by Anonymous Monk on Sep 30, 2002 at 17:06 UTC
    Just one last question (if anybody is still reading this node). Taint complains about using unlink $file; What are the alternatives to that? Insecure dependency in unlink while running with -T switch at ./addvir +tuser.pl