On 11/30/06, Chris Parker <[EMAIL PROTECTED]> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Adriano Ferreira wrote:
> On 11/30/06, Chris Parker <[EMAIL PROTECTED]> wrote:
>> while(@numbers = <>) {
>>
>> # Extract widths @width = split(" ", $numbers);
>
> Here at this piece of code, @numbers and $numbers are different
> variables. And you never assign anything to $numbers. Probably you
> want this:
>
> while (<>) { # read a line my @numbers = split /\s+/, $_; # split
> the line (using spaces as the delimiter)
>
>
I added what you suggested and this is what I get now:
Enter Total Square Footage: 1200
Enter widths separated by spaces:
3 4
Argument "3 4" isn't numeric in division (/) at calc.pl line 27, <>
line 2.
size = amount needed = 300
Sorry. I pointed the immediate problems but hasn't look deeply into
what you were trying to do. You want to read many numbers input from
STDIN and then make a loop for them. So you should remove the
construction of @numbers from the loop, doing
I am missing something, probably very obvious. It isn't getting the
split numbers.
Code is:
while(<>)
{
# Extract widths
chomp();
my @numbers = split /\s+/, $_;
my $result = &calculate;
print("size = amount needed = $result \n");
}
my @numbers = split /\s+/, <>;
for my $width (@numbers)
my $result = &calculate($width);
print("size = amount needed = $result \n");
}
I hope it helps more this time.
while(<>)
{
# Extract widths
chomp();
my @numbers = split /\s+/, $_;
my $result = &calculate;
print("size = amount needed = $result \n");
}
sub calculate {
my $a = $_;
my $value = $a / 12;
my $b = $value * $squareft;
return $b;
}
thanks again for your help
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
iD8DBQFFbtlkmGeA9U+OoOcRApbxAJ4qR/h9YEjsOa3/pwtWyFKTzgbELgCgjvG7
wQsCL1u3pf+xsicNGds8ixA=
=hq8M
-----END PGP SIGNATURE-----
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>