RE: named hash inside of hash

2004-06-08 Thread Andy_Bach
 I don't understand this line:

 $ips{$source_ip}-{$dest_ip}++;

 how can you access and increment something that doesnt exist?

Fancy name: autovivification - perl, w/ your best interests at heart 
(generally) knows what you want to do, so it automagically creates the 
source_ip hash entry (if it doesn't exist), creates the anon-hash (ditto), 
adds a dest_ip key (ibid) and sees the incr. op, so set a value to zero 
and increments it - bingo
 $ips{$source_ip}-{$dest_ip}++;
 if ( $ips{$source_ip}-{$dest_ip} == 1 ) {
 print First time $source_ip has sent $dest_ip packets!\n;
 }

On the other hand, autoV works for increment, but you should see a warning 
(you are using -w/strict right?) if you try::
 if ( $ips{$source_ip}-{$dest_ip} == 0 ) {
 print First time $source_ip has sent $dest_ip packets!\n;
 }
 $ips{$source_ip}-{$dest_ip}++;

Here, if it *is* the first time, as dest_ip doesn't exist, you'll see:
Use of uninitialized value in numeric eq (==) at 

In this case:
 unless ( $ips{$source_ip}-{$dest_ip} ) {
 print First time $source_ip has sent $dest_ip packets!\n;
 }
 $ips{$source_ip}-{$dest_ip}++;

gets around that as there's no compare - basically you're checking for 
truth, existence or non-zero.

Make any sense?

a

Andy Bach, Sys. Mangler
Internet: [EMAIL PROTECTED] 
VOICE: (608) 261-5738  FAX 264-5932

Hardware, n.:
The parts of a computer system that can be kicked.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: named hash inside of hash

2004-06-08 Thread Arms, Mike
Look up autovivification:

 
http://www.google.com/search?hl=enlr=ie=ISO-8859-1q=perl+autovivification
btnG=Search

Just part of the power of Perl.

--
Mike Arms


 -Original Message-
 From: Matt Bazan [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 08, 2004 4:51 PM
 To: [EMAIL PROTECTED]
 Subject: RE: named hash inside of hash
 
 
 Thanks for help, it's starting to make sense.  I don't understand this
 line:
 
  $ips{$source_ip}-{$dest_ip}++;
 
 how can you access and increment something that doesnt exist?  Thanks
 again.
 
  -Original Message-
  From: Peter Guzis [mailto:[EMAIL PROTECTED] 
  Sent: Tuesday, June 08, 2004 12:50 PM
  To: Matt Bazan; Thomas, Mark - BLS CTR
  Cc: [EMAIL PROTECTED]
  Subject: RE: named hash inside of hash
  
  Like this?
  
  ## begin code
  
  use strict;
  use Data::Dumper;
  
  my %ips;
  
  foreach my $source_ip ('192.168.1.2', '192.168.1.1', 
 '192.168.1.12') {
  
foreach my $dest_ip ('192.168.1.3', '192.168.9.19', 
 '192.168.9.1') {
  
  $ips{$source_ip}-{$dest_ip}++;
  
}
  
  }
  
  print Dumper \%ips;
  
  ## end code
  
   
  Peter Guzis
  Web Administrator, Sr.
  ENCAD, Inc.
  - A Kodak Company
  email: [EMAIL PROTECTED]
  www.encad.com 
  
  -Original Message-
  From: Matt Bazan [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, June 08, 2004 12:36 PM
  To: Thomas, Mark - BLS CTR
  Cc: [EMAIL PROTECTED]
  Subject: RE: named hash inside of hash
  
  
  Ok..here's a diagram:
  
  I need to setup a data structure that will keep track of a 
  source IP address.  Each source IP address I then need to 
  link to a destination IP
  (note: there can be multiple destiantion IP addresses for 
  each source) and a destination IP counter.  So, something like:
  
  source IP 1 - dst ip 1, counter
 dst ip 2, counter
 dst ip 3, counter
  source IP 2 - dst ip 1, counter
 dst ip 2, counter
  
  etc, etc.  Thanks! 
  
   -Original Message-
   From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED]
   Sent: Tuesday, June 08, 2004 12:28 PM
   To: Matt Bazan
   Cc: [EMAIL PROTECTED]
   Subject: RE: named hash inside of hash
   
create a hash who's first key's value is an anon ref to a
   hash who's
second key's value is a non-anon hash..get my drift?  
 Is there an 
easier way to do this?  Thanks..
   
   I have no idea what you're saying... so here's a stab in the dark:
   
   my $data = {
this = {
  is =   {
nested = 'true'
  },
  isnt = {
nested = 'false'
  }
}
  };
   
   print $data-{this}-{is}-{nested}; #prints 'true'
   print $data-{this}-{isnt}-{nested}; #prints 'false'
   
   Does that help?
   
   'perldoc perldsc' may help too.
   
   
   
   -- 
   Mark Thomas[EMAIL PROTECTED] 
   Internet Systems Architect DigitalNet, Inc. 
   
   $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; 
   ;;print;;
 
   
   
   
  
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  
  
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: A little help with looping and LWP

2004-06-08 Thread Levner, David [JJCUS Non JJ]
Title: RE: A little help with looping and LWP





Jeremy,


I'm not sure how many levels deep you want to go, or whether you want to limit your
spider to certain domains, but the best way to write such code is with recursion. In
other words, put the code that fetches and parses a single page into a subroutine. The
subroutine should accept a URL as an argument, and it should call itself for each link
that it finds (or each that it finds that matches the criteria you devise). To limit
the depth of such a subroutine, you can pass a second argument to the subroutine which
is the depth (number of recursive calls) that have already been made. You should
increment the depth counter at the beginning of the subroutine.


You should also keep a global hash of the URLs you have already visited. That makes
it easy to prevent your code from looking at the same page again and again.


David Levner


-Original Message-
From: Jeremy Junginger [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 08, 2004 5:11 PM
To: Jeremy Junginger
Cc: [EMAIL PROTECTED]
Subject: RE: A little help with looping and LWP



Sorry. Here's the scripto...



-Original Message-
From: Jeremy Junginger 
Sent: Tuesday, June 08, 2004 1:59 PM
Cc: [EMAIL PROTECTED]
Subject: A little help with looping and LWP



Good afternoon. I'm playing with PERL for dummies, and have extended one of
the examples in the book (linkcheck.pl) to capture http codes and to
customize the user agent. I've got it divided into subroutines, but can't
quite understand how to loop them so they spider the site. I don't mean
indefinitely, but just grab the HTML a tags on the site, capture the http
links, and then grab the links on each of those sites. As you can see, I'm
storing the links in an array, and I was thinking about doing a foreach
(@checkurls) loop to accomplish it. Any tips would be greatly appreciated!


-Jeremy



___
Perl-Win32-Users mailing list [EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Need help with Tk

2004-06-08 Thread Daniel Peterson
Thanks for the help. I am not sure why I did not read that one in the docs.
I looked at it. Brain sleeps zzz

--
Dan


-Original Message-
From: lyndon rickards [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 08, 2004 5:34 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Need help with Tk



 I need to have a entry box that displays 3 or more lines.
 How do I do that?

 --
 Dan

Use a Text box. Instead of using a \$var to get the contents
though, as in Entry, you'll need $textwidget-get('0.0', 'end')

HTH - Lynn.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


PIX firewall Log generator

2004-06-08 Thread Kamal Ahmed
Hi,

Does anyone know of a perl script to generate PIX firewall logs ?

-Kamal
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs