[vox-tech] perl: function with hash and scalar args

Peter Jay Salzman p at dirac.org
Thu Jun 24 14:46:39 PDT 2004


i have a function which takes a hash and scalar arg.  how is this done
correctly?  why is $scalar undefined at the print statement in
function()?


#!/usr/bin/perl
use strict;
use diagnostics;

sub function(%$)
{
   my (%hash, $scalar) = (shift, shift);

   print "hash: $hash{foo}\n";
   print "scalar: $scalar\n";
}

my (%hash, $scalar);

$hash{foo} = "hello";
$scalar    = "goodbye";

function(%hash, $scalar);



thanks,
pete


-- 
In theory, theory and practise are the same.  In practise, they aren't.
GPG Instructions: http://www.dirac.org/linux/gpg
GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D


More information about the vox-tech mailing list