Hi Shlomi,
On Saturday 29 December 2012 10:23 PM, Shlomi Fish wrote:
Hi Omps,

On Sat, 29 Dec 2012 22:12:14 +0530
Om Prakash Singh <torque.in...@gmail.com> wrote:

Hi All,

I am new to perl and while going through the chapters of Learning perl,
i just came through one excessive, while i was able to complete it, i
just came across something that didn't work and i couldn't find any
explanation for it. Would be great if i get some help in understanding
this behavior.

A few comments on your code:

below is the code

print "the string: ";
$string = <STDIN>;
print "the no.: ";
chomp($number = <STDIN>);
$result = $string x $number;
print "the result is:\n$result";

1. Add "use strict" and "use warnings".

2. Declare all variables using "my".

For more see:

http://perl-begin.org/tutorials/bad-elements/

Regards,

        Shlomi Fish

in the above code when i use
$result = $string x $number;
i get the right result, i.e. strings printed on two lines.

but, when i use
$result = $number x $string;
I don't get any output at all, just wondering why this happens, any help
would be highly appreciable.

Regards,
Omps


Thanks for the response, using the
use strict;
use warnings;
did gave me something like

Argument "om\n" isn't numeric in repeat (x) at learning.pl line 51, <STDIN> line 2.

so i believe the x operator wants the number as the second variable.

Regards,
omps.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to