[9562] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3156 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 14 16:07:17 1998

Date: Tue, 14 Jul 98 13:00:41 -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           Tue, 14 Jul 1998     Volume: 8 Number: 3156

Today's topics:
    Re: $my_debugger{contains_bugs} = 1; (Ilya Zakharevich)
        *** WHOA THERE!!! *** <scribble@pobox.com>
        ANN: Phila Area Perl Training, 17-21 Aug <joseph@5sigma.com>
    Re: Chomp() on win32 and unix perl (Marc Haber)
    Re: DB_File.pm (Michael Ledwidge)
    Re: direct access? (brian d foy)
    Re: explaining the whys of referencing... WAS Re: on th (Kevin Buhr)
    Re: explaining the whys of referencing... WAS Re: on th (Larry Rosler)
    Re: HELP: Programming Question (Larry Rosler)
    Re: HELP: Programming Question <ecl+@andrew.cmu.edu>
    Re: HELP: Programming Question (brian d foy)
    Re: HELP: Programming Question (brian d foy)
    Re: HELP: Programming Question <agy@macgreg.com>
    Re: HELP: Programming Question (Joseph M Carlton)
    Re: invoking href="www.mysite.com/cgi-bin/perl_script?$ (brian d foy)
        IO.pm in which versions? <domainsource@usa.net>
    Re: Is it possible to create a STAND ALONE EXECUTABLE? (brian d foy)
        newbie question on pattern match <xuchu@iscs.nus.edu.sg>
        Out-Smarting CGI.pm chapman50@hotmail.com
        passme <ecl+@andrew.cmu.edu>
    Re: pattern matching with variables? (Larry Rosler)
    Re: pattern matching with variables? <dfan@harmonixmusic.com>
    Re: PERL Tutorial <a.g.macinnes@nospam.rl.ac.uk>
    Re: RegExps: Check if string consists of EXACTLY 3 digi <mgregory@asc.sps.mot.com>
        Survey: Do you also use Tcl or Python? <tdarugar@binevolve.com>
    Re: Trouble with ActiveState - urgent <michael@kbk.org>
    Re: w3c/CERN directory protection (brian d foy)
    Re: Why the "};" on p.231 of PP (2)? <NOSPAMkEynOn@panix.comNOSPAM>
    Re: Why the "};" on p.231 of PP (2)? (brian d foy)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 14 Jul 1998 19:51:21 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: $my_debugger{contains_bugs} = 1;
Message-Id: <6ogcrp$8ed$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Kevin Reid
<kpreid@ibm.net>],
who wrote in article <1dc48jl.1wnravn1esyt67N@slip166-72-108-242.ny.us.ibm.net>:
> I am trying to write an alternate Perl debugger.
> 
> Here it is (so far):
> 
> ------------------------------------------------------------------------
> 
> package DB;
> 
> open DBW, "> Dev:Console:Debug Lines"
>   or die "Couldn't open debugger output window: $!";
> 
> sub DB {
>   my ($package, $filename, $line) = caller;
> 
>   my $packlines = \@{"main::_<$filename"};
>   printf DBW "%-4s %s\n", "$line:", do {chomp (my $temp =
> $packlines->[$line]); $temp}
>     if $package !~ /^Mac/;
>   1;
> }
> 
> 1;
> 
> ------------------------------------------------------------------------
> 
> However, when the following simple program is run (with my debugger), it
> does not wait for input properly:

No wonder, since DB::DB does not wait for input.  

Or do you mean the debugged program does not wait for input?  It does
here (not-a-Mac, thanks g*d!).  (Of course, I changed blah to /dev/tty.)

Hope this helps.
Ilya


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

Date: 14 Jul 1998 14:24:15 -0500
From: Tushar Samant <scribble@pobox.com>
Subject: *** WHOA THERE!!! ***
Message-Id: <6ogb8v$it4@tekka.wwa.com>

I was trying to compile trn4, and was obviously not paying
much attention, because suddenly it stopped and said:

    *** WHOA THERE!!! ***
        The hint value of $var on this machine was "was"!

What's to say to that? A sudden wave of fondness descended
on these old bones...



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

Date: Tue, 14 Jul 1998 12:49:12 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: ANN: Phila Area Perl Training, 17-21 Aug
Message-Id: <35ABB548.7B79C3C8@5sigma.com>

