WG: Directory sizes

2010-05-05 Thread HACKER Nora
Hi, my ( $rc2, $backupsizetrans ) = rexec( $backuphost, 'du -k ' . $backupdir\/$backdir2 . ' |tail -1 |awk \'{ print $1 }\'' ); to get the size of

AW: Directory sizes

2010-05-05 Thread Thomas Bätzler
HACKER Nora nora.hac...@stgkk.at asked: Unfortunately, this does not explain the difference between the local du and the one via rexec on a remote machine. Any help appreciated. When you're getting different results then you're doing something differently ;-) For one thing, you're using just

Re: Array, foreach problem

2010-05-05 Thread Shlomi Fish
Hi Paul, a few comments on your code - so you'll know how to write Perl better. On Wednesday 05 May 2010 02:52:03 Paul Fontenot wrote: Hi, I'm stuck on using an array to determine the out come of a foreach loop. The script is below.

AW: Directory sizes

2010-05-05 Thread HACKER Nora
Hi Thomas, For one thing, you're using just du to call the binary, so we can't be sure you're calling the same du in each case. So, when logged in on the remote machine, do which du and use the resulting fully qualified path in your rexec call. Check, this is ok - locally an remotely

How to Decode UDP packets got from libpcap using Net::Pcap

2010-05-05 Thread perl
I have used libpcap to capture data using Net::Pcap module ... and now ... i have been stuck with decoding... here is the code that i have used http://cpansearch.perl.org/src/SAPER/Net-Pcap-0.16/eg/pcapdump #!/usr/bin/perl use strict; use Data::Hexdumper; use File::Basename; use Getopt::Long

Re: How to Decode UDP packets got from libpcap using Net::Pcap

2010-05-05 Thread Uri Guttman
please paste your code properly. this was wrapped to hell and back by something you did. it even looked like it was quoted from another email. make sure you do a clean cut/paste of your code in posts to this list. uri -- Uri Guttman -- u...@stemsystems.com

AW: How to Decode UDP packets got from libpcap using Net::Pcap

2010-05-05 Thread Thomas Bätzler
perl perlatw...@gmail.com asked: I have used libpcap to capture data using Net::Pcap module [...] This is an UDP DNS Query How can i Decode them ... Any one Please help me http://www.net-dns.org/docs/Net/DNS/Packet.html HTH, Thomas -- To unsubscribe, e-mail:

Re: Array, foreach problem

