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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.