Counting keys in an array of hashes?

2008-02-20 Thread jamesdon
I am reading in a file, building an array of information that I need to evaluate: while () { if ($_ =~ m/stuff/) { push(@data, {'vlan' => $vlan, 'host' => $host, 'mac' => $mac, 'port' => $port}); } } Small sample of @data: vlan hostmacport 13 switch-1

Re: Problem with spaces in paths

2008-02-20 Thread John W. Krahn
jshock wrote: I have written a simple script that uses rsync to backup directories to a USB drive. The directories are selected from an array. The problem I am having is that if the directory has a space in it, the script breaks. I have tried putting backslashed in front of the spaces, and encas

Re: Problem Building Module

2008-02-20 Thread sisyphus
On Feb 19, 11:45 pm, [EMAIL PROTECTED] (David Blundell) wrote: > Hi All, > > I am trying to build Encode-Detect (I am using Solaris Express 1/08,   > Sunfreeware perl 5.8.8 and > Sunfreeware gcc 3.4.6). > > When I run make I get the following error: > > In file included from /usr/local/lib/perl5/5.

Problem with spaces in paths

2008-02-20 Thread jshock
I have written a simple script that uses rsync to backup directories to a USB drive. The directories are selected from an array. The problem I am having is that if the directory has a space in it, the script breaks. I have tried putting backslashed in front of the spaces, and encasing the entire p

Re: Counting keys in an array of hashes?

2008-02-20 Thread John W. Krahn
[EMAIL PROTECTED] wrote: I am reading in a file, building an array of information that I need to evaluate: while () { if ($_ =~ m/stuff/) { push(@data, {'vlan' => $vlan, 'host' => $host, 'mac' => $mac, 'port' => $port}); } } Small sample of @data: vlan hostmac

Re: Printing text between two blank lines

