Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Hash Printing reveals Hash Memory Location

by jwkrahn (Monsignor)
on Feb 03, 2012 at 03:51 UTC ( #951593=note: print w/ replies, xml ) Need Help??


in reply to Hash Printing reveals Hash Memory Location

if (($english && $foreign) eq '-1') {

The expression $english && $foreign will evaluate to either true (1) or false ("") but will never be equal to '-1'.



sub hash_processor::function () { my ($english, $foreign, $process) = @_;

Your prototype says that the subroutine accepts no arguments but the next line says that your subroutine does accept three arguments.    You shouldn't use prototypes.

You are using package names but I don't see where you are creating a package namespace.



if ($process == '0') {

That is usually written as $process == 0 or $process eq '0' depending on whether $process contains a string or a number.



$english = "$english" . "$hash_processor::tag_count"; $foreign = "$foreign" . "$hash_processor::tag_count";

That is usually written as:

$english .= $hash_processor::tag_count; $foreign .= $hash_processor::tag_count;


Comment on Re: Hash Printing reveals Hash Memory Location
Select or Download Code
Re^2: Hash Printing reveals Hash Memory Location
by tobyink (Abbot) on Feb 03, 2012 at 07:51 UTC

    The expression $english && $foreign will evaluate to either true (1) or false ("") but will never be equal to '-1'.

    Wrong. The "&&" operator doesn't return 1 or "". It returns the expression on the right side of "&&" if and only if both expressions are true.

    use 5.010; my $english = 'foobar'; my $foreign = -1; say ($english && $foreign); # says "-1" say ($foreign && $english); # says "foobar"
      It returns the expression on the right side of "&&" if and only if both expressions are true.
      It returns the expression on the right side if the expression on the left side is true.
      $ perl -E 'say "Yes" if "Foo" && 0 eq 0' # says "Yes" $ perl -E 'say "Yes" if "Foo" && "" eq ""' # says "Yes" $ perl -E 'say "Yes" if "Foo" && 0 eq ""' # Nothing
Re^2: Hash Printing reveals Hash Memory Location
by AnomalousMonk (Abbot) on Feb 03, 2012 at 19:22 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951593]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2014-12-21 02:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (101 votes), past polls