http://www.perlmonks.org?node_id=99103

c has asked for the wisdom of the Perl Monks concerning the following question:

i am in need of a head check. mine hurts and i am afraid my code is the cause.
i am trying to pass an argument to a subroutine i have built that generates a .htaccess file. my question is whether or not i am calling the right variable as it is passed to my sub.

my @webhost = glob("$www/*"); if ($panel) { for my $i(@webhost) { if ( -d $i ) && ( $i ne "lost+found" ) && ( $i ne "DEFUNCT" ) { if ( -d $i/controlpanel ) { system("cp -fRp $dir $i"); } else { mkdir $i/controlpanel/; system("cp -fRp $dir $i"); } } htaccess($i); } } sub htaccess { my $fqdn = shift; open(FH,">/www/$fqdn/controlpanel/.htaccess"); print<<HTA; AuthUserFile /etc/htsec/$fqdn.ht AuthName "Hosting Administration" AuthType Basic require valid-user HTA close(FH); }

my biggest concern is that the $fqdn is being set to the $i value without any gotchas, e.g. do i need to chomp this bad boy to create the file or any other ghosts i may not be seeing. also, i am using shift to pull the value out of @_ in my subroutine. is this the right way to do this? granted in this example $i is a single value rather than multiple strings being passed to the sub-routine, but i am sure i am going to make use of this again in the near future.

humbly -c