why not use & for a function call? Aren't & and ( ) the same? I used local originally b/c I wanted to use this globally from within the function. Is there a preferred way to use local?
thanks Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams 614-566-4145 "Wiggins d Anconia" <[EMAIL PROTECTED]> 04/27/2004 03:06 PM To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject: Re: erorr with "use constant" > > Can any provide some help? > I am getting this error: > > edm01:/usr/local/bin/perl>> perl -c tape_rotation_vaulting.pl > String found where operator expected at tape_rotation_vaulting.pl line 64, > near" > (Do you need to predeclare TWENTYONEDAYS_STRING?) > syntax error at tape_rotation_vaulting.pl line 64, near > "TWENTYONEDAYS_STRING "" > tape_rotation_vaulting.pl had compilation errors. > I think this is misleading you and you actually need an operator. > > I want to be able to print the string "There are xxxxx seconds in 21 days" > xxxx would come from the constant TWENTYONEDAYS_STRING. > > thanks! > > ## Set pragmas > > # use strict; > # use diagnostics; > Commenting out the above prevents them from helping you... The first should never need to be commented. > ## Set variables > > #my $twenty_one_days="/usr/local/log/21days.log"; > #my $thiry_days="/usr/local/log/30days.log"; > #my $ninety_one_days="/usr/local/log/91days.log"; > my $default="/usr/local/log/edmdefault.log"; > my $twenty_one_days_LnotesFS="/usr/local/log/LnotesFS.log"; > my $lvimg_L_Drive="/usr/local/log/lvimg_L_Drive.log"; > my $lvimg_K_Drive="/usr/local/log/lvimg_K_Drive.log"; > my $lvimg_JI_Drives="/usr/local/log/lvimg_JI_Drives.log"; > my $lvimg_GH_Drives="/usr/local/log/lvimg_GH_Drives.log"; > my $lvimg_FE_Drives="/usr/local/log/lvimg_FE_Drives.log"; > my $lvimg_DC_Drives="/usr/local/log/lvimg_DC_Drives.log"; > > ## Below are SC clients > > #my $idxsql="/usr/local/log/idxsql.log"; > #my $ORBaplog="/usr/local/log/ORBaplog.log"; > #my $ORBDsch="/usr/local/log/ORBDsch.log"; > #my $ORBmodel="/usr/local/log/ORBmodel.log"; > #my $ORBmsdb="/usr/local/log/ORBmsdb.log"; > #my $ORBOHusr="/usr/local/log/ORBOHusr.log"; > #my $ORBPo="/usr/local/log/ORBPo.log"; > #my $ORBPr="/usr/local/log/ORBPr.log"; > #my $ORB="/usr/local/log/ORB.log"; > > > system ("clear"); Know why this may or may not work... > > ## Epoch time == 21,30 and 91 > > ## Define global constants > > use constant TWENTYONEDAYS_STRING => 60 * 60 * 24 * 21; > use constant THIRTYDAYS_STRING => 60 * 60 * 24 * 30; > use constant NINETYONEDAYS_STRING => 60 * 60 * 24 * 91; > > # use constant THIRTYDAYS_STRING => localtime(time + 2592000); > # use constant NINETYONEDAYS_STRING => localtime(time + 7862400); > > > &timing; > Drop the ampersand until you know why you need it. timing(); Is preferred. > sub timing { > local $now_string = localtime; Use lexicals instead of locals until you know why you shouldn't. my $now_string = localtime; > print $now_string, "\n"; > print "\n"; > printf "There are ", TWENTYONEDAYS_STRING "seconds in 21 days"; perldoc -f printf printf takes a format followed by optional parameters to be dropped into that format, you don't need it here. print "There are " . TWENTYONEDAYS_STRING . "seconds in 21 days"; Should work. I believe your error is caused because you are missing a comma after the constant. HTH, http://danconia.org