Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Calculate Min Value
Please see the code below based on suggestions from this group.
=========== Actual Code ============
$i=0;
sub min {
my $min = shift(@_);
foreach my $value (@_) {
if ($value < $min) {
$min = $value;
}
}
return $min;
}

open INV_RPT, "$_inventory_rpt" or die "Can't open file handler";
open (INV_RPT_MIN, ">$_inventory_rpt_min");

while($Ctmp1 = <INV_RPT> )
{
chop($Ctmp1);
@Ctmp2=split(/~/,$Ctmp1);
$items{$Ctmp2[0]}=$Ctmp2[0];
}
foreach my $item (<> )
{
my @columns = split(/\~/, $line);
push($data{$columns[0]}, \@columns);
}

foreach $item (keys %items)
{
my @colums2values = map {$_->[3]} (@{$items{$item}});
my @colums2values = map {$_->[4]} (@{$items{$item}});
my @colums2values = map {$_->[5]} (@{$items{$item}});

print INV_RPT_MIN "$item: ".min(@colums2values);
}
=======

I get the following error message on executing the above code,
==== error message ========
Type of arg 1 to push must be array (not hash element) at
F:\scripts\inve
ntory_rpt_min.pl line 42, near "@columns)"
============================

Q: How do I resolve the above issue? Please point out problems with
the code.
Q: Is there a way to provide dynamic variable $i to @columns2values so
it looks at all columns starting at col.2 to the end-of-file.

Thanks for the help!!

Report this thread to moderator Post Follow-up to this message
Old Post
Ilyas Hassan
10-26-04 08:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:46 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.