[10660] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4252 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 19 01:07:22 1998

Date: Wed, 18 Nov 98 22:00:19 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 18 Nov 1998     Volume: 8 Number: 4252

Today's topics:
    Re: Are there no PERL experts out there... (Troy Denkinger)
    Re: Bareword? (David Formosa)
    Re: Dynalib - make problems on Activeperl (Randy Kobes)
        File handles to a variable <toto@javanet.com>
        Help -- Shellsort with perl <dales@enhanced-performance.com>
    Re: Help -- Shellsort with perl (Sam Holden)
        Help with DBI and DBD? (CMSC 424)
        How to parse a <SELECT ... MULTIPLE> list in script usi <proband@cam.org>
        inconsistent quoted expressions ? <tliu@stanford.edu>
    Re: Intermediate Perl questions (Ronald J Kimball)
        make ref to copy of data <xah@best.com>
        Perl Experts Needed rohan666@my-dejanews.com
    Re: Perl para windows 95 (Larry Rosler)
    Re: Perl Usage Survey - interpretations, anyone? <erik@cthulhu.demon.nl>
    Re: Please Help! reg expression <due@murray.fordham.edu>
    Re: Please Help! reg expression (Martien Verbruggen)
    Re: reverse comma operator in the camel (Ronald J Kimball)
        sendmail flags (TheEadsNet)
    Re: Sounds easy when I type it fast (Ronald J Kimball)
        strange SEGV with sort or some sort of such thing leroy@mpi.com
    Re: Two-Part RE question (Martien Verbruggen)
    Re: Two-Part RE question (Ronald J Kimball)
        Win16 DLL access (on NT) Help!!! <abramoa@leland.stanford.edu>
    Re: Win32 executing a .pl or .cgi mobetta1231@my-dejanews.com
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 19 Nov 1998 04:30:01 GMT
From: troy@whadda.com (Troy Denkinger)
Subject: Re: Are there no PERL experts out there...
Message-Id: <7306oh$dnr$1@hirame.wwa.com>

In article <3652F1F0.4D8F4054@sni.net>, grifftoe@sni.net wrote:
>> Rafely@xxiname.com wrote:
>> 
>> > Hello,
>> >
>> > I'm making a form so users can send me information.
>> > The also have to send me their name. How do I check
>> > and see if the name only consists of letters and white
>> > spaces?? So "My Name" is allowed but "Jj&*d d#fdhd"
>> > is not allowed!!! I want to send a message saying that
>> > the name was invalid! But how do I check and see if
>> > the name is valid?
>
>I prefer to check FORM input fields with javascript, I'll
>see if Joe's suggestion can be implemented on a FORM I check
>for a non-blank name field
>(http://www.mcalvany.com/inquiry.html)

However, the javascript won't validate if

a) the browser doesn't implement javascript.

b) the user doesn't use your form, but rather uses their own form to shoot 
data to your program or maybe just stuffs data directly to your program.

If you're going to care about the input, which you should, the program should 
validate on it's own.

Regards,

Troy Denkinger


------------------------------

Date: 19 Nov 1998 03:37:34 GMT
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: Bareword?
Message-Id: <slrn7574ju.9hb.dformosa@godzilla.zeta.org.au>

In article <72vnmf$1uu$1@nnrp1.dejanews.com>, bigcheese@my-dejanews.com wrote:
>What is a Bareword?

A bareword is a word that dosn't have any $ % & or quotes about it.

>
>"Bareword found where operator expected at line 39"
>
>line 39:
>			if ($hd eq "1") {
>				$base = "<IMG SRC=k/k1/";

Nothing seems wrong with this line.  Possably you have got your quoting 
wrong  some where.  BTW do you realy need eq there, wouldn't == do?


-- 
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.



------------------------------

Date: 19 Nov 1998 05:02:09 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: Dynalib - make problems on Activeperl
Message-Id: <slrn757a3d.bb7.randy@theory.uwinnipeg.ca>

On Wed, 18 Nov 1998 18:02:53 GMT, S
	ridhar Krishnaswamy <sridhar.krishnaswamy@mci.com> wrote:
>When I try to run "perl Makefile.PL" - I get the following error. It seems
>to be building a "testtest.c" file and is unable to find windows.h include
>file. I am running Activeperl - release  version 5.005_02 built for
>MSWin32-x86-object.
>
>Here is output from makemaker.
>
>------------------------------
>testtest.c
>D:\perl\lib\CORE\win32.h(57) : fatal error C1083: Cannot open include file:
>'windows.h': No such file or directory

[snip]

Hi,
   It looks like the include path for VC++ isn't being found - eg,
C:\Program Files\Microsoft Visual Studio\VC98\Include. You'd also
have similar problems later with the path to your libraries. Look in
your perl's Config.pm file, and change the values of incpath and 
libpth, respectively. This is necessary because the ActiveState binary 
has no idea where these files may have been placed on your system.

>
>Since makemaker seemed to run to completion, I tried to continue and run
>"nmake" on the Makefile. I get the follow error from xsubpp.
>
>----------------------------
>Microsoft (R) Program Maintenance Utility   Version 1.62.7022
>Copyright (C) Microsoft Corp 1988-1997. All rights reserved.
>
>Too many parameters - &&
>        D:\PERL\BIN\PERL.EXE -ID:\perl\lib -ID:\perl\lib
>D:\perl\lib\ExtUtils/xs
>ubpp  -typemap D:\perl\lib\ExtUtils\typemap DynaLib.xs >DynaLib.tc &&
>D:\PERL\BI
>N\PERL.EXE -ID:\perl\lib -ID:\perl\lib -MExtUtils::Command -e mv DynaLib.tc
>DynaLib.c
>Usage: xsubpp [-v] [-C++] [-except] [-prototypes] [-noversioncheck]
>[-nolinenumb
>ers] [-s pattern] [-typemap typemap]... file.xs
>NMAKE : fatal error U1077: 'D:\PERL\BIN\PERL.exe' : return code '0xff'
>Stop.
>----------------------------------

This is a problem with the redirection used in
	command_1 > file && command_2
with command_2 being interpreted as an argument to command_1.
To get past this point, you can manually give the commands on
either side of the &&:
	command_1 > file
	command_2
If you want to change this permanently, edit the file 
 ...\ExtUtils\MM_Unix.pm, and look for the subs xs_c and xs_o,
and make the equivalent changes in these to split the commands
on either side of the &&.

-- 
		Best regards,
		Randy Kobes

Physics Department		Phone: 	   (204) 786-9399
University of Winnipeg		Fax: 	   (204) 774-4134
Winnipeg, Manitoba R3B 2E9	e-mail:	   randy@theory.uwinnipeg.ca
Canada				http://theory.uwinnipeg.ca/


------------------------------

Date: Tue, 17 Nov 1998 14:32:20 -0500
From: "Josh Feinblum" <toto@javanet.com>
Subject: File handles to a variable
Message-Id: <7307fv$67b$1@as4100c.javanet.com>

I asked a question earlier about a writing a filehandle to a variable.

The response was to use the module IO::Scalar.  This worked, but had an
undesired side effect.

Part of the difficulty is that some of the print statements need to go to a
file.  Is there anyway to re-direct a specific filehandle to a variable?
>From my research I beleive that on solution would be sprintf but I can't
seem to get it to work right.

Thanks in advance
Josh





------------------------------

Date: Wed, 18 Nov 1998 21:36:09 -0800
From: Dale Sutcliffe <dales@enhanced-performance.com>
Subject: Help -- Shellsort with perl
Message-Id: <3653AE48.3E16492A@enhanced-performance.com>

Shellsort with perl seems to lock up my server, any ideas why?

for ($gap = $size/2; $gap > 0; $gap = $gap/2)
{
    for ($i = $gap; $i < size; $i = $i + 1)
    {
       for ($j = ($i - $gap); $j > -1; $j = ($j - $gap))
       {
        }
    }
}

Thanks,
    Dale



------------------------------

Date: 19 Nov 1998 05:45:25 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Help -- Shellsort with perl
Message-Id: <slrn757c3l.94n.sholden@pgrad.cs.usyd.edu.au>

On Wed, 18 Nov 1998 21:36:09 -0800, Dale Sutcliffe
	<dales@enhanced-performance.com> wrote:
>Shellsort with perl seems to lock up my server, any ideas why?

Have you considered printing out the values of the variables in the
inner loop and seeing what is happening...

You do realise that perl variables are not integers (unless you force
them to be with use integer) so that $gap/2 might take a long time to
become 0

$gap=10;
while($gap>0)
{
        $gap=$gap/2;
        $count++;
}
print $count;

for example prints 1078 for me.

Your examaple with $size=0 will take a _really_ large number of loops to
complete...

>
>for ($gap = $size/2; $gap > 0; $gap = $gap/2)
>{
>    for ($i = $gap; $i < size; $i = $i + 1)
>    {
>       for ($j = ($i - $gap); $j > -1; $j = ($j - $gap))
>       {
>        }
>    }
>}


-- 
Sam

People get annoyed when you try to debug them.
	--Larry Wall


------------------------------

Date: 19 Nov 1998 04:51:27 GMT
From: nr42412@csc.umd.edu (CMSC 424)
Subject: Help with DBI and DBD?
Message-Id: <73084f$eph$1@hecate.umd.edu>

I'm having trouble installing DBI and DBD.
I don't have root access and I don't have a large quota.

Inside the DBI directory I did:
perl Makefile.pl PREFIX=my_local_directory

Then I do:
make perl

and I install the new perl.
Then I run:
make
make test
make install

Then when I go out to the DBD directory and do:
myperl Makefile.PL PREFIX=my_local_directory
where myperl is the one I just made.
I immediately get an error message saying that 1.02 object files
are different than the .90 definition in the root user's directory
/usr/local/lib/perl5/site_perl/Oraperl.pm

Could you e-mail me at nr42412@marple.umd.edu in addition to this
newsgroup? thanks! any help is appreciated.

 .



------------------------------

Date: Wed, 18 Nov 1998 21:12:02 -0500
From: Sylvain Lavigne <proband@cam.org>
Subject: How to parse a <SELECT ... MULTIPLE> list in script using a foreach loop?
Message-Id: <36537E72.FB61C5DF@cam.org>

I have a form with list with multiple items that can be selected.
In my script I refer to the variable as $form('ITEMS').
How can I parse that list using a foreach loop?

foreach ....
{
   print " ... \n";

}

THANK





------------------------------

Date: Wed, 18 Nov 1998 18:38:53 -0800
From: "tommy" <tliu@stanford.edu>
Subject: inconsistent quoted expressions ?
Message-Id: <7300jr$3ij$1@nntp.Stanford.EDU>

Hi,
First a bit about the environment:
I'm running Sambar server, on an NT box, and using Active state perl
5.00502.
The following statements is embedded in a multiple part form perl program:

my $perl_binary = 'perl';
my $distance_program = 'distance_matrix_fastest.pl';
my $graph_program = 'distance_graph_final.pl';
 ....
    print '<p>',
$argQ->radio_group(-name=>'algorithm',-values=>['uncorrected','jukes-cantor'
,
    'kimura-2 parameter','nei-gojobori','simple
synonymous-non-synonymous']);
 .....
    $outputfile = 'matrixfile.out';
 .....
    my $method = $argQ->radio_group(-name=>'algorithm');
 .....
    $output = qx/ $perl_binary -d $distance_program $inputfile $outputfile
$method /;
    print $output;  <---------------- this doesn't work

    $output = qx/ $perl_binary -d $graph_program /;
    print $output;  <----------------- while this does
 .

I have actually printed the variables in the statement and tried it in the
command-line and they work fine.

I am using the debugger (-d) to let me know which program it's running.  I
do not get the debugger screen for the first $output, the program skips it
and I get the second one instead.

Does anyone know what is wrong with this code or how to get more insight
into the problem?

Thanks,
Tommy






------------------------------

Date: Wed, 18 Nov 1998 21:59:24 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Intermediate Perl questions
Message-Id: <1dipm27.1cezodhfkvy2oN@bay2-312.quincy.ziplink.net>

Markus Kaiser <m.kaiser@sz-sb.de> wrote:

> BTW, is '$text eq "\x11"' the same as '$text == 0x11'?

No.  The first does a string comparison against the character ^Q.  The
second does a numeric comparison against the number 17.

In the second case, the value of $text will be converted to a number.
Unlike in C, the number will not be the character's ASCII value.
Instead, the conversion will be done along the lines of the
atoi()/atof() functions.  (In concept, not necessarily in
implementation.)

Thus, if you do:

$text = "\cQ";

Then:

$text eq "\x11"

is true, but

$text == 0x11

is false, because the numeric value of "\cQ" is zero.

If you did this instead:

$text = 17;

then the results would be reversed.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: Wed, 18 Nov 1998 18:38:19 -0800
From: "Xah" <xah@best.com>
Subject: make ref to copy of data
Message-Id: <365384a1$0$12760@nntp1.ba.best.com>

I want to make a reference to a copy of a data. What is the idiomatic way?

Here's what I do now
 &{sub {my @aa = @{$_[0]}; return \@aa;}}($ref_data)

example:

#!/usr/local/bin/perl5 -w
use strict;
use Data::Dumper; $Data::Dumper::Indent=0;

my $ref_data = [9,3,48];
my $ref_dataCopy = &{sub {my @aa = @{$_[0]}; return \@aa;}}($ref_data);
pop(@$ref_dataCopy);
print Dumper $ref_data;
print Dumper $ref_dataCopy;

__END__

Thanks in advance.

 Xah, xah@best.com
 http://www.best.com/~xah/PageTwo_dir/more.html
 Petty penguins make way: GNU HURD is coming! <www.gnu.org>


------------------------------

Date: Thu, 19 Nov 1998 01:46:34 GMT
From: rohan666@my-dejanews.com
Subject: Perl Experts Needed
Message-Id: <72vt9n$6p7$1@nnrp1.dejanews.com>

I have a problem.... I need to GET users input from a shopping cart web site
done in JavaScript, and take their selection to another domain where a secure
server can process the order. (JScript will NOT allow cookies to be
transmitted off the original domain.) I am working on a Perl Script that can
redirect those selected items to another domain, but I have no clue how to
correctly code the PerlScript on grabbing variables from a JavaScript.
AAARRRGGGHHH!!! If you think you have a plan of action, pleeezz let me
know... You can see the site in question at
http://www.wholesalerestaurant.com Just view source to see the scripts.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Wed, 18 Nov 1998 17:53:44 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl para windows 95
Message-Id: <MPG.10bd1a026c4ef983989914@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <72vrg2$ii8$1@srv4-poa.nutecnet.com.br> on Wed, 18 Nov 1998 
23:25:47 -0200, Josi Carlos Jeske <zejeske@zaz.com.br> says...
> Onde posso conseguir perl para windows 95

Em <URL:http://www.activestate.com/>.  Para nenhum custo.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Thu, 19 Nov 1998 00:18:24 -0500
From: Erik van Roode <erik@cthulhu.demon.nl>
Subject: Re: Perl Usage Survey - interpretations, anyone?
Message-Id: <3653AA20.AA7CF1D@cthulhu.demon.nl>

John Porter wrote:
> 
> Adam Turoff wrote:
> >
> > I may not be well read in anthropology, but I've never read of a case
> > where neanderthals devolved into 'homo microsofticus'.  That would lead
> > me to believe that our fur-clad relatives were more intelligent than
> > your average ntadmin, teenage boy or otherwise.
> 
> Actually, there seems to be some speculation among anthropologists
> lately that the neanderthals may have indeed been more intelligent
> than the sapiens who displaced them.  Wish I had a link or two for you...

Perhaps this link is useful ?

- Missing Link - The Journal of Topical Anthropology 
  http://lead.csustan.edu/anthro/missing.html


------------------------------

Date: 19 Nov 1998 02:15:42 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: Please Help! reg expression
Message-Id: <72vv0e$3b2$0@206.165.167.236>

David Wee wrote in message <72vrp8$1rl$1@agate.berkeley.edu>...
>if i am using a backreference from a previous reg exp ($2 for instance)
>to match a new expression , how do i make it match only for the "full
>length" of $2?
>here it is....
>if (/^([0-9]+) (.+)\n/) {
>     print ("The first is $1 and the second is $2\n");
>     if ($std_line =~ /$2/i)

>etc..}
>To my displeasure, $std_line =~ /$2/i will be a successful match when only
>part of $2 is in $std_line
>i.e. if $2 = "A B C"
>and $std_line = "C"
>i don't want it being matched.
>how do i do this?


Well, if I understand you correctly (which is always a tenuous assumption
where I am concerned) I might try:

 if ($std_line =~ /^$2$/i)


HTH

AmD




------------------------------

Date: Thu, 19 Nov 1998 03:10:43 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Please Help! reg expression
Message-Id: <T_L42.85$yI1.112@nsw.nnrp.telstra.net>

In article <72vrp8$1rl$1@agate.berkeley.edu>,
	davecw@soda.CSUA.Berkeley.EDU (David Wee) writes:

> To my displeasure, $std_line =~ /$2/i will be a successful match when only
> part of $2 is in $std_line
> 
> i.e. if $2 = "A B C"
> and $std_line = "C" 
> 
> i don't want it being matched.

And it won't. Watch:

$_ = "blabla A B C blabla";
/(blabla) (.+) blabla/;

print "'$2'\n";
my $old_2 = $2;

my $stdline = " C";
if ($stdline =~ /$2/)
{
	print "Matched '$stdline' against RE '$old_2'\n";
}
else
{
	print "Couldn't match '$stdline' against RE '$2'\n";
}

OUTPUT:
'A B C'
Couldn't match ' C' against RE 'A B C'

If you change $stdline to 'A B C' or 'foo A B C bar', you will see a
successful match.

There are a few things you need to be aware of:

1) on a successful match, $2 will be reinitialised. It won't be
available after the match (hence the $old_2 in the code above).

2) If your $2 contains RE metacharacters, you need to escape those,
either with the \Q\E combination, or by using quotemeta

# perldoc perlre
# perldoc -f quotemeta

I suspect that the second point is the one that is causing you the
grief you are seeing, unless the code you showed us is not exactly
what you are using.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | The gene pool could use a little
Commercial Dynamics Pty. Ltd.       | chlorine.
NSW, Australia                      | 


------------------------------

Date: Thu, 19 Nov 1998 00:04:18 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: reverse comma operator in the camel
Message-Id: <1dipplr.1xq24c91yp26t6N@bay2-312.quincy.ziplink.net>

J.D. Laub <jdl@iasi.com> wrote:

> On page 48 of the camel:
> 
> # A "reverse comma operator".
> return (pop(@foo),pop(@foo))[0];
> 
> On page 93, when discussing the comma operator, the book states that "in a
> scalar context it evaluates its left argument, throws that value away, then
> evaluates its right argument and returns that value."  Given that, I would
> think a reverse comma operator would evaluate its RIGHT argument, then
> evaluate and return its LEFT argument.

That would not be very useful, would it?

In fact, it would be exactly the same as a regular comma operator with
the elements in reverse order.

[I use ,, to denote a reverse comma operator].
i.e. (3,,2,,1) would be exactly equivalent to (1,2,3); each evaluates 1,
then 2, then 3, and returns 3.

No, a reverse comma, as you can see from the code example you quoted
above, evaluates the left argument, then evaluates the right argument,
then returns the value of the *left* argument.
Thus, (1,,2,,3) evaluates 1, then 2, then 3, and returns 1.

>     #!/usr/local/bin/perl -w
>     my @foo = (101, 303);
>     my $a = (pop @foo, pop @foo)[0];
>     print "a=$a.\n";
> 
> This prints 303, the RIGHT argument in the list, which is the same as the
> comma operator.  Can someone explain what Larry, Tom, & Randall are trying to
> convey with their "reverse comma operator" example?

That is not the same as the comma operator.

my @foo = (101, 303);
my $a = (pop @foo, pop @foo);
print "a=$a.\n";

would print 101.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: 19 Nov 1998 02:47:32 GMT
From: theeadsnet@aol.com (TheEadsNet)
Subject: sendmail flags
Message-Id: <19981118214732.15220.00002864@ng118.aol.com>

Can someone tell me how to format the sendmail command such that I can make 
sendmail recognize Errors-To: headers.  I read the man page concerning the 
-ol  flag, but I can't seem to get it to work.

I want to route all incoming sendmail errors to a separate e-mail address.

Thank you , in advance.

-Joe Halbrook



------------------------------

Date: Thu, 19 Nov 1998 00:04:27 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Sounds easy when I type it fast
Message-Id: <1dipq97.1v8euameq7bjdN@bay2-312.quincy.ziplink.net>

Jenny Brandis <brandis@benet.net.au> wrote:

> But now what? I guess I need to upload the (unzipped) stable.zip to my
> cgi-bin, but do I need all those files? Or just some that run the bits I
> want?

You don't need to upload any of those files.  perl should already be
installed on your ISP's server.  You just need to make sure your Perl
scripts have the correct path in the #! line (#!/usr/local/bin/perl is
common, but ask your ISP), and then upload the scripts.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: Thu, 19 Nov 1998 02:49:10 GMT
From: leroy@mpi.com
Subject: strange SEGV with sort or some sort of such thing
Message-Id: <7300v1$9sh$1@nnrp1.dejanews.com>

hi!
I'd like to report a weird problem :
with  perl, version 5.004_04 built for sun4-solaris

I get a SEGV on the following line :

if( $x eq ( sort($x,$y) )[0] ) { return -1; } else {return 1; }

(basically I had  forgotten about $x cmp $y).

Actually, it is just fine for short strings ...
but I get the SEGV when $x is the 257 long string :

MGQKVNPIGFRVGVIRDWDSKWYADKKIVPALVKEDAVIRKFLNKKYNNAAVSHVEIERLKELKVKKRVKITLHSGKPGVVIGREAATMKETIASLEKLTKKEIVFNVVEVRKPEVVATLVAQSMAEQLENRASFRKSTKNCYAKSIKVRAKGIKTLSQRLGGREMARTEGYSEGQVPLHTLRADVEYATAEAQTTYGILGIKVWIYHGEILPGQSHEELRKERQSSASSNHGGGKRRPSRKGPRRSQEDAATEGGN

(this is a protein sequence, if you wondered ...)
I tried with other 257 long strings and everything is fine.

Is this the place to report such fancy bugs ?
I might not read the news often, Cc me a reply if you expect me to answer your
reply.

thanks !


christophe


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Thu, 19 Nov 1998 02:17:57 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Two-Part RE question
Message-Id: <pdL42.73$yI1.241@nsw.nnrp.telstra.net>