2010-05-05 Thread Brian
foreach $line (LOGFILE) { while (my $line = $logfile) would be a better idea than foreach $line. Just curious for an explanation to this. I tend to use foreach too. Don't they both accomplish the same thing? :) -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For

AW: Array, foreach problem

2010-05-05 Thread Thomas Bätzler
Brian fulls...@me.com asked: foreach $line (LOGFILE) { while (my $line = $logfile) would be a better idea than foreach $line. Just curious for an explanation to this. I tend to use foreach too. Don't they both accomplish the same thing? :) foreach (LOGFILE) means that the

Re: Array, foreach problem

2010-05-05 Thread Shawn H Corey
Brian wrote: foreach $line (LOGFILE) { while (my $line = $logfile) would be a better idea than foreach $line. Just curious for an explanation to this. I tend to use foreach too. Don't they both accomplish the same thing? :) Yes, but they go about it in different ways. The

Re: AW: Array, foreach problem

2010-05-05 Thread Shawn H Corey
Thomas Bätzler wrote: Brian fulls...@me.com asked: foreach $line (LOGFILE) { while (my $line = $logfile) would be a better idea than foreach $line. Just curious for an explanation to this. I tend to use foreach too. Don't they both accomplish the same thing? :) foreach (LOGFILE)

Re: about dispatch tables

2010-05-05 Thread Harry Putnam
Uri Guttman u...@stemsystems.com writes: HP The output from the script below: HP Shows 6 elements arrive in dispt($g, @ar) as @_. But when sub N(@_) HP is called, no variables arrive there. @_ is empty. When it seems like HP 5 elements should have arrived there well, it helps if

Re: Can we perform substitution to the matched pattern inside a regular expression so that the modified pattern gets returned instead of earlier matched one ?

2010-05-05 Thread Amit Saxena
On Fri, Apr 30, 2010 at 10:40 PM, C.DeRykus dery...@gmail.com wrote: On Apr 30, 3:55 am, learn.tech...@gmail.com (Amit Saxena) wrote: Hello everybody, Can we perform substitution to the matched pattern inside a regular expression so that the modified pattern gets returned instead of

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
On Wednesday 05 May 2010, Shlomi Fish wrote: 2. Don't use bareword filehandles - use lexical ones: open(my $output, , $output) or die Could not append to output - $!; Wouldn't there be any issues if we use same name for lexical filehandle and the scalar variable. Is Perl too intelligent to

AW: about dispatch tables

2010-05-05 Thread Thomas Bätzler
Harry Putnam rea...@newsguy.com asked: [...] which is also inside sub dispt {the sub function}. Where does global come in? Hint: $code-(@_); HTH, Thomas -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: about dispatch tables

2010-05-05 Thread Philip Potter
On 5 May 2010 14:36, Harry Putnam rea...@newsguy.com wrote: Uri Guttman u...@stemsystems.com writes:   HP The output from the script below:   HP Shows 6 elements arrive in dispt($g, @ar) as @_.  But when sub N(@_)   HP is called, no variables arrive there. @_ is empty. When it seems like  

Re: about dispatch tables

2010-05-05 Thread Philip Potter
On 5 May 2010 15:26, Thomas Bätzler t.baetz...@bringe.com wrote: Harry Putnam rea...@newsguy.com asked: [...] which is also inside sub dispt {the sub function}.  Where does global come in? Hint: $code-(@_); Or indeed $code; if you want to be cryptic :) Phil -- To unsubscribe, e-mail:

Re: Array, foreach problem

2010-05-05 Thread Shlomi Fish
On Wednesday 05 May 2010 17:20:25 Akhthar Parvez K wrote: On Wednesday 05 May 2010, Shlomi Fish wrote: 2. Don't use bareword filehandles - use lexical ones: open(my $output, , $output) or die Could not append to output - $!; Wouldn't there be any issues if we use same name for lexical

logic not being able to score last element in the array

2010-05-05 Thread iinfer
Hi, I'm new to perl but very enthusiastic about it. I'm having an issue with the following code. The task: two arrays one with a key key and one with responses from a form responses. The idea is that each value in the responses array will be compared to key; if the values match then a 1 or a 0

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
On Wednesday 05 May 2010, Shlomi Fish wrote: Wouldn't there be any issues if we use same name for lexical filehandle and the scalar variable. Is Perl too intelligent to recognize both of them? There certainly would be, and I don't think Perl is that intelligent to multiplex between the

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
On Wednesday 05 May 2010, Shawn H Corey wrote: Brian wrote: foreach $line (LOGFILE) { while (my $line = $logfile) would be a better idea than foreach $line. Just curious for an explanation to this. I tend to use foreach too. Don't they both accomplish the same thing? :)

Re: Array, foreach problem

2010-05-05 Thread Rob Coops
On Wed, May 5, 2010 at 10:18 AM, Shlomi Fish shlo...@iglu.org.il wrote: Hi Paul, a few comments on your code - so you'll know how to write Perl better. On Wednesday 05 May 2010 02:52:03 Paul Fontenot wrote: Hi, I'm stuck on using an array to determine the out come of a foreach loop.

Re: about dispatch tables

2010-05-05 Thread Harry Putnam
Philip Potter philip.g.pot...@gmail.com writes: On 5 May 2010 14:36, Harry Putnam rea...@newsguy.com wrote: Uri Guttman u...@stemsystems.com writes:   HP The output from the script below:   HP Shows 6 elements arrive in dispt($g, @ar) as @_.  But when sub N(@_)   HP is called, no variables

Re: AW: about dispatch tables

2010-05-05 Thread Harry Putnam
Thomas Bätzler t.baetz...@bringe.com writes: Harry Putnam rea...@newsguy.com asked: [...] which is also inside sub dispt {the sub function}. Where does global come in? Hint: $code-(@_); Yes, I knew it could be done there... but what to do then when more function calls are added. Are you

Re: Array, foreach problem

2010-05-05 Thread John W. Krahn
Akhthar Parvez K wrote: On Wednesday 05 May 2010, Shawn H Corey wrote: Brian wrote: foreach $line (LOGFILE) { while (my $line = $logfile) would be a better idea than foreach $line. Just curious for an explanation to this. I tend to use foreach too. Don't they both accomplish the

Re: about dispatch tables

2010-05-05 Thread Philip Potter
On 5 May 2010 17:29, Harry Putnam rea...@newsguy.com wrote: Anyway, I understood he was saying NOT global. What I asked is why that would matter.  That is, the values or elements in @_ arrive inside the `sub dispt {...}', so should be available to anything inside `sub dispt {...}'  right?

Re: logic not being able to score last element in the array

2010-05-05 Thread Robert Wohlfarth
On Tue, May 4, 2010 at 8:39 PM, iinfer tbon...@gmail.com wrote: # OPEN THE KEY my @key=(); my @score_key=(); sub key{ my $inFile = 'key.csv'; open(IN, $inFile) or die open $inFile: $!; @key=split(',',IN); @score_key=shift(@key); return @key; } Is it possible that the

Re: about dispatch tables

2010-05-05 Thread Harry Putnam
Uri Guttman u...@stemsystems.com writes: HP == Harry Putnam rea...@newsguy.com writes: HP A third sub function is called in the dispatch table ( N(@_); ) but HP the variables don't survive to be use there. there are no variables to survive in a sub, just passed arguments in @_ HP

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
On Wednesday 05 May 2010, Rob Coops wrote: Would it not be more efficient to reset the file handle to the star of the file? use strict; use warnings; use Fcntl qw(:seek); ... foreach my $condition (@conditions) {  seek ( $fh, 0, 0 ) or die ERROR: Could not reset file handle\n;  while

Re: logic not being able to score last element in the array

2010-05-05 Thread John W. Krahn
iinfer wrote: Hi, Hello, I'm new to perl but very enthusiastic about it. I'm having an issue with the following code. The task: two arrays one with a key key and one with responses from a form responses. The idea is that each value in the responses array will be compared to key; if the

Re: Array, foreach problem

2010-05-05 Thread Rob Coops
On Wed, May 5, 2010 at 7:21 PM, Akhthar Parvez K akht...@sysadminguide.comwrote: On Wednesday 05 May 2010, Rob Coops wrote: Would it not be more efficient to reset the file handle to the star of the file? use strict; use warnings; use Fcntl qw(:seek); ... foreach my $condition

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
On Wednesday 05 May 2010, Rob Coops wrote: A file never starts life being huge but certainly logs tend to grow, and they are not always kept in check properly so assume they will be massive (I've seen flat text logs that grew by as much as +1GB per day) assuming that the file will always be

Re: Array, foreach problem

2010-05-05 Thread Rob Coops
On Wed, May 5, 2010 at 8:50 PM, Akhthar Parvez K akht...@sysadminguide.comwrote: On Wednesday 05 May 2010, Rob Coops wrote: A file never starts life being huge but certainly logs tend to grow, and they are not always kept in check properly so assume they will be massive (I've seen flat

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
On Wednesday 05 May 2010, John W. Krahn wrote: If I could explain this further for Perl beginners: With that foreach statement, it reads the file first and creates an array with each line as elements and that array is being looped so the overhead is higher, whereas with that while

Re: Array, foreach problem

2010-05-05 Thread Uri Guttman
APK == Akhthar Parvez K akht...@sysadminguide.com writes: APK Thanks for the explanation John. Could you give one or two real APK time examples where you used a list (instead of an array) except APK in loops such as: for ('a', 'b', 'c', 'd')? I wonder if I'm APK underusing lists in my

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
On Thursday 06 May 2010, Rob Coops wrote: Of course and a system like nagios does exactly that, it reports errors and positives, mail is of course not the way right to deal with monitoring certainly in large environments it is simply not done via mail. Currently looking at the monitoring

Re: Teaching Perl

2010-05-05 Thread Randal L. Schwartz
Shlomi == Shlomi Fish shlo...@iglu.org.il writes: Shlomi Why do you need a version with a function that is specifically Shlomi called doors? What will this doors function do? Generally Shlomi functions and methods should be called according to verbs and Shlomi actions - not according to nouns.

Re: Teaching Perl

2010-05-05 Thread Robert H
On 5/5/10 6:12 PM, in article 861vdqhuat@red.stonehenge.com, Randal L. Schwartz mer...@stonehenge.com wrote: Shlomi == Shlomi Fish shlo...@iglu.org.il writes: Shlomi Why do you need a version with a function that is specifically Shlomi called doors? What will this doors function do?