CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Warning after add of -w

 



mmcw
User

Apr 13, 2001, 1:59 AM

Post #1 of 4 (471 views)
Warning after add of -w Can't Post

Hello,

I have a script that works fine.
I am now checking the code and have added the -w command to the perl executer.
#!/usr/local/bin/perl -w

The error log contains (after starting the script that runs still fine) the following warning:

Argument "6375<->6375|RUSH|17|Fly By Night||HARDROCK.label..." isn't numeric in ncmp at /data1/hypermart.net/mmcw/cgi-bin/Shop/Lib/list_category.pl line 305.

The warning point to the following code:

# Set values if values are empty
$r_in->{'row'} = 0 unless ($r_in->{'row'});
if ($r_in->{'row'}) {
$r_in->{'type'} = "a" unless ($r_in->{'type'});
$r_in->{'order'} = "a" unless ($r_in->{'order'});
}
else {
$r_in->{'type'} = "n" unless ($r_in->{'type'});
$r_in->{'order'} = "a" unless ($r_in->{'order'});
}

$r_data = sort_data($r_in->{'row'},$r_in->{'type'},$r_in->{'order'},$r_data);

Where $r_data is a array with the line:
6375|RUSH|17|Fly By Night||HARDROCK

The sort_data point to the following sub:

#####
#
# subroutine sort_data
# Subroutine that does the actual sort.
# Accepts 5 params viz..
# 1. The column number to sort. Column no. start from 0.
# 2. The type of sort numeric or alphabetic. Default is Alphabetic.
# 3. The order of sort. Default order is ascending
# 4. The referrence of the array that needs to be sorted.
# 5. The delimiter between the different column of the array.
###

sub sort_data {

my ($row,$type,$sort_order,$r_data) = @_;
my (@array);

if ($type eq "n") {
if ($sort_order eq "d") {
@array = map { (split ('<->', $_))[1] }
reverse sort {$a <=> $b}
map { join ('<->', lc ((split('\|', $_))[$row]) , $_) }
@{$r_data};
}
else {
@array = map { (split ('<->', $_))[1] }
sort {$a <=> $b}
map { join ('<->', lc ((split('\|', $_))[$row]) , $_) }
@{$r_data};
}
}
else {
if ($sort_order eq "d") {
@array = map { (split ('<->', $_))[1] }
reverse sort {$a cmp $b}
map { join ('<->', lc ((split('\|', $_))[$row]) , $_) }
@{$r_data};
}
else {
@array = map { (split ('<->', $_))[1] }
sort {$a cmp $b}
map { join ('<->', lc ((split('\|', $_))[$row]) , $_) }
@{$r_data};
}
}

return (\@array)
}

What does this warning mean and how to fix this warning or do I not have to fix this error.




Jasmine
Administrator

Apr 20, 2001, 8:48 AM

Post #2 of 4 (461 views)
Re: Warning after add of -w [In reply to] Can't Post

That error simply means that some of your data that's not numeric is being sorted by the numeric comparison operator <=>

Just check the data that's being sorted and make sure that you're using the correct comparison operator for the data that's being sorted.

PS -- it would be so much easier to read the code if you enclosed them in

Code
 and

tags (kill the extra space in the sample tags)



DSelver
Novice

Apr 20, 2001, 7:10 PM

Post #3 of 4 (457 views)
Re: Warning after add of -w [In reply to] Can't Post

Are the

Code
 and

tags the same as using

Code
 and




Jasmine
Administrator

Apr 20, 2001, 9:03 PM

Post #4 of 4 (453 views)
Re: Warning after add of -w [In reply to] Can't Post

Yes, it is.


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives