[9636] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3230 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 23 02:07:18 1998

Date: Wed, 22 Jul 98 23:00:21 -0700
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, 22 Jul 1998     Volume: 8 Number: 3230

Today's topics:
    Re: 'eval' and 'require' <ajh@rtk.com>
    Re: 100% FREE Franchise Site (Rick Roby)
    Re: [NEEDED]:Password History Script (-)
    Re: Coding Quiz (was Re: efficiency: print<<"xxx" vs. p (David. E. Goble)
    Re: comparing files in perl <lloyd@morpheme.com>
        Copyright question <dcobb@cyberrealm.net>
    Re: Dynamically creating graph images (Martin Gleeson)
    Re: Flat-File Database (-)
    Re: HELP! How do i read a remote HTML file into a local (-)
        How to send the e-mail by attractment <bugking@usa.net>
        installing perl in a different directory, @INC <dannyv@tibco.com>
    Re: mail bomber source code for perl. (-)
        need some info about perl (GEMINI)
    Re: no Net::IMAP ?? <uri@sysarch.com>
    Re: Perl array name (Larry Rosler)
    Re: Regular expressions for Perl 5 ptimmins@my-dejanews.com
    Re: Regular expressions for Perl 5 <avatar4@blueskyweb.com>
    Re: Reversing time (-)
    Re: Save additional data (Tad McClellan)
    Re: specific character/position in string <ajohnson@gpu.srv.ualberta.ca>
    Re: specific character/position in string (Josh Kortbein)
    Re: specific character/position in string (Charles DeRykus)
    Re: specific character/position in string (Larry Rosler)
    Re: Tcl is better than Perl lvirden@cas.org
    Re: Tcl is better than Perl (Cameron Laird)
    Re: the low road (Tad McClellan)
    Re: Variable Interpolation (Tad McClellan)
    Re: Web Components (-)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 22 Jul 1998 13:43:09 -0700
From: "Aaron Harsh" <ajh@rtk.com>
Subject: Re: 'eval' and 'require'
Message-Id: <6p5ith$5qn$1@brokaw.wa.com>

Martin Gregory wrote in message ...
>_Is_ there any safe way to test 'require'?


You could check the return value from eval, which will be true iff the
require'd file exists and ran succesfully:

  unless ( eval 'require "foo"' )
  {
     $@ ||= "foo did not return a true value";
     die "ERROR: $@\n";
  }

or:

   my $is_foo_available = eval 'require "foo"';

--
Aaron Harsh
ajh@rtk.com


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

Date: Thu, 23 Jul 1998 04:44:27 GMT
From: richie@Rednecks.com.nospam.ok (Rick Roby)
Subject: Re: 100% FREE Franchise Site
Message-Id: <35b6bf18.4434460@enews.newsguy.com>

On 23 Jul 1998 02:39:47 GMT, mgjv@comdyn.com.au (Martien Verbruggen)
wrote:

>In article <190798221712@anywhereusa.com>,
>	"Javier Fernandez" <Sierra@AnywhereUSA.com> writes:
>
>> 100% FREE Franchise Site at URL http://www.sierranv.net/~online
>
>Thank you. I was afraid for a minute that you would charge me for this
>spam.
>
>> This Site contain more than 2500 absolutely FREE business documents
>> (business reports, ideas, examples of agreements, US law, job proposals
>> of work from your home and much more). All of them will help you to
>
>Just what I was waiting for! US law documents. That will be useful. I
>can just imagine sitting at my desk, next week or so, and suddenly
>feel an incredible craving to read a US law document. I'll probably
>also email it to everyone I know in Europe.

You mean you get those cravings too? Man, I can't wait to send them to
my Canadian friends too! :-)


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

Date: Thu, 23 Jul 1998 05:07:33 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: [NEEDED]:Password History Script
Message-Id: <35b6c4dc.107340764@news2.cais.com>

Simon Whiting <simon.whiting@dpie.gov.au> Said this:

>G'day All,
>
>I have a UNIX systems that requires a password history of
>the last 5 passwords.  I've searched for such a script, but
>haven't found anything.  Does such a script exist?
>


