Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Hash problem

by rupesh (Hermit)
on May 19, 2005 at 04:29 UTC ( #458516=note: print w/ replies, xml ) Need Help??


in reply to Hash problem


use strict; my %hash; foreach(<DATA>) { $hash{$1}=() if /JSESSIONID=(.*)$/; } foreach (sort keys %hash) { print $_."\n"; } __DATA__ [17/May/2005:18:15:59 -0700]sdjhsj USERID=t70xvcy; jdhdh JSESSIONID=00 +00RDnYTABcRWOx0UN2Zq--sZB:10f408hdg [17/May/2005:18:15:59 -0700]sdjhsj USERID=t70xvcy; jdhdh JSESSIONID=00 +00RDnYTABcRWOx0UN2Zq--sZB:10f408hdg [17/May/2005:18:15:59 -0700]sdjhsj USERID=t70xvcy; jdhdh JSESSIONID=00 +00RDnYTABcRWOx0UN2Zq--sZB:10f408g13


Cheers,
Rupesh.


Comment on Re: Hash problem
Download Code
Re^2: Hash problem
by bart (Canon) on May 19, 2005 at 09:24 UTC
    I am amazed that
    $hash{$1}=()
    works without warning, on 5.6.1 and on 5.8.4, as does
    my $x = ();

    Can anybody explain, are my expectations so off?

      From perldata:

      If you evaluate an array in scalar context, it returns the length
      of the array. (Note that this is not true of lists, which return the last
      value, like the C comma operator, nor of built-in functions, which
      return whatever they feel like returning.)

      An empty list doesn't have any values, so trying to get the last value gives you undef.


      We're not surrounded, we're in a target-rich environment!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (14)
As of 2015-07-06 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (80 votes), past polls