5 Sigma Productions (that's me, Joseph Hall) will be conducting
a 3-day introductory Perl programming class followed by a 2-day
intermediate/advanced class 17-21 August in the Philadelphia
area.  Seating is limited.  For more information, see
http://www.perltraining.com/schedules.html.  Also note there's
a CGI/Perl class there in September.

	-joseph

--
Joseph N. Hall, prop., 5 Sigma Productions       mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training  . . . . . . . . . . . . . . .  http://www.perltraining.com


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

Date: Tue, 14 Jul 1998 18:50:13 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Re: Chomp() on win32 and unix perl
Message-Id: <6og9ad$k6c$2@nz12.rz.uni-karlsruhe.de>

Jonathan Feinberg <jdf@pobox.com> wrote:
> Also: use ASCII mode when transferring your file between platforms;
>this will automagically translate end-of-line sequences between
>platforms.

This is not an option if you are using Samba or NFS.

Greetings
Marc

-- 
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber          |   " Questions are the         | Mailadresse im Header
Karlsruhe, Germany  |     Beginning of Wisdom "     | Fon: *49 721 966 32 15
Nordisch by Nature  | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29


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

Date: 14 Jul 1998 16:57:38 GMT
From: leddo@drjones.next.com.au (Michael Ledwidge)
Subject: Re: DB_File.pm
Message-Id: <6og2m2$rse@inferno.mpx.com.au>

Paul Buder (paulb@user1.teleport.com) wrote:
: >> DCash

: >  To my concern, you must be looking a generic DB_File. You must specify
: >this DB_File by choosing GDBM_File.pm, SDBM_File.pm, etc. Yes, these files
: >comes with Perl.

: Wrong.  DB_File comes with perl but doesn't install unless you have
: the underlying C library.  Look at www.sleepycat.com for that.

If you're installing under Win32, where do you stick the C libary?
BTW the above info is for BerekelyDB only.

Cheers,
	.M.
--
---------------------------------------------------------------------
				          Michela Ledwidge
	TLWM-A-TQC	               michela@thequality.com	
				http://thequality.com/people/michela 
---------------------------------------------------------------------



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

Date: Tue, 14 Jul 1998 15:45:46 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: direct access?
Message-Id: <comdog-ya02408000R1407981545460001@news.panix.com>
Keywords: from just another new york perl hacker

In article <35AB7834.6C12@ast.cam.ac.uk>, Jim Lewis <jrl@ast.cam.ac.uk> posted:

>Is there any way in perl to replace a line in a file without having
>to recreate the whole file? (i.e. like a direct access file in
>FORTRAN)

you can open a file for both reading and writing, then play with seek(), 
tell(), and other sorts of byte-position facilities.  see the docs
for more details.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


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

Date: 14 Jul 1998 13:51:19 -0500
From: buhr@stat.wisc.edu (Kevin Buhr)
Subject: Re: explaining the whys of referencing... WAS Re: on the fly subs with special tag markers
Message-Id: <vba7m1gjmfs.fsf@mozart.stat.wisc.edu>

Dan Baker <dtbaker_@flash.net> writes:
>
>                                                             I have read
> the syntax of references a couple of times, but have trouble really
> *grokking* the concept because I don't see why you would choose to use
> them... what they do better than other constructs? There are obviously
> reasons they are implemented, and I haven't been able to really get to
> that level....

I can think of three good reasons for using references in Perl.  Of
course, there are probably more.

The first is specific to Perl, and I've already seen it mentioned in
followups to your article: Perl complex data structures are built up
from arrays and hashes, but arrays and hashes in Perl always have
scalar elements.  If you didn't have references (a way of
"scalarizing" other arrays and hashes), you'd have to resort to
terrible tricks to get "arrays of arrays of hashes of arrays" or
whatever.  These tricks, which are still documented here and there in
the Perl manpages, are comparatively inefficient and grungy.

The second reason is subroutine-call efficiency.  This is somewhat
less compelling, but the fact is that it's usually faster to pass big
structures by reference rather than by value, simply because down at
the lowest level, the pass-by-reference becomes a copy operation on a
very small data structure while the pass-by-value can become a copy
operation on a very big data structure.

The third reason has to do with objects, and I happen to think it's
the most important.  If you passed objects by value, methods couldn't
change them.  With references, you can write:

	$object->make_yourself_purple;

and the "make_yourself_purple" subroutine can change the "$object",
because it's got a reference to the object.  If it just got a copy of
the "$object", it would be able to change its copy, but not the
original.  You'd have to make the method return a modified object and
write something like:

	$object = $object->make_a_purple_copy;