Doesn't shadow password have something like that available (not as
default but if you want to enable it)
??



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

Date: Thu, 23 Jul 1998 02:23:31 GMT
From: goble@kigateway.eastend.com.au (David. E. Goble)
Subject: Re: Coding Quiz (was Re: efficiency: print<<"xxx" vs. print)
Message-Id: <35b6aaa3.0@duster.adelaide.on.net>

Uri Guttman <uri@sysarch.com> wrote:
>
>1. Who is main the PERSON you should think about while you are writing code?
>
No one, you should be thinking about the code reflecting the design
>
>2. Other than comments, what is the most important HUMAN aspect of code?
>
	user-friendliness
>
>3. What is the main PURPOSE of comments?
>
	Readability
>
>Bonus: What is the OPPOSITE of spaghetti code?
>
	Structured code


Regards :           David. E. Goble
                         goble@kin.on.net
                 http://www.eastend.com.au/~goble
    Po Box 648 Kingscote Kangaroo Island South Australia 5223



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

Date: Wed, 22 Jul 1998 21:51:32 -0700
From: Lenny Bruce Lee <lloyd@morpheme.com>
Subject: Re: comparing files in perl
Message-Id: <35B6C154.4A6B341@morpheme.com>

Martien Verbruggen wrote:
> 
> In article <6p5n18$ei4@jupiter.planet.net>,
>         impactid@pantheon.yale.edu () writes:
> 
> > i'm wondering if there's a perl function or module that would
> > do what diff does in unix shell.
> 
> This question was asked a few weeks back, on this very newsgroup.
> 
> > please post or email cwu@geocities.com
> 
> Please use www.dejanews.com to find that thread.
> 
> Martien

Actually, I asked the question. There was no answer. File::Compare is equivalant to unix cmp but doesn't do what diff
does. Anyone who is interested in working on this, I have an algorithm I have written comparing two files. It is not
smart and elegant like like diff though. It's output is more of the nature:

=== T6504B75 Test Cmp ===
T6504B75-- 6500 *  BASIC FSF/BSF TEST - 1 (FULL)
CCW-UNL-03 READ BUFFERED LOG IS EMPTY.CSW=0D000000
WAITING FOR MOUNT COMPLETION .....
DEV=**DEVICE** - START.
DEV=**DEVICE** - END.
<<DIFF1: ENTER MONITOR COMMAND
<<DIFF2: QUIT
<<DIFF3: **CPUTIMESTAMP**
============
T6504B75-- 6500 *  BASIC FSF/BSF TEST - 1 (FULL)
CCW-UNL-03 READ BUFFERED LOG IS EMPTY.CSW=0D000000
WAITING FOR MOUNT COMPLETION .....
DEV=**DEVICE** - START.
DEV=**DEVICE** - END.
>>DIFF1: 
>>DIFF2: 
>>DIFF3: 
=========================

This is great but if one line is inserted then each line after that is off.
ie:
<<this line is different
--
>>this line is the same
>>this line is different

 Any help would be welcome. Write me at
perldiff@morpheme.com if you wish to particpate in creating a better version. Or, better yet point to an already
existing diff like perl module.

-lloyd
-- 
"The new electronic interdependence recreates the world
 in the image of a global village."  - Marshall McLuhan
  mailto:lloyd@morpheme.com ----- http://www.morpheme.com


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

Date: Tue, 21 Jul 1998 12:59:29 -0400
From: Dustin Cobb <dcobb@cyberrealm.net>
Subject: Copyright question
Message-Id: <35B4C8F1.90D65F50@cyberrealm.net>

I'm a cgi programmer and I've written many scripts for the ISP I work
for.  Recently, I've been told by someone else in our company that the
scripts that we've written in Perl cannot be copyrighted due to the fact
that Perl isn't a compiled language.  Therefore, we would have to
re-write most of these scripts in another language (like C/C++) to
obtain a copyright.  Is this true?  Can anyone give me an example of
some software that is written entirely in Perl and is legitimately
copyrighted?