In article <3653732C.5C6E3446@hotmail.com>,
	sara starre <nospam.perl_rocks@hotmail.com> writes:

> PS: The solutions were great! It seemed like some posters thought
> that the ?'s were needed in the regex, and others didn't. I'll try
> it both ways and see which I like, but I may not stumble on the
> case(s) that ? was designed to prevent.

I am not sure if you know this, but just in case:
The ? you are referring to is there to match 'non-greedy'. That
basically means it will match the shortest string possible that
satisfies the RE. If you don't use it, a RE will match greedy, and
will match the longest possible string that satisfies the RE.

Like:

$_ = "cat[man]dog]dog";

/\[(.+)]/;
print "$&\n";

/\[(.+?)]/;
print "$&\n";

OUTPUT:
[man]dog]
[man]

This may or may not be important in the case you're looking at. In any
way, you'll indeed have to pick the one that gives you the best
success rate. In case there will always be exactly one opening, and
exactly one closing bracket (in that order), they shuold be
functionally identical.

If you really need to deal with possible nested brackets, refer to one
of the other posts in this thread, or have a look at the perlfaq6
entry "Can I use Perl regular expressions to match balanced text?".

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I'm just very selective about what I
Commercial Dynamics Pty. Ltd.       | accept as reality - Calvin
NSW, Australia                      | 