This seems fine, but what if this code appeared in a subroutine that
had been passed "$object" by value?  You'd have to change it so it
returned a copy, too, and you'd have to change how it was called.
Soon, you'd end up changing every subroutine to return a copy, even if
it didn't need to, and in addition to driving the garbage collector
bonkers, you'd be forced to use the ugly "$x = $x->foo" syntax.

In other words, while it may be considered bad "traditional"
programming practice for a subroutine to modify its arguments, it's an
absolutely necessary programming technique for object-oriented
programming.  A central tenant of OO programming is that objects have
a global state and object methods can modify this state.  If you don't
have references, you can't have global state without resorting to
horrible tricks.

I hope that makes sense.

Kevin <buhr@stat.wisc.edu>


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

Date: Tue, 14 Jul 1998 12:17:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: explaining the whys of referencing... WAS Re: on the fly subs with special tag markers
Message-Id: <MPG.10154e8655b558e598970e@nntp.hpl.hp.com>

In article <vba7m1gjmfs.fsf@mozart.stat.wisc.edu> on 14 Jul 1998 13:51:19 
-0500, Kevin Buhr <buhr@stat.wisc.edu> says...
> Dan Baker <dtbaker_@flash.net> writes:
 ...
> I can think of three good reasons for using references in Perl.  Of
> course, there are probably more.
 ...
> The second reason is subroutine-call efficiency.  This is somewhat
> less compelling, but the fact is that it's usually faster to pass big
> structures by reference rather than by value, simply because down at
> the lowest level, the pass-by-reference becomes a copy operation on a
> very small data structure while the pass-by-value can become a copy
> operation on a very big data structure.

More critical than efficiency is the ability to pass separate aggregates 
as sequential arguments without having them flattened into a single list.

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


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

Date: Tue, 14 Jul 1998 12:09:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: HELP: Programming Question
Message-Id: <MPG.10154cc0c274595498970d@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <35ABA90F.E684F8A6@cas-inc.com> on Tue, 14 Jul 1998 13:53:04 -
0500, J. Paul Hill <paul.hill@cas-inc.com> says...
> I have just started playing with Perl and have been working through the
> exercises in my Perl book.  I wrote a short script to calculate the
> circumference of a circle and decided to give it the option of repeating
> this calculation more than once.  Unfortunately, the logic statement
> seems to only execute correctly the first time through.  After that, it
> either quits or repeats infinitely depending on which logic operator I'm
> using.  Here's the code:
> 
> #!/usr/bin/perl
> $answer = "yes";
> $pi = 3.141592654;
> while ($answer eq "yes") {
>    print "Input radius of circle ";
>    $radius = <STDIN>;
>    (Then it calculates the circumference and prints out the results)
>    print "Would you like to compute another circumference? ";
>    $answer = <STDIN>;
> }
> 
> With the "while" it executes once.  If I use "while ($answer ne "no")",
> it computes repeatedly.  What am I doing wrong?

chomp the newline off the end of $answer.

`perldoc -f chomp`

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


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

Date: Tue, 14 Jul 1998 15:20:40 -0400
From: Eric Chung-Hung Lee <ecl+@andrew.cmu.edu>
Subject: Re: HELP: Programming Question
Message-Id: <Qpeuy8a00iWU04n4E0@andrew.cmu.edu>

Excerpts from netnews.comp.lang.perl.misc: 14-Jul-98 HELP: Programming
Question by "J. Paul Hill"@cas-inc.c 
> Unfortunately, the logic statement
> seems to only execute correctly the first time through.  After that, it
> either quits or repeats infinitely depending on which logic operator I'm
> using.  Here's the code:
>  
> #!/usr/bin/perl
> $answer = "yes";
> $pi = 3.141592654;
> while ($answer eq "yes") {
>    print "Input radius of circle ";
>    $radius = <STDIN>;
>    (Then it calculates the circumference and prints out the results)
>    print "Would you like to compute another circumference? ";


>    $answer = <STDIN>;
This line should be
 $answer = chop(<STDIN>)

The way you had it, when the user typed in "yes" the contents of $answer
would be "yes\n" because <STDIN> includes the newline character.  Chop()
gets rid of this.



> }
>  
> With the "while" it executes once.  If I use "while ($answer ne "no")",
> it computes repeatedly.  What am I doing wrong?
>  
> Thanks for your help!