Thanks.



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

Date: Thu, 23 Jul 1998 15:04:31 +1000
From: gleeson@unimelb.edu.au (Martin Gleeson)
Subject: Re: Dynamically creating graph images
Message-Id: <gleeson-ya02408000R2307981504310001@news.unimelb.edu.au>

[courtesy cc: sent to original author via email.]

In article <6p58fu$26b$1@ultranews.duc.auburn.edu>,
carltjm@mail.auburn.edu (Joseph M Carlton) wrote:

>I am using perl to fetch data from a database for a web project that I am 
>working on. Now, I need to dynamically build a bar graph with this data.  
>Someone told me that I could use javascript and somebody told me that I 
>could do the whole thing in perl. I have not been able to find any 
>information on this topic for either javascript or perl.  Could someone 
>PLEASE direct me to a book or web page with information on this?  I am 
>not limited to perl and javascript, so if anyone knows of a better way to 
>do this.  I would be VERY appreciative.  Thanks in advance for your help.

Yes, you can do this easily with perl using Lincoln Stein's excellent
GD.pm. <URL:http://stein.cshl.org/WWW/software/GD/GD.html>.

Cheers,
Marty.
--
Martin Gleeson
** Personal opinion only **
Webmaster, The University of Melbourne, Australia.
Imagine, if you will, a world without hypothetical situations...


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

Date: Thu, 23 Jul 1998 04:54:33 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Flat-File Database
Message-Id: <35b6c1d4.106564884@news2.cais.com>

"Sam Spurling" <spurling@mindspring.com> Said this:

>I am new to perl and am wanting to write a database that can be added to
>deleted from and modified.  Does anyone have an example that I can use to
>see and understand how this works in perl.
>
>

This example may be a tad bit complex, but try

http://www.extropia.com

That's "Selena Sol's" web site.  on it he has a database manager
script that is pretty complex but might give you a couple ideas.




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

Date: Thu, 23 Jul 1998 05:17:50 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: HELP! How do i read a remote HTML file into a local variable?
Message-Id: <35b6c6a3.107767466@news2.cais.com>

"rudis" <rudis@mindless.NOSPAMcom> Said this:

>I'm making a perl 5 CGI script in which i need to read remote html
>files into local variables, similar to the way you can open local ones
>with
>
>
>open(FILE,"/local/path/to/file");
>
>@somearray =3D <<FILE>;
>
>close(FILE);
>
>
>I've tried replacing the local path on the open command to a remote
>URL (i.e.: open(FILE,"http://www.somehost.com/somefile.html");)), but
>that doesn't seem to work.
>

The easiest way is to invoke lynx, although that is not portable.
It's the simplest way though:

$variable = `lynx -source http://www.somehost.com/somefile.html`;

(those are backticks, the top-left corner of your keyboard).  Now, the
source of the above URL is in $variable.

But, like I said, it's not portable.  For a more portable (meaning you
can take the script and run it on almost any computer) is to use one
of the modules, or http-lib.pl (available at http://www.extropia.com)

These will allow you to get web pages, post get and post data, etc,
from within your perl scripts.



>
>Can someone please help me out by emailing me some code snippets to
>rudis@mindless.NOSPAMcom (after removing the word NOSPAM from that
>address).
>
>

Sorry, if you can't read the newsgroup, you shouldn't ask for help
here.




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

Date: Thu, 23 Jul 1998 11:30:03 +0800
From: "Bug" <bugking@usa.net>
Subject: How to send the e-mail by attractment
Message-Id: <35b6af8d.0@ruby.hknet.com>

i don't know how to use it, can someone help?




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

Date: Wed, 22 Jul 1998 16:59:07 -0700
From: Danny van der Rijn <dannyv@tibco.com>
Subject: installing perl in a different directory, @INC
Message-Id: <35B67CCB.711A1DA8@tibco.com>

i want to be able to compile perl (5.00404) and then have people install
it whereever they want to.  

on Solaris 2.6, this doesn't work so fine, since the @INC list is
compiled into PERL and therefore PERL finds none of its libraries.

on NT, this works fine, as the precompiled @INC is automatically
prepended with paths that are relative to the perl executable's new
location if it's different than the built location.

one workaround i've tried is to install perl as perl.real (or whatever)
and have perl be a shell script:

#!/bin/sh
exec perl.real \
-I/new_perl_install/lib/sun4-solaris/5.00404 \
-I/new_perl_install/lib \
-I/new_perl_install/lib/site_perl/sun4-solaris \
-I/new_perl_install/lib/site_perl \
$*

but i'm not too happy with this.  any ideas?


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

Date: Thu, 23 Jul 1998 04:45:50 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: mail bomber source code for perl.
Message-Id: <35b6bfc9.106042477@news2.cais.com>

"My Name" <nonspammers.cut.after.the.period.hot_redox@hotmail.com>
Said this:

>> >>Matthew Flinchbaugh <matthew@nofear.hjsoft.com> wrote:
>> >>-> hey does any one have the perl source code for a mail bomber?
>
>> yeah, 
>> 
>> #!/bin/sh
>> cd /
>> rm -r
>> 
>> This simple, two line code, run on any linux machine as root will
>> connect to a special port on the sendmail server. Run this shell
>> script and you will get a series of prompts, asking things like
>> "target server or email address", number of messages to send,
>> duration, etc.
>
>Actually I think:
>#!/bin/sh
>cd /
>rm -rf
>
>would be more helpful for our friend
>

Oh, well you like the more evil email-bombing routines, I see.  Sure,
add the f to the command and stand back!  Email will start spewing out
all over the internet!




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

Date: 23 Jul 1998 03:06:45 GMT
From: dennis@info4.csie.nctu.edu.tw (GEMINI)
Subject: need some info about perl
Message-Id: <6p69c5$8qp$2@netnews.csie.NCTU.edu.tw>

hi there,
  Recently I have to hold a presentation that
introduce perl language. However, some information
is not easily available from the books, FAQ, or internet resources.
What I'd like to know is :
1. the history and background of Perl's development,
when & by whom the perl was created.
2. what company or organization is in charge of it? 
if we need a solid support, any fee is needed?

please tell me the information or 
the location that I can get info from,
thanks.


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

Date: 23 Jul 1998 00:08:05 -0400
From: Uri Guttman <uri@sysarch.com>
To: jbnivoit@ix.netcom.com
Subject: Re: no Net::IMAP ??
Message-Id: <x7sojtky56.fsf@sysarch.com>

>>>>> "j" == jbnivoit  <jbnivoit@ix.netcom.com> writes:

  j> Hi everybody,

  j> 	i'm a little surprised that the libnet bundle does not come with
  j> a Net::IMAP package (it has Net::POP3). Do i have an older version? Is
  j> anyone
  j> working on such a thing?

i found it very quickly using WAIT at
http://theory.uwinnipeg.ca/SFgate/WAIT4CPAN.html

i leave the search up to the reader.

hth,

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Wed, 22 Jul 1998 20:09:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl array name
Message-Id: <MPG.1020494338fc2f38989779@nntp.hpl.hp.com>

In article <1dclalq.kmv60q1p1664gN@bay1-119.quincy.ziplink.net> on Wed, 
22 Jul 1998 22:33:07 -0400, Ronald J Kimball <rjk@coos.dartmouth.edu> 
says...
> Larry Rosler <lr@hpl.hp.com> wrote:
> 
> > That is certainly a simple and usable approach, but might get you into
> > trouble in various ways.  For example, suppose the name is not a valid
> > Perl identifier?
> 
> Symbolic references may get you into trouble, but not in the way you
> gave as an example.  Any string is a valid identifier in a symbolic
> reference.
> 
>   DB<1> $x = "is this\tan\ninvalid identifier???"
> 
>   DB<2> $$x = "no, it works!"
> 
>   DB<3> x $$x
> 0  'no, it works!'
>   DB<5> X ~is
> $is this^Ian^Minvalid identifier??? = 'no, it works!'
>   DB<6> 

Evidently, though I can't find it either explicitly, implicitly, or by 
example in perlref.  I assumed the name ended up in the symbol table 
somehow and therefore had to be a valid identifier.

Anyhow, one of the first and most valuable things I learned from this 
newsgroup was to rethink my code to avoid symbolic references.  Things 
have been much cleaner since then; hence the small tutorial I posted.  No 
question that '-w' and 'use strict;' are the way to go.

Having said that, I can ask how to explain to a newbie what *are* the 
ways one could get in trouble using symbolic references?

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


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

Date: Thu, 23 Jul 1998 03:53:34 GMT
From: ptimmins@my-dejanews.com
Subject: Re: Regular expressions for Perl 5
Message-Id: <6p6c3v$f4c$1@nnrp1.dejanews.com>

In article <35B631ED.DC3BBCC4@netscape.com>,
  BJKim <shado@uclink4.berkeley.edu> wrote:
> Does Perl 4 not support certain aspects of regular expressions that Perl
> 5 does.
>
> This is the error I get in Perl 4 but not in Perl 5
>
> /(<TD>(.*?)</TD><TD>(.*?)</TD>){1}?/: nested *?+ in regexp at change.cgi
> line 70.
>
> Any suggestions on what I should do?
>
>

It hurts when I bang my head against the wall doc. What should I do?

Seriously though, you're using '*' in a non-greedy way, which you can't do in
Perl 4. Don't do that. The Perl 4, that is. Not the non-greedy.

Patrick Timmins
U. Nebraska Medical Center

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 23 Jul 1998 00:21:02 -0400
From: qwerty <avatar4@blueskyweb.com>
Subject: Re: Regular expressions for Perl 5
Message-Id: <35B6BA2E.F8E15661@blueskyweb.com>

I rarely post here, but this one required from me a response.
BJKim, for the first part, ignore that previous response, which
completely reveresed your question.  For the second part, please
demonstrate what you are trying to match for, One might assume to just
the next </TD>, but this might not be the case.

-qwerty

ptimmins@my-dejanews.com wrote:
> 
> In article <35B631ED.DC3BBCC4@netscape.com>,
>   BJKim <shado@uclink4.berkeley.edu> wrote:
> > Does Perl 4 not support certain aspects of regular expressions that Perl
> > 5 does.
> >
> > This is the error I get in Perl 4 but not in Perl 5
> >
> > /(<TD>(.*?)</TD><TD>(.*?)</TD>){1}?/: nested *?+ in regexp at change.cgi
> > line 70.
> >
> > Any suggestions on what I should do?
> >
> >
> 
> It hurts when I bang my head against the wall doc. What should I do?
> 
> Seriously though, you're using '*' in a non-greedy way, which you can't do in
> Perl 4. Don't do that. The Perl 4, that is. Not the non-greedy.
> 
> Patrick Timmins
> U. Nebraska Medical Center
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 23 Jul 1998 05:21:09 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Reversing time
Message-Id: <35b6c7ce.108066405@news2.cais.com>

martin_harriss@my-dejanews.com Said this:

>How can I turn a given date in the dd mmm yyyy form into the internal time
>format as returned by the time function?  I need to be able to compare the
>time written in a file with the current time.
>

perldoc localtime

localtime gives you an array consisting of day, month, year, weekday
number, hour, minute, seconds, daylight_savings, and so on and so
forth.  Use it instead of time and you can easily construct comparison
strings.




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

Date: Wed, 22 Jul 1998 22:33:14 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Save additional data
Message-Id: <qta6p6.j2d.ln@localhost>

Fernando Nemec (fnemec@sti.com.br) wrote:

: >When I open the file for read it will be read line by line. then I have to
: >close it and to work with this information. How can I realise it, that only
: >this one line will be overwrite with the new information, so that I can
: >return to it, when I open the file again.

: I have encountered a problem very similar, but I don't find any solution
: yet; if you find the solution, please tell me how I can do it!


   Could one of you try explaining the unanswered problem again?

   I'm not understanding the question, I guess.



   Might it be one of these questions?


   Q) How can I change only one line in a file.

   A) See the Perl FAQ, part 5:

       "How do I change one line in a file/
        delete a line in a file/
        insert a line in the middle of a file/
        append to the beginning of a file?"
        


   Q) How can I change only one line in a file, without having to
      rewrite the whole file.

   A) You can't in the general case. See the Perl FAQ, part 5:

       "How do I change one line in a file/
        delete a line in a file/
        insert a line in the middle of a file/
        append to the beginning of a file?"
       

   Q) When reading in the modified file, how can I tell if it is
      one of the modified lines?

   A) See my other followup.




   If none of those are it, then please try rephrasing the question.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 22 Jul 1998 21:58:09 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: specific character/position in string