------------------------------

Date: Thu, 19 Nov 1998 00:04:32 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Two-Part RE question
Message-Id: <1dipqm8.1dfn1ah19sihjrN@bay2-312.quincy.ziplink.net>

Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote:

> You could try 
> $x=~/\[(.*?)\]/ and $y = $1;

Unnecessary use of non-greedy matching.

This is also the *least efficient* use of non-greedy matching, where the
regex engine has to step out of and into the capturing parentheses on
every step.

> As for the speed difference :
> Benchmark: timing 1000000 iterations of regex, substr...
>      regex: 38 wallclock secs (37.19 usr +  0.08 sys = 37.27 CPU)
>     substr: 23 wallclock secs (22.60 usr +  0.04 sys = 22.64 CPU)
> 
> Replace the string to be searched with 'cat['.("abc"x1000).'man]dog' and the
> difference is more noticable.
> 
> Benchmark: timing 10000 iterations of regex, substr...
>      regex: 16 wallclock secs (16.37 usr +  0.00 sys = 16.37 CPU)
>     substr:  1 wallclock secs ( 0.67 usr +  0.00 sys =  0.67 CPU)
> 
> 
> Just in case someone wants to point out my error in the my benchmark code
> (I'm good at getting these worng and thus getting the opposite results
> than reality would indicate)...
> 
> use Benchmark;
> $x = 'cat[man]dog';
> timethese(10000, {
>                 "substr" => \&use_substr,
>                 "regex" => \&use_regex,
>                 });
> sub use_substr {
>         $i1=index($x,"\[");
>         $i2=index($x,"\]");
>         $y =substr($x,$i1+1,$i2-$i1-1);
> }
> sub use_regex {
>         $x=~/\[(.*?)\]/ and $y = $1;
> }


