Data::Dumper is a good tool to visualise complex data structures, not to access them. In this case, you could access the JSESSIONID directly (since domain and path seem to be constant):
print $jar->{COOKIES}{'example.com'}{'/'}{'JSESSIONID'}[1], "\n";
But there is a better way. Since $mech->cookies() returns an HTTP::Cookies object, you should use its methods to access the cookie. The scan() method should accomplish what you want.
# ... as before, set $jar = ... sub callback { # 0 version # 1 key # 2 val # 3 path # 4 domain # 5 port # 6 path_spec # 7 secure # 8 expires # 9 discard # 10 hash #-- add more comparisons to narrow the search result print "Cookie: $_[2]\n" if $_[2] =~ /^8430/; } $jar->scan( \&callback );
See also perldsc, HTTP::Cookies, and maybe Data::Diver.
In reply to Re: Data::Dumper and Cookies
by Perlbotics
in thread Data::Dumper and Cookies
by PerlSufi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |