Re: RegExp equivalencies

2005-01-25 Thread Ing. Branislav Gerzo
Michael Kraus [MK], on Tuesday, January 25, 2005 at 15:44 (+1100) typed the following: MK> $item =~ /_(\d+)$/; MK> $id = $1; you could write this into one-line: ($id = $item) =~ s/.*_(\d+)$/$1/; -- ...m8s, cu l8r, Brano. [" " - [cloaked tagline]] -- To un

RE: unable to include .pm file

2005-01-25 Thread Mark Henry
Bob, thanks! Interesting.. the C file is there (but I couldn't get it to compile.) I though they were just 2 different methods of using the module (.pm or .c).. So is it a rule that all .pm files must have supporting compiled c code somewhere else? I will read the doc also, Thanks, I hope it w

RE: RegExp equivalencies

2005-01-25 Thread Thomas Bätzler
Michael Kraus <[EMAIL PROTECTED]> asked: > Is: > > my ($id) = $item =~ /_(\d+)$/; > > Equivalent to: > > $item =~ /_(\d+)$/; > $id = $1; Yes. It's especially useful when you've got more than one capture in your RE. > Wild Technology Pty Ltd , ABN 98 091 470 692 Sales - Ground [...] And that

Re: Logfile name

2005-01-25 Thread Jan Eden
Owen wrote on 25.01.2005: >On Mon, 24 Jan 2005 14:31:53 +0100 Jan Eden <[EMAIL PROTECTED]> >wrote: > >>Hi, >> >>I create monthly log files with names like statistics_01_2005.log. >>Now I have a function which returns the logfile name for the current >>month: [snip] >>In some cases I need the name

Re: perl script to binary executible

2005-01-25 Thread Octavian Rasnita
Hi, The programs made by IndigoStar or ActiveState don't compile the perl program into executables, but they create a .exe file that contains the perl program and the perl interpreter. This kind of programs usually unpack the files it contains into a temp folder and run the perl program from there

Re: Problems installing Text-Iconv-1.4

2005-01-25 Thread Chris Brown
Many thanks for taking the time to reply, I appreciate that. Should have mentioned my OS - it's Mandrake Linux 10.1. I only have one version of Perl installed (at least I have not installed another version apart from the one bundled with the OS). This is installed at /usr/lib/perl5/ I did a sear

Re: Problems installing Text-Iconv-1.4

2005-01-25 Thread mgoland
- Original Message - From: Chris Brown <[EMAIL PROTECTED]> Date: Tuesday, January 25, 2005 7:08 am Subject: Re: Problems installing Text-Iconv-1.4 > Many thanks for taking the time to reply, I appreciate that. NP Chriss, we are all a big happy family here. [ Perl Lovers :O) ] > > Shoul

"or die" question

2005-01-25 Thread Rod Jenkins
After a failed open, I want to run two statements for an "or die". Code Quesiton: open (TEST, ">/tmp/test") or { die "Could not open test file\n"; syslog("LOG_ALERT","Could not open test file"); }; This does not work, but what is the "right" way

Re: "or die" question

2005-01-25 Thread Prasanna Kothari
interchange may work. { syslog("LOG_ALERT","Could not open test file"); die " .."; } or look for help of "eval " Rod Jenkins wrote: After a failed open, I want to run two statements for an "or die". Code Quesiton: open (TEST, ">/tmp/test") or { die "Could not open test file

RE: "or die" question

2005-01-25 Thread Bob Showalter
Rod Jenkins wrote: > After a failed open, I want to run two statements for an "or die". > > Code Quesiton: > > open (TEST, ">/tmp/test") > or { > die "Could not open test file\n"; > syslog("LOG_ALERT","Could not open test file"); >}; > > This does no

RE: "or die" question

2005-01-25 Thread Thomas Bätzler
Hi, > After a failed open, I want to run two statements for an "or die". > > Code Quesiton: > > open (TEST, ">/tmp/test") > or { > die "Could not open test file\n"; > syslog("LOG_ALERT","Could not open test file"); >}; > > This does not work, but w

Re: "or die" question

2005-01-25 Thread Rod Jenkins
On Jan 25, 2005, at 8:33 AM, Bob Showalter wrote: Rod Jenkins wrote: After a failed open, I want to run two statements for an "or die". Code Quesiton: open (TEST, ">/tmp/test") or { die "Could not open test file\n"; syslog("LOG_ALERT","Could not open test fil

Re: "or die" question

2005-01-25 Thread Robert Boone
The "or " can call a subroutine. open (TEST, ">/tmp/test") or myDie(); sub myDie { syslog("LOG_ALERT","Could not open test file"); die "Could not open test file\n"; } On Tue, 2005-01-25 at 08:17 -0600, Rod Jenkins wrote: > After a failed open, I want to run two statements for

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
You have to stop spending so much time playing with all this bogus benchmarking :) It not bogus :) Its an example to find the best method for a project. If you prefer I'll ask the question I was trying to answer with the benchmark: Assuming you have an array of 0-15 elements is it quicker/more ef

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread mgoland
- Original Message - From: "JupiterHost.Net" <[EMAIL PROTECTED]> Date: Tuesday, January 25, 2005 11:01 am Subject: Re: hash slice/exists vs. grep benchmark weirdness... > > You have to stop spending so much time playing with all this bogus > > benchmarking :) > > It not bogus :) Its an

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
Just as an FYI, you don't need "exists" in your code at all. It is just a waste of time in your example. Should be beter writen as: print "hi" if $n{11}; What if it's value is 0, '', or undef? It would exist but your test would miss it :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additio