2008-02-20 Thread obdulio santana
I offer you, a tiny version , @ll=split /^\s*\n/m,join '',; print for @ll[1 .. $#ll - 1] ; __END__ pri dfsdfsa dfasdf asdf first second last ass sad sas d Maybe this helps somebody. Thaks Perl's folks.

Re: JendaRex and Perl 5.10

2008-02-20 Thread Jenda Krynicky
From: axtens <[EMAIL PROTECTED]> > G'day everyone > > I've been trying unsuccessfully to re-compile JendaRex.pm, using the > latest PDK (7.1) and the latest Perl (5.10). > > Everything seems to compile okay, whether I use PerlCtrl as is, or > with Jenda's own PDKcompile, and the

Re: Counting keys in an array of hashes?

2008-02-20 Thread Chas. Owens
On Feb 19, 2008 11:12 PM, <[EMAIL PROTECTED]> wrote: > I am reading in a file, building an array of information that I need > to evaluate: > > while () { > if ($_ =~ m/stuff/) { > push(@data, {'vlan' => $vlan, 'host' => $host, 'mac' => $mac, 'port' > => $port}); > } > } > > Small sample of @da

Re: Problem with spaces in paths

2008-02-20 Thread Gunnar Hjalmarsson
jshock wrote: @source = qw( "/Users/joe/Documents/Palm/" "/Users/joe/Library/Application\ Support/AddressBook" "/Users/joe/Library/Application\ Support/iCal" "/Users/joe/Library/Mail" ); That code does probably not do what you want. Besides the space problem, t

Re: Printing text between two blank lines

2008-02-20 Thread Gunnar Hjalmarsson
obdulio santana wrote: I offer you, a tiny version , @ll=split /^\s*\n/m,join '',; print for @ll[1 .. $#ll - 1] ; That code does not meet the OP's specification. Please consider a file whose data looks like this: pri dfsdfsa first asdf asdf asdf second last ass sad -- Gunnar Hjalmar

ordering data in a table!

2008-02-20 Thread Pat Rice
Hi all I'm using htm templates to display this data, but what I would like to be able to sort the infromation, by clicking on the title of the header on the coloum. eg to sort by CPU. is there any easy!! way of doing this ? as in a inbult way of doing this sorting by clicking on the link. eg Mas

Re: Printing text between two blank lines

2008-02-20 Thread obdulio santana
2008/2/20, Gunnar Hjalmarsson <[EMAIL PROTECTED]>: > > obdulio santana wrote: > > I offer you, a tiny version , > > > > @ll=split /^\s*\n/m,join '',; > > print for @ll[1 .. $#ll - 1] ; > > > > That code does not meet the OP's specification. Please consider a file > whose data looks like this: > >

Re: ordering data in a table!

2008-02-20 Thread yitzle
You can use Perl's sort to sort the data in Perl and regenerate the table. Or you can use some Javascript table widget. Try Googling for "Javascript table" or "Javascript table sort". Some hits I found: http://www.joostdevalk.nl/code/sortable-table/ http://www.workingwith.me.uk/articles/scripting/s

Saving attachment

2008-02-20 Thread Tony Marquis
I need to save attachment received by email with a specific subject. My email server support IMAP and POP3... I tried with Net::IMAP:Simple, Email::Simple, but i can't find a way to strip the attachment from the message and save it somewhere. Which module i should use for this kind of applicat

Re: GUI Toolkit - which one to learn? (GTK/GTK2/Tk)

2008-02-20 Thread yitzle
I don't know... maybe I /was/ looking at the C code. The code Chas provided does look fairly similar to the Tk code. Thanks for the replies. I guess I'll be using GTK2 after all :D -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.or

Re: GUI Toolkit - which one to learn? (GTK/GTK2/Tk)

2008-02-20 Thread Francisco Valladolid
Hi, it depends that you particular needs. Example Tk is portable but primitive, the look and feel is good on Gtk2. Gtk2 is also portable, in both Unix/Windows/ . Sometimes you must try severals toolkits libraries to do this task, and the last word always is your. Regards. On Feb 21, 2008 1:2

Re: Printing text between two blank lines

2008-02-20 Thread Gunnar Hjalmarsson
obdulio santana wrote: Please let me know if everything is Ok. @l = ; @nl = map /^\s*\n/?1:0,@l; map { print $l[$_] if ("$nl[$_ - 1]$nl[$_]$nl[$_ + 1]" eq "101" ) } (0 .. $#nl); 1. It's no longer a tiny version. ;-) 2. It generates a warning. Aren't you using strictures and warnings?? 3. I'd u

Suppressing output from backtick operator

2008-02-20 Thread Joseph L. Casale
How does one do this? I have the output in a script set to a variable such as: my $var = `cmd --arg1 --arg2 | egrep 'This|That'` and I don't want to see it as the script is run. Thank you, jlc -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://

Re: Suppressing output from backtick operator

2008-02-20 Thread Chas. Owens
On Wed, Feb 20, 2008 at 5:18 PM, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > How does one do this? I have the output in a script set to a variable such as: > my $var = `cmd --arg1 --arg2 | egrep 'This|That'` and I don't want to see it > as the script is run. snip Supressing output on STDERR fr

Re: Suppressing output from backtick operator

2008-02-20 Thread yitzle
On both Windows and Unix, there are two output streams, STDOUT and STDERR. The backtick operator captures the STDOUT and lets you use it eg to set $var. STDERR is what you are seeing. (Perl's warn prints to STDERR) What you can do (on Linux machine) is redirect the STDERR to null. I don't think egr

Re: Suppressing output from backtick operator

2008-02-20 Thread Chas. Owens
On Wed, Feb 20, 2008 at 5:42 PM, Chas. Owens <[EMAIL PROTECTED]> wrote: snip > This code also benefits from the fact that it only spawns on process snip That should be "one process" not "on process". It is important, and I forgot to add this, to use waitpid* to reap the child process after an op

RE: Suppressing output from backtick operator

2008-02-20 Thread Joseph L. Casale
> That should be "one process" not "on process". It is important, and I > forgot to add this, to use waitpid* to reap the child process after an > open3 unless you don't mind zombies. > > * http://perldoc.perl.org/functions/waitpid.html Thank you Chas and yitzle jlc -- To unsubscribe, e-mail: [

Re: Suppressing output from backtick operator

2008-02-20 Thread yitzle
Suggestion: rather than use egrep (which, as Chas points out, requires a new process - and ignoring his solution for a moment - sorry), it might make more sense (and increase portability) to move the RegEx parsing into Perl. my $var = grep {/This|That/}, `cmd --arg1 --arg2; (Did I do this right? I

Re: Suppressing output from backtick operator

2008-02-20 Thread Chas. Owens
On Wed, Feb 20, 2008 at 5:50 PM, yitzle <[EMAIL PROTECTED]> wrote: snip > my $var = grep {/This|That/}, `cmd --arg1 --arg2; > (Did I do this right? I'm not very familiar with grep) snip That is mostly correct. You are using the grep function in scalar context, so it will return the number of it

RE: Suppressing output from backtick operator

2008-02-20 Thread Joseph L. Casale
> Suggestion: rather than use egrep (which, as Chas points out, requires > a new process - and ignoring his solution for a moment - sorry), it > might make more sense (and increase portability) to move the RegEx > parsing into Perl. > > my $var = grep {/This|That/}, `cmd --arg1 --arg2; > (Did I do

Re: Printing text between two blank lines

2008-02-20 Thread John W. Krahn
Gunnar Hjalmarsson wrote: obdulio santana wrote: Please let me know if everything is Ok. @l = ; @nl = map /^\s*\n/?1:0,@l; map { print $l[$_] if ("$nl[$_ - 1]$nl[$_]$nl[$_ + 1]" eq "101" ) } (0 .. $#nl); 1. It's no longer a tiny version. ;-) 2. It generates a warning. Aren't you using strictu

address translation

2008-02-20 Thread J. Peng
how to translate this mask to clear text form with perl? netmask 0x thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: address translation

2008-02-20 Thread John W. Krahn
J. Peng wrote: how to translate this mask to clear text form with perl? netmask 0x If you mean an IP address netmask then 0x is an invalid netmask because all the bits are 1. John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of

Re: address translation

2008-02-20 Thread J. Peng
On Thu, Feb 21, 2008 at 3:29 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: > J. Peng wrote: > > how to translate this mask to clear text form with perl? > > netmask 0x > > If you mean an IP address netmask then 0x is an invalid netmask > because all the bits are 1. > John, all

Re: GUI Toolkit - which one to learn? (GTK/GTK2/Tk)

2008-02-20 Thread Octavian Rasnita
From: "zentara" <[EMAIL PROTECTED]> On Tue, 19 Feb 2008 22:36:09 -0500, [EMAIL PROTECTED] (yitzle) wrote: Hi I decided throwing a GUI on Perl would be fun so I want to make a Connect Four. Which GUI module would you advise? It seems the major contenders are GTK, GTK2/GTK+ and Tk. Tk seems to