Message-Id: <35B6A6C1.5D5E67C7@gpu.srv.ualberta.ca>

Larry Rosler wrote:
!
[snip]
! 
! Benchmark: timing 200000 iterations of REGEX, RINDEX, RINDEX2, SUBSTR...
!      REGEX: 114 secs (42.78 usr  0.24 sys = 43.02 cpu)
!     RINDEX: 26 secs ( 8.60 usr  0.06 sys =  8.66 cpu)
!    RINDEX2: 20 secs ( 7.51 usr  0.04 sys =  7.55 cpu)
!     SUBSTR: 10 secs ( 3.78 usr  0.03 sys =  3.81 cpu)
! 
! CONCLUSION:
! 'SUBSTR' rules (as always) and 'REGEX' loses big (as always).
! 
! Here is the final code, if anyone wants to verify any of this:
! 
! #!/usr/local/bin/perl5 -w
! use Benchmark;
! use vars qw( $string $flag );
! $string = 'a' x 2999 . '.' . 'b';
! $flag = 0;
! timethese(200000, {
!         REGEX   => sub { $flag = 1 if $string =~ /\..$/ },
!         SUBSTR  => sub { $flag = 1 if ("." eq substr($string, -2)) },
!         RINDEX  => sub { $flag = 1 if (rindex($string, ".") eq
! length($string) - 2) },
!         RINDEX2 => sub { $flag = 1 if (rindex($string, ".") eq 2999) },
! });

