in reply to Re: Use of uninitialized value $_ in string
in thread Use of uninitialized value $_ in string
Hi frozenwithjoy,
Yes, the line 32 is my $conf = "$_";. I've managed to remove the errors but I'm not so sure if this is the correct approach especially the declaration of the same variables under sub add_vhost. What I did was...
remove these variables from above:
my $conf = "$_"; my $conf_bn = basename($conf); my $conf_mtime = (stat($conf))[9]; my $date = strftime '%m%d%Y', localtime; my $backup = "$conf.$date"; my $backup_bn = basename("$conf.$date"); my $ltime = localtime();
then declared the $conf, $conf_bn, and $ltime variables under sub add_vhost.
sub add_vhost { my $conf; my $conf_bn; my $ltime;
and removed the comments from the variables under foreach...
foreach (@object) { my $conf = "$_"; my $conf_bn = basename($conf); my $conf_mtime = (stat($conf))[9]; my $date = strftime '%m%d%Y', localtime; my $backup = "$conf.$date"; my $backup_bn = basename("$conf.$date"); my $ltime = localtime();
The errors were gone every time I execute the script. However, after providing two required arguments, the script still does nothing. I was expecting it would start creating a backup of the existing file.
[root@wsprod01 myperl]# ./test.pl --domain google.com --client google Usage: ./test.pl --domain companydomain.com --client company [--job-co +de 12345] [--help].
Cheers,
JP
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Use of uninitialized value $_ in string
by AnomalousMonk (Archbishop) on Apr 05, 2014 at 15:15 UTC | |
by juanpablo (Novice) on Apr 06, 2014 at 09:08 UTC | |
by AnomalousMonk (Archbishop) on Apr 06, 2014 at 19:54 UTC | |
by Bloodnok (Vicar) on Apr 05, 2014 at 15:21 UTC | |
by AnomalousMonk (Archbishop) on Apr 05, 2014 at 15:50 UTC | |
by Bloodnok (Vicar) on Apr 06, 2014 at 12:17 UTC |
In Section
Seekers of Perl Wisdom