Posts

Showing posts from October, 2010

PERL and Anonymous Hashes and Debugging

PERL has a seemingly infinite number of libraries out there.  One that I find extremely helpful and which I just happened to stumble upon is the Data::Dumper one.  For anyone that has used Perl references and anonymous hashes, you know how tough debugging can be.   But Data::Dumper is so cool.  Just use the library and then print the main reference to see the whole tree: #!/usr/bin/perl use Data::Dumper; use warnings; use diagnostics; use strict; my ($nextline,$HOST,$COMPONENT,$RESTOFLINE,$PHASE,$INTERVAL,$FLOWS,$OVERFLOW); my ($masterHash); $masterHash = {}; while ( defined($nextline= ) ) {         chomp ($nextline);         if ( $nextline =~ m/^[A-Za-z]+\s+\d+\s+\d+:\d+:\d+\s+([A-Za-z0-9_]+)\s+\[\d+\]\s+([A-Za-z0-9_]+):(.*)$/ )         {                 $HOST = $1;                 $COMPONENT = $2;                 $RESTOFLINE = $3;                 $HOST = lc($HOST);                 $COMPONENT = lc($COMPONENT);                 if ( $RESTOFLINE =~ m/\s+\[\w+\]\s+\[\d+\]\s+([0-9])\s+:

Cookies, wget, & firefox

Modern Firefox versions store cookies in an sqllite database which makes them hard to extract.  There is an add-on that allows you to export, but that is overkill for me, since all i wanted to do was download a file using wget. Awesomely, the man page showed a really easy wy to do this quickly.... View your cookies through Firefox's normal Preferences->Privacy->Cookies. The name listed on the right is the Name.  Click on each name, and notice the value.  Put those together to get a command line that works: wget --no-cookies --header "Cookie:  <NAME>=<VALUE> "    https://example.com/dir/file1 Voila.