RE: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread Thomas Bätzler
[EMAIL PROTECTED] suggested: > Just as an FYI, you don't need "exists" in your code at all. > It is just a waste of time in your example. Should be beter writen as: > > print "hi" if $n{11}; Bad idea, if you consider this: $n{'oops'} = 0; print "hi" if $n{'oops'}; print "ho" if exists $n{'oop

RE: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread Bakken, Luke
> > You have to stop spending so much time playing with all this bogus > > benchmarking :) > > It not bogus :) Its an example to find the best method for a project. > > If you prefer I'll ask the question I was trying to answer with the > benchmark: > > Assuming you have an array of 0-15 elemen

hashes of arrays?

2005-01-25 Thread Mariano Cunietti
Hi, I'm trying to write a script to "invert" an alias database file. I mean, I want to generate a list where the key is the name of the user, and the value is the list of the aliases this user is involved into. Something like /etc/group file, as an example. I was wondering how could I use hashes

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread mgoland
- Original Message - From: "JupiterHost.Net" <[EMAIL PROTECTED]> Date: Tuesday, January 25, 2005 11:37 am Subject: Re: hash slice/exists vs. grep benchmark weirdness... > > > > > Just as an FYI, you don't need "exists" in your code at all. It > is just a waste of time in your example.

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread Lawrence Statton
> > You have to stop spending so much time playing with all this bogus > > benchmarking :) > > It not bogus :) Its an example to find the best method for a project. > And I'll reiterate more clearly. Benchmarking is *not* the tool to find the best method. The BEST method for a project is that

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
print "hi" if $n{11}; What if it's value is 0, '', or undef? It would exist but your test would miss it :) In that case "defined" would be a beter function to use. ok, but I'm still not interested in the value of the key I;'m interested inthe key, so why not exists since its made for hashes :)

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
Bakken, Luke wrote: You have to stop spending so much time playing with all this bogus benchmarking :) It not bogus :) Its an example to find the best method for a project. If you prefer I'll ask the question I was trying to answer with the benchmark: Assuming you have an array of 0-15 elements

RE: hashes of arrays?

2005-01-25 Thread Andrianoelison Joël
Hum, use hash like this : my %myhash; # you'd better declare it outside the while() foreach $destination (@dest_user) { if (/$destination/) { s/(\s+):*/defined($myhash{$destination})?$myhash{$destination}=$myhash{$dest ination}.",".$1:$myhash{$destination}=$1/e } } guess it'd work :-( not teste

Re: hashes of arrays?

2005-01-25 Thread Ankur Gupta
It is possible to store an array in a hash by using references #foreach $destination (@dest_users) { # NO NEED FOR THIS #print "==>$destination\n"; push( @{$aliases{$alias}}, @dest_users ); foreach $key ( keys %aliases ){ print "$key: @{$aliases{$key}}\n

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
Thanks for your input :) Finally, there were serious errors in your methodology in your Serious? I thought "in the Big Picture, it won't matter a gnats eyebrow." :) original benchmark. It turns out the printing dominated the total That is why I made both identical except for the difference I'm co

RE: Storing $DIGIT variables in arrays

2005-01-25 Thread Graeme St. Clair
I'm no expert on regex's, but IP @'s are not all that easy to match and validate at the same time. There is a good discussion of precisely this problem in Chap 4 of "Mastering Regular Expressions" by J E F Friedl, pub O'Reilly, at pp 123-125. He concludes:- "Sometimes it's better to take some o

SOLVED: hashes of arrays?

2005-01-25 Thread Mariano Cunietti
On Tue, 2005-01-25 at 18:55, Ankur Gupta wrote: > > Mariano Cunietti wrote: > > > #foreach $destination (@dest_users) { # NO NEED FOR THIS > > >#print "==>$destination\n"; > > > > > > push( @{$aliases{$alias}}, @dest_users ); > > > > > > foreach $key ( ke

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread Lawrence Statton
> Thanks for your input :) No problem -- I really do enjoy this. However, I do have some actual WORK that I need to do today :( > > Finally, there were serious errors in your methodology in your > > Serious? I thought "in the Big Picture, it won't matter a gnats eyebrow." :) And I stand by t

Re: "or die" question

2005-01-25 Thread John W. Krahn
Rod Jenkins wrote: After a failed open, I want to run two statements for an "or die". Code Quesiton: open (TEST, ">/tmp/test") or { die "Could not open test file\n"; syslog("LOG_ALERT","Could not open test file"); }; This does not work, but what is the "right" way to do

Re: How to find regex at specific location on line

2005-01-25 Thread renard
I am a newbie and have been following this thread since I am interested in benchmarking. So I copied the code and ran it on my machine. I have a 3.5 MHz system runing Windows XP. I am using ActivePerl 3.8.6. On my machine, benchmark complained about too few iterations. So I modified the script in t

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread John W. Krahn
JupiterHost.Net wrote: In benchmarking some code I've come across something I did not expect: slice: use strict; use warnings; my @k=qw(1 2 3 4 5 6); my %n;@[EMAIL PROTECTED] = @k; print "hi" if exists $n{1}; print "hi" if exists $n{3}; print "hi" if exists $n{5}; print "hi" if exists $n{7}; print

Re: How to go back to a line and do something with it in an input fil e?

2005-01-25 Thread mgoland
- Original Message - From: "Li, Aiguo (NIH/NCI)" <[EMAIL PROTECTED]> Date: Monday, January 24, 2005 5:14 pm Subject: How to go back to a line and do something with it in an input fil e? > hello, all. Hello Seems like there is a problem with your data, or problem is miss-read. See

Re: How to find regex at specific location on line

2005-01-25 Thread Jay
On Tue, 25 Jan 2005 14:39:42 -0500, renard <[EMAIL PROTECTED]> wrote: > I am a newbie and have been following this thread since I am interested in > benchmarking. > > So I copied the code and ran it on my machine. I have a 3.5 MHz system > runing Windows XP. I am using ActivePerl 3.8.6. > > On my

Re: perl script to binary executible

2005-01-25 Thread Jenda Krynicky
From: "Octavian Rasnita" <[EMAIL PROTECTED]> > The programs made by IndigoStar or ActiveState don't compile the perl > program into executables, but they create a .exe file that contains > the perl program and the perl interpreter. This kind of programs > usually unpack the files it contains into a

Re: perl script to binary executible

2005-01-25 Thread Randal L. Schwartz
> "Manas" == Manas Kulkarni <[EMAIL PROTECTED]> writes: Manas> I would like to convert my perl script into a binary executable before Manas> deploying it on a client machine 1) why? 2) have you read the FAQ entry on that? -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 5

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
#!/usr/bin/perl use warnings; use strict; use Benchmark 'cmpthese'; my @k = qw( 1 2 3 4 5 6 ); cmpthese( -10, { exists => sub { my $count = 0; my %hash; @hash{ @k } = (); for my $num ( 1, 3, 5, 7, 9, 11 ) { $count++ if exists $hash{ $num };

RE: Program to read data from serial port, filter and process

2005-01-25 Thread Charles K. Clarkson
Jason Balicki <[EMAIL PROTECTED]> wrote: : Some people emailed me privately and asked that I do post : what I've come up with to the list. : : I wrote this program over the course of the last week, : starting with very little perl experience (I've modified : others code, and small things like tha

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
> Lawrence Statton wrote: [snip] Gotcha, thx So then can you suggest a method of benchmarking these 2 methods that would be more accurate? I believe John's solution was excellent at illustrating th deficiencies in the way I was doing it and supplying a solution and answering my question all at

RE: Program to read data from serial port, filter and process

2005-01-25 Thread Jason Balicki
Charles K. Clarkson wrote: > As John already posted, you should be using warnings and > strict in your script. Below the first line (the shebang) > place these lines. This will break your script. You'll need > to ask some questions and read the documentation to get it

RE: Program to read data from serial port, filter and process

2005-01-25 Thread Charles K. Clarkson
Jason Balicki <[EMAIL PROTECTED]> wrote: : if you've got any helpful tips though... :) Coping with Scoping: http://perl.plover.com/FAQs/Namespaces.html Repost your script to the previous web link and I'll take another look on Thursday. HTH, Charles K. Clarkson -- Mobile Homes Specialist 2

search engine for beginners.perl.org

2005-01-25 Thread Vladimir Lemberg
Hi, Is there any way so search old posts via web? For example I want to ask some trivia question and I'm pretty sure that this question has been asked so many times. So before posting a new topic, I'd rather search the old ones regarding my problem. thanks in advance, Vladimir

Re: search engine for beginners.perl.org

2005-01-25 Thread Owen Cook
On Tue, 25 Jan 2005, Vladimir Lemberg wrote: > > Is there any way so search old posts via web? For example I want to ask some > trivia question and I'm pretty sure that this question has been asked so many > times. > So before posting a new topic, I'd rather search the old ones regarding my >

Re: tie DB_File flags

2005-01-25 Thread Jenda Krynicky
From: Ken Gillett <[EMAIL PROTECTED]> > Information about these has proved hard to come by, but having > ascertained what I need to use I find another problem. I want to > calculate the flags to use beforehand, but if I try > > tie %$dbm, "DB_File", $dbf, $dbflags, $mode, $DB_HASH; > > even tho