________________________________________________

All that pleases is but for a moment.
All that troubles is but for a moment.
Nothing is important save that which is eternal.  
________________________________________________ 


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

Date: Tue, 14 Jul 1998 15:36:17 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: HELP: Programming Question
Message-Id: <comdog-ya02408000R1407981536170001@news.panix.com>
Keywords: from just another new york perl hacker

In article <35ABA90F.E684F8A6@cas-inc.com>, "J. Paul Hill" <paul.hill@cas-inc.com> posted:

>#!/usr/bin/perl
>$answer = "yes";
>$pi = 3.141592654;
>while ($answer eq "yes") {
>   print "Input radius of circle ";
>   $radius = <STDIN>;
>   (Then it calculates the circumference and prints out the results)
>   print "Would you like to compute another circumference? ";
>   $answer = <STDIN>;
>}
>
>With the "while" it executes once.  If I use "while ($answer ne "no")",
>it computes repeatedly.  What am I doing wrong?

reading from STDIN includes the newline at the end of the string,
so not only do you have "y", "e", and "s", but also "\n".

you could solve this using chomp, which removes the input record
separator:

   chomp($answer = <STDIN>);

see the docs for more info.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


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

Date: Tue, 14 Jul 1998 15:49:59 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: HELP: Programming Question
Message-Id: <comdog-ya02408000R1407981549590001@news.panix.com>
Keywords: from just another new york perl hacker

In article <Qpeuy8a00iWU04n4E0@andrew.cmu.edu>, Eric Chung-Hung Lee <ecl+@andrew.cmu.edu> posted:

>Excerpts from netnews.comp.lang.perl.misc: 14-Jul-98 HELP: Programming
>Question by "J. Paul Hill"@cas-inc.c 

>> #!/usr/bin/perl
>> $answer = "yes";
>> $pi = 3.141592654;
>> while ($answer eq "yes") {
>>    print "Input radius of circle ";
>>    $radius = <STDIN>;
>>    (Then it calculates the circumference and prints out the results)
>>    print "Would you like to compute another circumference? ";

>>    $answer = <STDIN>;

>This line should be
> $answer = chop(<STDIN>)

are you sure? :)

(hint:  what does chop() *really* do?)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


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

Date: Tue, 14 Jul 1998 15:50:27 -0400
From: "Adam Graham-Yooll" <agy@macgreg.com>
Subject: Re: HELP: Programming Question
Message-Id: <6ogcpc$rq2$1@client2.news.psi.net>

Are you using "chop" to chop the newline from "$answer = <STDIN>"?





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

Date: 14 Jul 1998 19:40:48 GMT
From: carltjm@mail.auburn.edu (Joseph M Carlton)
Subject: Re: HELP: Programming Question
Message-Id: <6ogc80$9rs$1@ultranews.duc.auburn.edu>


J. Paul Hill (paul.hill@cas-inc.com) wrote:
: With the "while" it executes once.  If I use "while ($answer ne "no")",
: it computes repeatedly.  What am I doing wrong?

: Thanks for your help!


Paul, it is picking up "yes\n" as your input (the return character).  You 
can change your while to while ($answer eq "yes\n") and it will work.

--

Joey Carlton
Senior, Computer Engineering
Auburn University
carltjm@mail.auburn.edu


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

Date: Tue, 14 Jul 1998 15:06:04 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: invoking href="www.mysite.com/cgi-bin/perl_script?$var with out user click
Message-Id: <comdog-ya02408000R1407981506040001@news.panix.com>
Keywords: from just another new york perl hacker

In article <35AB9D92.E9A7EB79@mail.mcoe.k12.ca.us>, Joseph Norris <sirron@mail.mcoe.k12.ca.us> posted:

>I need to invoke an href from my one perl script after I load the $var.
>At this point, I force the user to another screen with this href line
>and make them click on it. Is there any other way?  Thanks.

Javascript and other demons' work will do such things.  Perl doesn't
do that sort of thing.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>
had a demonstration until a few days ago... ;)


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

Date: Tue, 14 Jul 1998 15:25:50 -0400
From: "David Thompson" <domainsource@usa.net>
Subject: IO.pm in which versions?
Message-Id: <6ogb4k$ke2$1@winter.news.erols.com>

I heard that the IO library comes bundled with some releases of Perl
5.... does 5.003 and/or 5.004 included it by default (especially
IO::socket)?  Thanks.

