http://www.perlmonks.org?node_id=748082

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.

    -derby
      And, anyway, %hash = {} does not do what himanshu.padmanabhi think it does. To clear a hash in perl, we do:
      %hash = ()
      or
      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:

    hash={};

    -- 
    Ronald Fischer <ynnor@mm.st>
      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.
      -derby