Re: the only difference is the 'x' after '/g'

2006-03-30 Thread tom arnall
i need the blank in 'From [' etc in order to distinguish it from the strings with 'From:' one solution to the problem, btw, is to use '\s' instead of a literal blank. does this behavior rank as a bug in perl? tom arnall north spit, ca On Thursday 30 March 2006 05:15 am, Hans Meier (John Doe) w

Re: Counting specific elements in a XML object

2006-03-30 Thread Hans Meier (John Doe)
Bob Showalter am Donnerstag, 30. März 2006 23.32: > Chas Owens wrote: > > If we are going to pick nits then it should be > > > > grep -c "" fn > > Note that grep -c counts matching *lines*. There is no formal > requirement that these elements appear on separate lines. Dave, my first one-liner su

Re: store Array in hash ?

2006-03-30 Thread Mr. Shawn H. Corey
On Thu, 2006-30-03 at 13:23 -0800, John W. Krahn wrote: > Did you actually try that? > > $ perl -le'my $test{$setup}{opt} = q[OK]; print $test{$setup}{opt}' > syntax error at -e line 1, near "$test{" > Execution of -e aborted due to compilation errors. Oops. Make that: $test{$setup}{opt} = 'OK

Re: Counting specific elements in a XML object

2006-03-30 Thread Bob Showalter
Chas Owens wrote: If we are going to pick nits then it should be grep -c "" fn Note that grep -c counts matching *lines*. There is no formal requirement that these elements appear on separate lines. Here's a slightly more complex Perl one-liner that counts *occurences* perl -lne '$n++ f

Re: store Array in hash ?

2006-03-30 Thread John W. Krahn
Mr. Shawn H. Corey wrote: > On Wed, 2006-29-03 at 23:45 -0800, John W. Krahn wrote: >>Michael Gale wrote: >>>Hello, >>Hello, >> >>>I have setup a hash like the following: >>> >>>my $test; >>> >>>$test->{$setup}->{'opt'} = "OK"; >>Or: >> >>my $test = { $setup => { opt => 'OK' } }; > > Or: > m

Re: Counting specific elements in a XML object

2006-03-30 Thread Hans Meier (John Doe)
Chas Owens am Donnerstag, 30. März 2006 22.35: > > > cat fn | grep | wc [...] > > grep fn | wc [...] > If we are going to pick nits then it should be > > grep -c "" fn too much work. c "" fn But your alias may be different ;-) Hans -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

Re: Counting specific elements in a XML object

2006-03-30 Thread Chas Owens
On 3/30/06, Hans Meier (John Doe) <[EMAIL PROTECTED]> wrote: > Gavin Bowlby am Donnerstag, 30. März 2006 21.45: > > How about: > > > > cat fn | grep | wc > > When I posted a "cat | grep" the first (and last) time, several people got a > well known heart attack :-) > > grep fn | wc > > > as a non-

Re: Counting specific elements in a XML object

2006-03-30 Thread Hans Meier (John Doe)
Gavin Bowlby am Donnerstag, 30. März 2006 21.45: > How about: > > cat fn | grep | wc When I posted a "cat | grep" the first (and last) time, several people got a well known heart attack :-) grep fn | wc > as a non-Perl approach to the problem... [...] Agreed, but OT here ;-) Hans -- To uns

RE: Counting specific elements in a XML object

2006-03-30 Thread Gavin Bowlby
How about: cat fn | grep | wc as a non-Perl approach to the problem... -Original Message- From: Hans Meier (John Doe) [mailto:[EMAIL PROTECTED] Sent: Thursday, March 30, 2006 11:38 AM To: beginners@perl.org Subject: Re: Counting specific elements in a XML object Dave Adams am Donnerst

Re: Counting specific elements in a XML object

2006-03-30 Thread Hans Meier (John Doe)
Dave Adams am Donnerstag, 30. März 2006 21.12: > If I have a xml file like the following: > > > > John Doe > 43 > M > Recieving > > > Bob Gordon > 50 > M > Shipping > > > > Is there some perl module out there that can help me get

Counting specific elements in a XML object

2006-03-30 Thread Dave Adams
If I have a xml file like the following: John Doe 43 M Recieving Bob Gordon 50 M Shipping Is there some perl module out there that can help me get the number of employees or in other words, the number occurences of ""? I guess

Re: How to split a string read from the file?

2006-03-30 Thread Gerard Robin
I am off topic regarding your question about split, but with a one-liner like this perl does the work for you: perl -pi~ -e 's/^\d+ *: *//' file.txt hth -- Gérard -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Win32::GUI Question

2006-03-30 Thread Albert
Hello guys, I did create a program with a GUI. Now I use Win32::GUI::Dialog() to show the window. It works all fine. But now I want that it executes Win32::GUI::Dialog(), check if any events happend and then give control back to my program. So I could make a program like this: while(true) {

Re: store Array in hash ?

2006-03-30 Thread Mr. Shawn H. Corey
On Wed, 2006-29-03 at 23:45 -0800, John W. Krahn wrote: > Michael Gale wrote: > > Hello, > > Hello, > > > I have setup a hash like the following: > > > > my $test; > > > > $test->{$setup}->{'opt'} = "OK"; > > Or: > > my $test = { $setup => { opt => 'OK' } }; Or: my $test{$setup}{opt} =

Re: the only difference is the 'x' after '/g'

2006-03-30 Thread Hans Meier (John Doe)
tom arnall am Donnerstag, 30. März 2006 12.36: > the following code: > > my (@main); > $_=" > From a > From: b > From: c > From: d > "; > @main = /From [^\n]*?\n.*?(From: .*?\n).*?/gx; > print "@main"; > print "

the only difference is the 'x' after '/g'

2006-03-30 Thread tom arnall
the following code: my (@main); $_=" From a From: b From: c From: d "; @main = /From [^\n]*?\n.*?(From: .*?\n).*?/gx; print "@main"; print "--\n"; @main = /From [^\n]*?\n.*?(

RE: store Array in hash ?

2006-03-30 Thread Baskaran Sankaran
You can try this. $test->{$setup}->{'data'} = [$data[0], $data[1]]; As you said reference is not going to work, if your array value changes at run time. You can also access specific elements of the array individually, whenever required. Baskaran From: Mich