David.





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

Date: Tue, 14 Jul 1998 15:10:12 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Is it possible to create a STAND ALONE EXECUTABLE?
Message-Id: <comdog-ya02408000R1407981510120001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6ofqi6$d73$1@nnrp1.dejanews.com>, mad_ahmad@my-dejanews.com posted:

>I've written this perl program and It's all set.
>i now want to turn it into an executable that's stand alone.
>is that in any way concievable?

well, you could embed the perl interpreter and your program into
a C wrapper if you really wanted to.

some operating systems have support for this sort of thing, but
it's not a universal thing.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


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

Date: 14 Jul 1998 18:16:39 GMT
From: wings <xuchu@iscs.nus.edu.sg>
Subject: newbie question on pattern match
Message-Id: <6og7a7$d4k5@id4.nus.edu.sg>


i am reading "Programming Perl" 2nd edition and when trying to "put commas
in the right places in an integer", the book told me to do this:

	1 while s/(\d)(\d\d\d)(?!\d)/$1,$2/; #P74

it does work but i wonder why my way doesnt work:

	1 while s/(\d)(\d\d\d)([^\d]*)/;

anybody mind telling me the reason?


-- 
wings
------
World is a book, those dont travel read only one page.

Email: xwings@usa.net, xuchu@iscs.nus.edu.sg
ICQ UIN: 1440319
http://gump.iscs.nus.edu.sg


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

Date: Tue, 14 Jul 1998 19:30:52 GMT
From: chapman50@hotmail.com
Subject: Out-Smarting CGI.pm
Message-Id: <6ogblc$i3k$1@nnrp1.dejanews.com>

Hello.

My problem is that when I use CGI.pm (v 2.36) to upload files it loses their
contents. However it does manages to keep track of the data from text fields
and radio buttons etc.

When information is uploaded from a form it is put in a handle known as
STDIN. What CGI.pm does when you create an instance of it is to read this
thing called STDIN and empty the uploaded data from it. This upload data does
infact contain the uploaded file which I can extract myself. I get the
uploaded data using these commands...

    $size = $ENV{'CONTENT_LENGTH'};
    read (STDIN, $data, $size);

However STDIN can only be read once before it becomes empyt. So if I read
from it first, CGI.pm isn't able to find any data in STDIN and if CGI.pm
reads it first then the uploaded file is lost. What I need to know is how to
extract a copy of the data inside STDIN after CGI.pm reads it itself. I've
looked inside CGI.pm but have been uncessful as my knowledge of humongous
object oriented programs is limited. Of course if you know anything about
this I'd love to hear from you.

chris




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


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

Date: Tue, 14 Jul 1998 15:15:19 -0400
From: Eric Chung-Hung Lee <ecl+@andrew.cmu.edu>
Subject: passme
Message-Id: <opeut7a00iWU04n3Y0@andrew.cmu.edu>


________________________________________________

All that pleases is but for a moment.
All that troubles is but for a moment.
Nothing is important save that which is eternal.  
________________________________________________ 


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

Date: Tue, 14 Jul 1998 12:07:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: pattern matching with variables?
Message-Id: <MPG.10154c512dd0631d98970c@nntp.hpl.hp.com>

In article <MPG.1015432ee3a1120398970b@nntp.hpl.hp.com> on Tue, 14 Jul 
1998 11:28:37 -0700, Larry Rosler <lr@hpl.hp.com> says...
> Michael Fox <mike@umcs.maine.edu> says...
> > I'm trying to write a script which involves checking a variable for
> > various patterns.  Something like this:
> > 
> > if ($string =~ /$changing_variable/) {
> > 	...
> > 
> > }
> > 
> > Since $ in a pattern match matches the end of a line, this doesn't work.
> > Does anyone know a way around this?  I've checked the rest of the code by
> > plugging in some constant patterns, but this is really holding me up. A
> > quick reply would be greatly appreciated!

It turns out that what he *really* wanted to do was to substitute the 
contents of $changing_variable into the regex.  As this is automatic, I 
can only assume that "this doesn't work" means that he theorized about it 
instead of actually trying it.

This raises the issues of \Q, \E, quotemeta, /o, eval '...', and why not 
use index() in the first place (assuming $changing_variable is a string 
to be matched literally -- though he *did* say 'various patterns').

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


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