With the short value for $x, I didn't see the time disparity you found.
All three solutions took about the same amount of time.

['nongreedy' is your 'regex']

Benchmark: timing 1000000 iterations of greedy, nongreedy, substr...
    greedy: 18 secs (18.07 usr  0.00 sys = 18.07 cpu)
 nongreedy: 22 secs (20.78 usr  0.00 sys = 20.78 cpu)
    substr: 17 secs (18.13 usr  0.00 sys = 18.13 cpu)



With the long value for $x, substr was much faster than nongreedy, as it
was for you.  The greedy regex that I proposed is also much faster than
the nongreedy one.  However, the substr solution is still the clear
winner.

Benchmark: timing 10000 iterations of greedy, nongreedy, substr...
    greedy:  4 secs ( 3.88 usr  0.00 sys =  3.88 cpu)
 nongreedy: 24 secs (24.00 usr  0.00 sys = 24.00 cpu)
    substr:  1 secs ( 0.85 usr  0.00 sys =  0.85 cpu)


Note, however, that with a different long value for $x --
'cat'x1000.'[man]dog' -- the regex solutions are slightly faster than
the substr solution.  By about 1/50000 of a second per iteration.  :-)

Benchmark: timing 100000 iterations of greedy, nongreedy, substr...
    greedy:  9 secs ( 8.55 usr  0.00 sys =  8.55 cpu)
 nongreedy:  9 secs ( 8.77 usr  0.00 sys =  8.77 cpu)
    substr: 11 secs (11.03 usr  0.00 sys = 11.03 cpu)



