Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple(?) compilation problem - 'undef' operator

Status
Not open for further replies.

SeanR01

MIS
Jan 22, 2002
29
AU
Hi,

Can anyone help, I'm trying to compile a perl script, and get the following error:

Can't declare undef operator in my at defrag.pl line 1558, near ") ="
Execution of defrag.pl aborted due to compilation errors.

where line 1558 and thereabouts is:

my ( undef,undef,undef,$day,$month,$year,undef,undef,undef ) = localtime;
$date = $year + 1900 . $month + 1 . $day;

occurring in sub get_args, I think:

# sub get_args
#
# Uses supplied module Getopt::Long to place command line options into the
# hash %args. Ensures that at least the mandatory argument --tablespace
# was supplied. Also verifies directory arguments and connects to Oracle.

There's a getopt/long.pm file present under perl/lib. I'm assuming it's the right version, etc (as below). I'm compiling a script written for Unix on NT, but that shouldn't matter, hopefully.

# GetOpt::Long.pm -- Universal options parsing
package Getopt::Long;
# RCS Status : $Id: GetoptLong.pm,v 2.10 1997-04-18 22:21:10+02 jv Exp $
# Author : Johan Vromans
# Created On : Tue Sep 11 15:00:12 1990
# Last Modified By: Johan Vromans
# Last Modified On: Wed Apr 16 16:27:33 1997

I'm not at all proficient in perl, just want the script to go. I'm happy to supply all source code, etc. There's the possibility of other compile errors once getting past this one, although it's at line 1558/2700...

TIA,
Sean
 
Change line 1558 to
Code:
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
 
Sorry, make that
Code:
my ($sec,$min,$hour,[b]$day,$month,[/b]$year,$wday,$yday,$isdst) = localtime;
In other words, just replace the 'undefs'; let the existing var names stay the same.
 
The reason your original effort failed is because you can't assign another value to 'undef'. It looks like you just want the day, month and year, ignoring the rest of the values localhost returns. You can do that with a slice (i.e. just take elements 3 to 5), like so:
Code:
my ( $day, $month, $year ) = ( localtime )[ 3 .. 5 ];
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top