Date: 14 Jul 1998 15:11:40 -0400
From: Dan Schmidt <dfan@harmonixmusic.com>
Subject: Re: pattern matching with variables?
Message-Id: <wkbtqss0wj.fsf@turangalila.harmonixmusic.com>

Michael Fox <mike@umcs.maine.edu> writes:

| I'm trying to write a script which involves checking a variable for
| various patterns.  Something like this:
| 
| if ($string =~ /$changing_variable/) {
| 	...
| }
| 
| Since $ in a pattern match matches the end of a line, this doesn't
| work.

It worked for me.  Did you try it?

| Does anyone know a way around this?  I've checked the rest of the
| code by plugging in some constant patterns, but this is really
| holding me up. A quick reply would be greatly appreciated!

Here's my test code.

====

$string = "foobar";

for $changing_variable ('^f', 'bleh', 'oob', 'oob$') {
  if ($string =~ /$changing_variable/) {
    print "$changing_variable matched on $string\n";
  } else {
    print "$changing_variable didn't match on $string\n";
  }
}

====

^f matched on foobar
bleh didn't match on foobar
oob matched on foobar
oob$ didn't match on foobar

-- 
                 Dan Schmidt -> dfan@harmonixmusic.com, dfan@alum.mit.edu
Honest Bob & the                http://www2.thecia.net/users/dfan/
Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/
          Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/


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

Date: Tue, 14 Jul 1998 10:09:32 +0100
From: Andrew MacInnes <a.g.macinnes@nospam.rl.ac.uk>
Subject: Re: PERL Tutorial
Message-Id: <35AB204A.355BAA5E@nospam.rl.ac.uk>

JLEHMANN wrote:

> Are there any good PERL tutorials on the net?  I've read a good portion
> of The Java Tutorial, which I think is excellent, and it would be great
> if the same thing existed for PERL.
>
> Thanks,
> John


I like the Perl tutorial at http://agora.leeds.ac.uk/Perl/ it goes through
the basics (variables, loops, arrays, filehandling, subroutines and
regexps) and there are tutorials to work on.


This tutorial is available in plain text format on anonymous FTP at
ftp://agora.leeds.ac.uk/scs/doc/. The first file to get is
whole-perl-tutorial.readme which explains what to do about the main file
whole-perl-tutorial.txt.gz.

HTH

Andrew MacInnes

----------------------------------------------------------
- RAL                       E-mail:A.G.MacInnes@rl.ac.uk -
- DCI                  Telephone (direct): (01235)446104 -
- Atlas Building                                         -
- R27 - F31                                  Disclaimer: -
- Chilton, Didcot     These opinions are my own and most -
- Oxon, OX11 0QX      probably not that of my employers. -
----------------------------------------------------------



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

Date: 14 Jul 1998 23:02:08 +0930
From: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: Re: RegExps: Check if string consists of EXACTLY 3 digits ??
Message-Id: <r83ec4o8x3.fsf@asc.sps.mot.com>

lr@hpl.hp.com (Larry Rosler) writes:
> > >I am writing a CGI script which accepts input via QUERY_STRING. 
> > >However, the input is only valid if it consists of EXACTLY 3 DIGITS!  No
> > >more , no less, no other characters in front, after or in between the
> > try
> > 
> >    $string =~ m/^\d{3}(?!\n)$/
> 
> Yes.  The *four* others of us who responded so far are wrong, wrong, 
> wrong, wrong!  The key is here, from perlre:
> 
> $   Match the end of the line (or before newline at the end)

Yeah - this is a real curly isn't it.  It doesn't even tell you what
it will choose to match (the end of the line, or the newline: which?).

It can catch you in all sorts of wierd ways.  

What do you think that this will print (guess before running!)?

  perl -w -e '$a = "zaped\n"; $a =~ s/[a-z]*?(.)$/$1/; print length($a);'

Can you explain the result?

I've been caught by it (in a similar situation to the example above),
and wonder why this quirk was put in, and whether those that put it in
regret it now?  Don't we all chomp our strings when we want them to be
\n free?

Martin.


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

Date: Tue, 14 Jul 1998 19:56:21 GMT
From: Parand Tony Darugar <tdarugar@binevolve.com>
Subject: Survey: Do you also use Tcl or Python?
Message-Id: <35ABB8B0.41085A5D@binevolve.com>

Hello,

  I've noticed recently that a good number of Perl people also
