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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.