use Benchmark;

$x = 'cat[man]dog';

timethese(1_000_000, {
                "substr" => \&use_substr,
                "nongreedy" => \&use_nongreedy,
                "greedy" => \&use_greedy,
                });
sub use_substr {
        $i1=index($x,"\[");
        $i2=index($x,"\]");
        $y =substr($x,$i1+1,$i2-$i1-1);
}
sub use_nongreedy {
        $x=~/\[(.*?)\]/ and $y = $1;
}
sub use_greedy {
        $x=~/\[([^]]*)\]/ and $y = $1;
}


-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: Wed, 18 Nov 1998 18:30:26 -0800
From: "Andrey L. Abramov" <abramoa@leland.stanford.edu>
Subject: Win16 DLL access (on NT) Help!!!
Message-Id: <365382C1.EE86EC83@leland.stanford.edu>




How do I access Win16 DLLs from Perl (on Win'95 or WinNT platform)  ?
Will Win32API do it? Please help!!!!

Many thanks in advance....


--
===================================================================
Andrey L. Abramov                            |    "Try not.  Do.
MBA'97, Stanford Graduate School Of Business |      Or do not.
mailto:abramoa@leland.stanford.edu           |  There is no 'try'".
Phone: (650)947-8827                         |       - Yoda
=====================================================================




------------------------------

Date: Thu, 19 Nov 1998 04:11:54 GMT
From: mobetta1231@my-dejanews.com
Subject: Re: Win32 executing a .pl or .cgi
Message-Id: <7305pv$dtn$1@nnrp1.dejanews.com>

I can't imagine why you would be having problems running perl programs from
the command line. I've been doing it for a while now. During the
installation, the .pl is registered and associated with perl.exe. Maybe you
should try downloading the newest ActivePerl. I've had success with the
previous version as well as this one.

In article <tamcgee-1711982231070001@cc1017583-a.union1.nj.home.com>,
  tamcgee@home.com (Tom McGee) wrote:
> I run Website professional on an NT4 box, and I too can't just type the
> name of the scriptr. I have to type "perl myscript.pl" for it to run from
> the command line.
>
> But that doesn't stop my server from running cgi properly.
>
> Your command prompt issue is a red herring. Check your server docs.
>
> --Tom
>
> In article <72t1eb$9op$1@news.hoosier.net>, "Rambler"
> <rambler@bloomington.in.us> wrote:
>
> >>I have associated the .pl and .cgi file extensions with perl.exe on my
> >>system and can double click on the file in the explorer and the program
> >>runs.  I can also at the dos prompt tyep 'perl test.pl' and the program runs
> >>but I can't just type test.pl.  All I get is "Bad command or file name
> >>".  This is obviously preventing anything to work from a web page.
> >>
> >>Can anyone tell me what I am doing wrong?  All I can find anyplace I have
> >>search says I must simply associat the pl and cgi extensions with perl.exe.
> >>
> >>--
> >>Rambler
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 4252
**************************************

home help back first fref pref prev next nref lref last post