know Tcl, and a good number of Tcl people also know Perl and
Python, and so forhth. I was curious if that's actually 
widespread or a figment  of my imagination.

  If you have 30 seconds and are interested check out
	http://www.binevolve.com/~tdarugar/survey/lang_survey.vet
and mark the languages you know. You can see the results there
also.

Best,
	Tony Darugar
	http://www.binevolve.com/~tdarugar/


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

Date: Fri, 10 Jul 1998 13:11:33 -0400
From: "Michael B. Klein" <michael@kbk.org>
Subject: Re: Trouble with ActiveState - urgent
Message-Id: <6o5hut$pev$1@as4100c.javanet.com>

If you don't need any of ActiveState's 'extras' (PerlIS, PerlScript, or
PerlEx) right away, I would suggest moving to the standard distribution.
Gurusamy Sarathy has created a great binary distribution which is available
from CPAN (complete with libwin32, a bunch of Win32-specific modules), or
you can compile it yourself (it wasn't so hard for me, but depending on your
setup, you might have to make some small configuration tweaks).  You can get
all the ActiveState extras back when Perl 5.005 is released, since the
ActiveState code will be merged in with the standard distribution.

Ulf Wendel wrote in message <35A5C3D1.98157818@kiel.netsurf.de>...
>Hi!
>
>I've lot's of trouble with the ActiveState Perl Version (NT, Build 316).
>I simply can't include any CPAN modules - and my chief is getting
>impatient... The latest error message was: "Can't find loadable object
>in module... " It occurs when I type a simple "use Win32::ODBC;". @INC
>is modified to look in the current working directory for modules.
>Thanks!
>
>Ulf Wendel
>




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

Date: Tue, 14 Jul 1998 15:45:57 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: w3c/CERN directory protection
Message-Id: <comdog-ya02408000R1407981545570001@news.panix.com>
Keywords: from just another new york perl hacker

In article <gLKq1.838$Xt1.3960417@newsr2.u-net.net>, "I.M.Hay" <i.m.hay@man0524.wins.icl.co.uk> posted:

>Tony Curtis wrote in message
>>It's not clear what "one at a time" actually means here.
>>Nor indeed what "user" means.  If you could elaborate...
>
>
>A user is someone using a browser to access the pages. Another user would be
>someone using another browser (probably on another PC) to access the pages.
>By one at a time I mean that once a 'user' has been authenticated only they
>can access the pages, until they stop accessing them - but, of course, you
>can't de-authenticate yourself!

you can de-authenicate yourself by forcing the browser to request
credentials again and causing the transaction to fail.

however, you may look into the various database authentication 
modes available with Apache (and mod_perl).  you could easily
change the passwords or credentials on the fly.  i tend to 
code this sort of thing myself so that i can include an expiration
time after which the user has to re-authenticate or stop using the
service.  mod_perl and DBI are invaluable for this.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


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

Date: 14 Jul 1998 18:59:27 GMT
From: k y n n <NOSPAMkEynOn@panix.comNOSPAM>
Subject: Re: Why the "};" on p.231 of PP (2)?
Message-Id: <6og9qf$5m2@news1.panix.com>

[NB: This is a repost, after correcting a typo of my own.]





Why is there a semicolon after the next-to-last "}" in the code below,
which appears on p. 231 of Programming Perl (2nd ed.)?:

    $blksize = (stat FROM)[11] || 16384; # preferred block size?
    
    while($len = sysread FROM, $buf, $blksize) {
	if(!defined $len) {
	    next if $! =~ /^Interrupted/;
	    die "System read error: $!\n";
	}
	$offset = 0;
	while($len) {           # Handle partial writes.
	    $written = syswrite TO, $buf, $len, $offset;
	    die "System write error: $!\n"
		unless defined $written;
	    $len -= $written;
	    $offset += $written;
	};
    }

Is it just a typo?  Just curious,

K.
-- 
To those who prefer to reply by e-mail, please remove the upper-case
letters from the return address in the header.  Thank you.  K.


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

Date: Tue, 14 Jul 1998 15:07:31 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Why the "};" on p.231 of PP (2)?
Message-Id: <comdog-ya02408000R1407981507310001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6og9qf$5m2@news1.panix.com>, k y n n <NOSPAMkEynOn@panix.comNOSPAM> posted:

>Why is there a semicolon after the next-to-last "}" in the code below,
>which appears on p. 231 of Programming Perl (2nd ed.)?:

>Is it just a typo?  Just curious,

it doesn't have to be there.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


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

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

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