now, change the string compare 'eq' to a proper numerical
comparison '==' for RINDEX2 and you should find that it
compares favorably to SUBSTR, even a little faster in my
test (not unexpectedly, since this is the kind of thing
rindex() is designed to do).

regards
andrew


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

Date: 23 Jul 1998 03:03:58 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: specific character/position in string
Message-Id: <6p696u$3ht$1@news.iastate.edu>

Josh Kortbein (kortbein@iastate.edu) wrote:
: #!/usr/local/bin/perl5

: use Benchmark;

: my $string = 'a' x 2999 . '.' . 'b';
: my $flag = 0;
: timethese(1000000, {
:         'REGEX' =>
:                 '$flag = 1 if $string =~ /\..$/',
:         'SUBSTR' =>
:                 '$flag = 1 if ("." eq substr($string, -2))',
:         'RINDEX' =>
:                 '$flag = 1 if (rindex($string, ".") eq length($string) - 2)',
:         'RINDEX2' =>
:                 '$flag = 1 if (rindex($string, ".") eq 2999)'
: });

Oops - those should be ==s in RINDEX and RINDEX2, not eqs. Same
mistake in Larry Rosler's post (he inherited it from me).

If you make the replacement the RINDICES approach SUBSTR in the
benchmark. Apparently eq was forcing stringification of both
its arguments.




Josh



--

__________________________________________
She had heard all about excluded middles;
they were bad shit, to be avoided.
            - Thomas Pynchon



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

Date: Thu, 23 Jul 1998 03:13:59 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: specific character/position in string
Message-Id: <EwJ2BC.2Br@news.boeing.com>

