Amit Saxena wrote: > > I could be a very basic question but I am unable to find any answers on > internet. > > What's the difference between "=>" and ">=" in Perl ? > > To the best of my knowledge, ">=" means greater than or equal to and "=>" is > just used instead of comma to distinguish between key and values while > assigning a hash. > > I am unable to justify the output of the following program (for "=>" > operator)
[snip] > if ($i => 5) > { > print "\nInside If"; > } > else > { > print "\nInside Else"; > } > > print "\n"; > $ perl y.pl > Useless use of private variable in void context at y.pl line 26. > > Inside If => is exactly equivalent to a comma, everywhere, except that it has the added effect that it quotes a bareword value preceding it, so print XX => $_ => "\n"; is the same as print 'XX', $_, "\n"; so your conditional statement is if ($i, 5) { ... } which evaluates $i and throws it away (hence your warning) and then evaluates 5, which is true. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/