Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

clear perl hash variable

by himanshu.padmanabhi (Acolyte)
on Mar 04, 2009 at 11:38 UTC ( #748082=perlquestion: print w/replies, xml ) Need Help??
himanshu.padmanabhi has asked for the wisdom of the Perl Monks concerning the following question:

how to clear perl hash variable in javascript? In perl,we do it using %hash={}; I am not sure in which forum I should post this. not all javascript ppl might be aware of perl hash.

Replies are listed 'Best First'.
Re: clear perl hash variable
by derby (Abbot) on Mar 04, 2009 at 12:09 UTC

    himanshu.padmanabhi, you're post is confusing. Take a look at How do I post a question effectively?. Taken as it's written, what you're asking is odd - since the Javascript is client-side (browser) and perl is server-side (web server) and the two normally do not run together in the same process -- unless you have some funky Inline thing happening or you're doing something wild like using Javascript to create perl code.

      And, anyway, %hash = {} does not do what himanshu.padmanabhi think it does. To clear a hash in perl, we do:
      %hash = ()
      undef %hash
      or, if $hash is a hash reference,
      %$hash = ()
      or, somewhat similarly but not exactly the same,
      $hash = {}
      or, also somewhat similarly but not exactly the same,
      undef $hash
      []s, HTH, Massa (κς,πμ,πλ)
Re: clear perl hash variable
by rovf (Priest) on Mar 04, 2009 at 12:03 UTC

    I would do it similar:


    Ronald Fischer <>
      That's how you would clear a Javascript object (which may be what the OP is after, who knows) but not a perl hash *in* Javascript.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://748082]
Approved by rovf
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2018-05-22 18:46 GMT
Find Nodes?
    Voting Booth?