In article <6p5qgf$9kr$1@news.iastate.edu>,
Josh Kortbein <kortbein@iastate.edu> wrote:
>Michael Shavel (mshavel@erols.com) wrote:
>
>: Hello,
>
>: I need to find out if the next to last character in a 3001 length
>: character string is a period (.)
>  omitted...
>
>/home/kortbein% perl find.pl
>Benchmark: timing 1000000 iterations of REGEX, RINDEX, RINDEX2, SUBSTR...
>     REGEX:  1 secs ( 0.97 usr  0.02 sys =  0.98 cpu)
>    RINDEX:  4 secs ( 3.87 usr  0.02 sys =  3.88 cpu)
>   RINDEX2:  5 secs ( 4.22 usr  0.02 sys =  4.23 cpu)
>    SUBSTR:  2 secs ( 1.47 usr  0.00 sys =  1.47 cpu)
>/home/kortbein% cat find.pl
>#!/usr/local/bin/perl5
>
>use Benchmark;
>
>my $string = 'a' x 2999 . '.' . 'b';
>my $flag = 0;
>timethese(1000000, {
>        'REGEX' =>
>                '$flag = 1 if $string =~ /\..$/',
>        'SUBSTR' =>
>                '$flag = 1 if ("." eq substr($string, -2))',
>        'RINDEX' =>
>                '$flag = 1 if (rindex($string, ".") eq length($string) - 2)',
                                                     ==
>        'RINDEX2' =>
>                '$flag = 1 if (rindex($string, ".") eq 2999)'
>});
                                                     ==
>
>Question to more experienced readers: why does my code warn about
>use of an uninitialized variable in one of the timethese() evals
>if I run with -w? I can't see where the usage mentioned is.
>I thought it might have been substr(), since one can assign to
>it, but a separate test I ran had no problems with substr() being
>on the LHS or RHS of assignment.
>

The smoking gun is in variable $string's hands but
I'm not sure how it got there :). 

Here's a couple of workarounds:

  declare $string as a package global rather than a lexical.

  use anonymous sub code ref's rather than code strings
  in the timethese call.    


HTH,
--
Charles DeRykus


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

Date: Wed, 22 Jul 1998 21:47:34 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: specific character/position in string
Message-Id: <MPG.1020604279e6867598977a@nntp.hpl.hp.com>

In article <6p696u$3ht$1@news.iastate.edu> on 23 Jul 1998 03:03:58 GMT, 
Josh Kortbein <kortbein@iastate.edu> says...
> Josh Kortbein (kortbein@iastate.edu) wrote:
> : #!/usr/local/bin/perl5
> 
> : use Benchmark;
> 
> : my $string = 'a' x 2999 . '.' . 'b';
> : my $flag = 0;
> : timethese(1000000, {
> :         'REGEX' =>
> :                 '$flag = 1 if $string =~ /\..$/',
> :         'SUBSTR' =>
> :                 '$flag = 1 if ("." eq substr($string, -2))',
> :         'RINDEX' =>
> :                 '$flag = 1 if (rindex($string, ".") eq length($string) - 2)',
> :         'RINDEX2' =>
> :                 '$flag = 1 if (rindex($string, ".") eq 2999)'
> : });
> 
> Oops - those should be ==s in RINDEX and RINDEX2, not eqs. Same
> mistake in Larry Rosler's post (he inherited it from me).

Along with the substr($string, -2, 1) bug.  I'll have to train myself to 
look more carefully, even at what I'm not looking for.

> If you make the replacement the RINDICES approach SUBSTR in the
> benchmark. Apparently eq was forcing stringification of both
> its arguments.

And REGEX is still out of the running. :-)

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


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

Date: 23 Jul 1998 03:26:24 GMT
From: lvirden@cas.org
Subject: Re: Tcl is better than Perl
Message-Id: <6p6ah0$6gr$1@srv38s4u.cas.org>


According to  <mrauschkolb@my-dejanews.com>:
:Read all about it here:
:

Well, actually, one only reads about one side of the issue there...
-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: 22 Jul 1998 23:33:04 -0500
From: claird@Starbase.NeoSoft.COM (Cameron Laird)
Subject: Re: Tcl is better than Perl
Message-Id: <6p6ee0$eie$1@Starbase.NeoSoft.COM>

