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!

I do not understand Argument "May" isn't numeric in numeric eq (==) at

Status
Not open for further replies.

MkIIISupra

Programmer
Apr 17, 2002
108
US
Below is the error I get when I try to run a script I am slowly building. I am in the learning process with Perl and this is my 3 script that I have written. The first two were very simple and short. My goal with this script when I finish is to have a CRON job scan a predefined directory and when specific files appear, move (and copy in some cases) the files to a predetermined directory, rename them and in specific cases e-mail a copy of the files to predefined recipients. The intent is to ensure all reports and files are delivered and filed correctly. Please be patient as I am a total newb to Perl, and I do have several books but I am still getting stumped with this one.

Linux: perl Report\ Processor
Argument "Jan" isn't numeric in numeric eq (==) at Report Processor line 15.
Argument "May" isn't numeric in numeric eq (==) at Report Processor line 15.
Guess what! Jan, worked!
Linux:

Here is the code that generates the error above:

Code:
#!/bin/bash/perl -w
# This is a rename and move script. The goal is to rename files then move them to their
# appropriate folders, and then e-mail (hopefully) the files to pre-defined people.
use warnings;
use strict;
use Time::Local;

my $date = `date`; # Load $date with system date.

chomp $date; # Clear any trailing spaces

my $mMonth = substr ($date, 4, 3); # Move month into mMonth to be used to perform renames and moves based on the month.

if ($mMonth == "Jan"){
	print "Guess what! Jan, worked! \n";
}
elsif ($mMonth == "Feb"){
	print "Guess what! Feb, worked! \n";
}
elsif ($mMonth == "Mar"){
	print "Guess what! Mar, worked! \n";
}
elsif ($mMonth == "Apr"){
	print "Guess what! Apr, worked! \n";
}
elsif ($mMonth == "May"){
	print "Guess what! May, worked! \n";
}
elsif ($mMonth == "Jun"){
	print "Guess what! Jun, worked! \n";
}
elsif ($mMonth == "Jul"){
	print "Guess what! Jul, worked! \n";
}
elsif ($mMonth == "Aug"){
	print "Guess what! Aug, worked! \n";
}
elsif ($mMonth == "Sep"){
	print "Guess what! Sep, worked! \n";
}
elsif ($mMonth == "Nov"){
	print "Guess what! Nov, worked! \n";
}
elsif ($mMonth == "Dec"){
	print "Guess what! Dec, worked! \n";
}
else {
	print "Oh HELP ME! The date function failed! \n";
}



One by one the penguins return my sanity, as day by day Microsoft steals my sanity!

OpenSuSE 10.0 kicks fanny!
 
In perl == is used for equality testing between numeric variables. U
se the eq operator for testing equality of strings...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Oh, do I feel like a heel... Thank you!

One by one the penguins return my sanity, as day by day Microsoft steals my sanity!

OpenSuSE 10.0 kicks fanny!
 
you can also use the diagnostics pragma with your perl scripts during development for more detailed descriptions of many warnings:

use warnings;
use diagnostics;





------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top