In article <6p6ah0$6gr$1@srv38s4u.cas.org>,  <lvirden@cas.org> wrote:
>
>According to  <mrauschkolb@my-dejanews.com>:
>:Read all about it here:
>:
>
>Well, actually, one only reads about one side of the issue there...
			.
			.
			.
So you think <URL:http://
starbase.neosoft.com/~claird/comp.lang.misc/portable_scripting.html#bilaterals>
might interest some of these readers?
-- 

Cameron Laird           http://starbase.neosoft.com/~claird/home.html
claird@NeoSoft.com      +1 713 996 8546 FAX


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

Date: Wed, 22 Jul 1998 22:24:33 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: the low road
Message-Id: <hda6p6.b0d.ln@localhost>

file (file@job.to) wrote:
: A suggestion use the substitution command:

: so...
: $_ = $html_text;
: $html_text =~ s/\\n/<br>/g;
                  ^^
                  ^^  ???


   I think that a substitution is the way to go too...

   ... but I would go with one that actually works  ;-)


    $html_text =~ s/\n/<br>/g;


: John schrieb in Nachricht <6p57kc$mds$1@nnrp02.primenet.com>...
: >Hello,
: >
: >First of all I would like to say that I am new to the Newsgroup and still
: in
: >the learning stages with perl too but I will do my best not to sound
: >completely ignorant.  As to my topic I was creating a database program
: using
: >perl cgi when I encountered a problem.  It became necessary for form via an
: >HTML page to pass information from a <textarea>.  The problem was I needed
: >to remove the \n's and replace them with <BR>'s.  I opted to use the Split
: >command to split at the \n's and then run a foreach loop to paste the
: <BR>'s
: >in place.  True to TIMTOWTDI form after I finished I got to thinking that
: >there might have been a better way.  Is it possible to set the Output
: Record
: >Separator ($\) to <BR> and if so how do you get it in before the data is
: >passed from the form?
: >
: >I have searched my stack of manuals and browsed till my eyes are falling
: out
: >but I can't seem to find the answer.  It could be that I am looking in the
: >wrong area's but I differ to the wisdom of the board.



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 22 Jul 1998 22:44:07 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Variable Interpolation
Message-Id: <7ib6p6.b3d.ln@localhost>

monty hindman (montyh@umich.edu) wrote:
: I guess I should ask differently:  Why is Perl more than happy to
: interpolate a previously unmentioned scalar variable, while it won't do
: the same for a previously unmentioned array variable?  I'm not trying to
: solve a problem here so much as understand what's going on.


I expect it is because you could always interpolate scalar variables.

So nobody _expected_ to get literal $ signs without escaping them.


Then one day the p5p decided to change perl so that it would begin
interpolating array variables too.

But there were lots of programs out there that would break after
such a change (since interpolation was not possible, programmers
relied on getting their literal @ sign with no need to escape it).

So they added a warning that a new feature has been introduced that
is not backward compatible.

(but the warning is only issued if perl does not (yet) know of an array
 with that name when it encounters an attempt to interpolate it
)



[ Speculation all. I don't follow the p5p list ]


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 23 Jul 1998 04:49:12 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Web Components
Message-Id: <35b6c044.106164567@news2.cais.com>

birgitt@my-dejanews.com Said this:

>
>I could have provided SPAM from AMAZON, if that is what you needed.
>May be I am a bit sensitive, but I don't quite understand why you
>add the URLs of two other online bookstore chaines in your response.
>
>IMHO, either you add thousands of other online bookstores' URL from all
>of which you can order those books and which don't SPAM or you don't add
>any URL.
>
>Do I miss a point here ? Sorry for the off-topic response.
>

I think you do miss a point here....  should this person be required
by some legislation that occured in your mind, to go out and compile a
complete list of every possible retail outlet before mentioning a few
alternatives to the one company that has spammed more often than any
other company?

Maybe those are his two favorite sites?  Can he mention them without
spending the next 6 weeks researching all the other outlets??




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

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 3230
**************************************

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