[9492] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3086 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 7 20:07:21 1998

Date: Tue, 7 Jul 98 17:00:25 -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, 7 Jul 1998     Volume: 8 Number: 3086

Today's topics:
        __Data__ Re: methods to insert/substitute blocks of tex <dtbaker_@flash.net>
        any way to measure sub-seconds? was Re: how long does i <dtbaker_@flash.net>
    Re: Debug ? (brian d foy)
    Re: diff like module or code in perl? <regis.julie@capway.com>
        Directory Names with Perl for NT <jLockard@rwd.com>
    Re: Docs for a2p/walk.c? (Stephen McCamant)
        Form Data & cgi script help clydeyboy@my-dejanews.com
    Re: FREE Shopping Cart jmsmith@iminet.com
    Re: Getting Yesterday's Date jhildeb2@my-dejanews.com
    Re: Getting Yesterday's Date <merlyn@stonehenge.com>
        Help with Form Data manipulation ! clydeyboy@my-dejanews.com
    Re: help with perl install on win95. jhildeb2@my-dejanews.com
        How can I process a data file from the Web? <shargo@students.uiuc.edu>
        manipulate /etc/passwd without expect ?? (Chetan Ahuja)
        new charter and moderator for comp.lang.perl.announce <merlyn@stonehenge.com>
    Re: Oh man, DO I love Perl ! (References to things that <merlyn@stonehenge.com>
        on the fly subs with special tag markers Re: methods to <dtbaker_@flash.net>
    Re: Pattern matching problems <matt@whiterabbit.co.uk>
    Re: Pattern matching problems <merlyn@stonehenge.com>
    Re: question about objects <tchrist@mox.perl.com>
        Question on Win32::Process <stevens@defiant.gsfc.nasa.gov>
    Re: Question on Win32::Process <stevens@defiant.gsfc.nasa.gov>
        removing selected usernames in a passwd file <esor@mnl.sequel.net>
        scalar range - Re: methods to insert/substitute blocks  <dtbaker_@flash.net>
        Text::MetaText Re: methods to insert/substitute blocks  <dtbaker_@flash.net>
        tough regexp - help needed otis@my-dejanews.com
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 07 Jul 1998 17:57:00 -0500
From: Dan Baker <dtbaker_@flash.net>
Subject: __Data__ Re: methods to insert/substitute blocks of text?
Message-Id: <35A2A7BC.109E@flash.net>

F.Quednau wrote:
> 
> Dan Baker wrote:
> >
> > I would like to get some thoughts from the crowd on different methods to
> > substitute blocks of text into templates.
> 
> There must be s...loads of different ways to do this.
> On my webpage there is a script which has the static webstuff stored in the
> __DATA__ entry of the script. It then outputs that together with some
> dynamically generated stuff in the middle. Handy if you want everything to be
> together! Check it out through my sig!
--------

definitely one way, but I am hoping to leave the HTML source as a .htm
file so that it can be viewed and editted by a non-perl person with
regular HTML editors.

Dan




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

Date: Tue, 07 Jul 1998 17:55:09 -0500
From: Dan Baker <dtbaker_@flash.net>
Subject: any way to measure sub-seconds? was Re: how long does it take to execute some code?
Message-Id: <35A2A74D.4B61@flash.net>

I've kinda been wonding about this too.... measuring to the nearest
second sometimes isn't too accurate. Is there anything for better
accuracy? Sometimes you can't build a test loop to repeat 1000x while
testing...


Dan


Larry Rosler wrote:
> 
> In article <6nt5nb$qp2$1@nnrp1.dejanews.com> on Tue, 07 Jul 1998 12:52:59
> GMT, dwiesel@my-dejanews.com <dwiesel@my-dejanews.com> says...
> > How do I find out how long time it takes to execute some code?
> 
> In addition to the suggested use of Benchmark for isolated snippets or
> the Unix time command for entire programs, you can time segments of code
> very simply by inserting statements like this:
> 
> my $t0 = (times)[0]; # Record starting time.
> 
>    # Code segment to be timed...
> 
> my $t1 = (times)[0]; # Record ending time.
> printf "%.2f\n", $t1 - $t0; # The difference is in seconds.
> 
> --
> Larry Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com




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

Date: Tue, 07 Jul 1998 18:06:41 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Debug ?
Message-Id: <comdog-ya02408000R0707981806410001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6nts3r$741$1@nntp2.uunet.ca>, "Teflon" <indy@NOSPAMdemobuilder.com> posted:

>Darren Sweeney wrote in message <6neodv$8lr$1@nnrp4.snfc21.pbi.net>...

>>I have a script which returns the '500 Internal error' message.
>>
>>What is the best way to debug...I have tried telnet perl -c/w but they both
>>tell me the script is OK.

those only catch compile-time things.  you might have errors popping
up at run-time too.

>Try commenting out most of your code until it works, then uncomment sections
>until you get the error.  Then wittle it down to a single line.

i hope you were being facetious - but if you were, you forgot the
smiley.  

CGI.pm has built in debugging stuff.  try running it from the command
line as documented in the module to see if anything interesting
comes up.

besides the tactics i mentioned in TPJ #9 <URL:http://www.tpj.com>, one
might like how i start of some of my CGI scripts (CGI::* tends to make
this annoying):

BEGIN 
   {
   my $old_W = $^W;
   
   $VERSION = '19980703.004';
   
   $^W = 0;
   
   $ENV{'PATH'} = '';

   $debug = 0;

   sub debug
      {
      $debug = 1;
      
      $| = 1;
      
      $My_Module::XYZ::debug = $debug;
      $My_Module::ABC::debug = $debug;
      $My_Module::LMNOP::debug = $debug;
      print "Content-type: text/plain\n\n";
      print "YOU ARE IN DEBUGGING MODE - thanks, the management\n";
      print "This is process $$\nReal user is $<\nEffective user is $>\n";
      print "This is VERSION $VERSION\n\n";
      
      open STDERR, ">&STDOUT";

      $^W = 1;
      }  
      
   debug if $debug or $ENV{'QUERY_STRING'} eq 'd';

   $^W = $old_W unless $debug > 0;
   }



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: Mon, 6 Jul 1998 19:38:59 +0200
From: "Rigis Julii" <regis.julie@capway.com>
Subject: Re: diff like module or code in perl?
Message-Id: <6ntm3q$207$1@minus.oleane.net>


Lenny Bruce Lee a icrit dans le message <35A06D0F.B2BA8CA0@morpheme.com>...
>Does anyone know of a module that implements the unix diff(1) functionality
in perl. It would be check File::compare in Cpan
Bye




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

Date: Tue, 07 Jul 1998 19:28:23 -0400
From: Jeff Lockard <jLockard@rwd.com>
Subject: Directory Names with Perl for NT
Message-Id: <35A2AF16.6F93D0CE@rwd.com>

Hi -

I am trying to write some simple scripts that will recursively move
files and subdirectories from one server to another.  I am not a Perl
expert and have been using the SYSTEM command to shell out to use the
DOS copy, xcopy, and move commands.

The problem that I keep running into is that the folders and files may
have spaces in the names which tend to mess up the DOS commands (even on

NT!).  Long names are fine, but a space causes the DOS commands to fail.

Does anyone know of a Perl module/extension that will allow me to do
this?

Thanks for any help...
Jeff Lockard
RWD Technologies, Inc



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

Date: 7 Jul 1998 22:33:47 GMT
From: stephen@alias-2.pr.mcs.net (Stephen McCamant)
Subject: Re: Docs for a2p/walk.c?
Message-Id: <slrn6q58h3.40t.stephen@alias-2.pr.mcs.net>

On Mon, 06 Jul 1998 04:44:06 GMT,
 Peter J. Farley III <pjfarley@banet.net> wrote:
>OK, I'm reading the source for it assiduously, and some things are
>clear, and some other things are not.  As for why I'm doing it, well
>I'm trying to bring a2p up to gawk 3.0.3 level, fixing the known bugs
>in the process.
>
>Basically, the grammar needs to be re-written in a fairly major way to
>correct the failure to recognize the '>' redirection operator and
>concatenating more than two expressions.  After studying several
>different awk grammars, I believe I understand what needs to be done,
>but I need to be able to translate the existing grammar actions to the
>new grammar, which will have more nodes and slightly different
>structure.  Some of the actions translate quite cleanly, but others do
>not.  I really need to make decisions on structure, like how BEGIN/END
>is handled currently (probably keep), but to do certain changes, I
>need to understand better how walk.c is designed to work.
>
>It would really be a great help, though, if there was *any* sort of
>commentary at all besides the source.  TIA for any info or pointers
>you can provide on this.

I'm afraid that a2p development isn't really going on any more. Judging by
the change log in the perl4 version, the last substantive modification to
walk.c was made in 1992. (The perl5 version has strchr() instead of index(),
some function prototypes, and, coming in 5.005, ANSI function declarations,
but nothing really new).

If you want to work on this, more power to you, but I think the only person
you could ask for insight would be Larry himself.

-- 
____________________________________________________________
Stephen McCamant ======== alias@mcs.com (finger for PGP key)


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

Date: Tue, 07 Jul 1998 22:14:00 GMT
From: clydeyboy@my-dejanews.com
Subject: Form Data & cgi script help
Message-Id: <6nu6j7$e9g$1@nnrp1.dejanews.com>

I have a form that people fill out which upon submit sends the data to a
mailto cgi script.  This script sends the form data via email to me and a
carbon copy to the sender.

The cgi script checks the required fields and makes sure data is entered into
them.  However, I would like this script to go one step further.  I would
like it to check a particular set of fields for duplicate entries.

This set of fields will contain a single number (from 1-15). Each number
should only be used once.  There are 15 entry fields where these numbers will
be entered.  The method of entry is a drop down list with 1 being the
default.  The person using the form will pick one number for each field go to
the next field and do the same until all of the 15 fields are filled out.  I
am trying to use perl to check these 15 fields for duplicates.

One method I wanted to use is to have perl total the fields and compare the
total to 120 (this is the amount they would add up to if each number was used
only once).  If this is true send a happy, you did it type message", if false
send a try it again message.

The hard part is figuring out how to get perl to reference the fields and
realize they are really numbers and not words.	I initially wrote a script
using the form field names and perl did not add them up as numbers. The field
names on the web form are CFpts01 for the first field and so on until
CFpts15.  Perl will not add these when I use them.  I cannot tell it to add
numbers because the numbers are determined by the person entering the form.

I bought the Llama (Learning Perl 2nd edition) book and the Lizard (Perl for
Win32 Systems) book.  I must be a dingus because I cannot figure this out. 
As you can tell I am new at this and realize it is probably a simple solution
for most perl people.  Any help would be appreciated.

Thanks

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


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

Date: Tue, 07 Jul 1998 23:11:34 GMT
From: jmsmith@iminet.com
Subject: Re: FREE Shopping Cart
Message-Id: <6nu9v6$ki2$1@nnrp1.dejanews.com>

In article
<990E072C6BBA588F.A612D7D1A1F4AC1B.32759FE53F179380@library-proxy.airnews.net
>,  "Max Files" <max@idfw.com> wrote:

>


Doesn't look like to me you checked it out at all because there is no file to
download. It sets up automatically. http://www.321website.com shopping cart is
awesome



> I checked this out but didn't find a quick way to download the
> file. Anyway, I found a decent shopping cart program which
> is also free. I haven't had the time to get it fully configured
> yet, but you can't beat the price.
>
> http://www.minivend.com
>
> veronica@iminet.com wrote in message <6ng6m3$pa6$1@nnrp1.dejanews.com>...
> >I found an awesome web-based shopping cart for free.
> >http://www.321website.com
> >
> >-----== Posted via Deja News, The Leader in Internet Discussion ==-----
> >http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum
>
>


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


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

Date: Tue, 07 Jul 1998 21:50:46 GMT
From: jhildeb2@my-dejanews.com
Subject: Re: Getting Yesterday's Date
Message-Id: <6nu57n$bta$1@nnrp1.dejanews.com>

I would suggest using the Date::Manip module.  The DateCalc routine in this
module provides numerous ways to manipulate dates forwards and backwards.

Jim Hildebrand
Novice Perl Programmer

In article <6nu1r9$6le$1@nnrp1.dejanews.com>,
  schumacc@db.erau.edu wrote:
>
> I have a need within a Perl script to get yesterday's date. We are on AIX 4.0
> and I checked the man page for date, but found no option which will return
> yesterday's date. Is there an easy way to do this within Perl or UNIX? I
> thought I could just subtract one from the day, but that quickly becomes more
> complicated than I want to deal with. Any suggestions would be greatly
> appreciated. Could you e-mail me as well as posting any ideas. I don't get to
> read the news group regularly.
>
> TIA,
> Chris Schumacher.
>
>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Chris Schumacher (System Administrator)           E-Mail: schumacc@db.erau.edu
> Embry-Riddle Aeronautical University                 Fax: (904) 226-7000
> 600 S. Clyde Morris Blvd.                          Phone: (904) 226-6449
> Daytona Beach, FL 32114
>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum
>


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


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

Date: Tue, 07 Jul 1998 23:00:57 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Getting Yesterday's Date
Message-Id: <8cww9pi7vq.fsf@gadget.cscaper.com>

>>>>> "schumacc" == schumacc  <schumacc@db.erau.edu> writes:

schumacc> I have a need within a Perl script to get yesterday's
schumacc> date. We are on AIX 4.0 and I checked the man page for date,
schumacc> but found no option which will return yesterday's date. Is
schumacc> there an easy way to do this within Perl or UNIX? I thought
schumacc> I could just subtract one from the day, but that quickly
schumacc> becomes more complicated than I want to deal with. Any
schumacc> suggestions would be greatly appreciated. Could you e-mail
schumacc> me as well as posting any ideas. I don't get to read the
schumacc> news group regularly.

    $yesterday = localtime;
    sleep 86400;
    print "It was $yesterday yesterday\n";

:-)

(Or read the other messages in this thread....)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $22,319.19 collected, $186,159.85 spent; just 55 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Tue, 07 Jul 1998 22:10:35 GMT
From: clydeyboy@my-dejanews.com
Subject: Help with Form Data manipulation !
Message-Id: <6nu6cq$e15$1@nnrp1.dejanews.com>

I have a form that people fill out which upon submit sends the data to a
mailto cgi script.  This script sends the form data via email to me and a
carbon copy to the sender.

The cgi script checks the required fields and makes sure data is entered into
them.  However, I would like this script to go one step further.  I would
like it to check a particular set of fields for duplicate entries.

This set of fields will contain a single number (from 1-15). Each number
should only be used once.  There are 15 entry fields where these numbers will
be entered.  The method of entry is a drop down list with 1 being the
default.  The person using the form will pick one number for each field go to
the next field and do the same until all of the 15 fields are filled out.  I
am trying to use perl to check these 15 fields for duplicates.

Thanks ClydeyBoy

One method I wanted to use is to have perl total the fields and compare the
total to 120 (this is the amount they would add up to if each number was used
only once).  If this is true send a happy, you did it type message", if false
send a try it again message.

The hard part is figuring out how to get perl to reference the fields and
realize they are really numbers and not words.	I initially wrote a script
using the form field names and perl did not add them up as numbers. The field
names on the web form are CFpts01 for the first field and so on until
CFpts15.  Perl will not add these when I use them.  I cannot tell it to add
numbers because the numbers are determined by the person entering the form.

I bougt the Llama (Learning Perl 2nd editon) book and the Lizard (Perl for
Win32 Systems) book.  I must be a dingus because I cannot figure this out. 
As you can tell I am new at this and realize it is probably a simple solution
for most perl people.  Any help would be appreciated.


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


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

Date: Tue, 07 Jul 1998 21:47:47 GMT
From: jhildeb2@my-dejanews.com
Subject: Re: help with perl install on win95.
Message-Id: <6nu523$bni$1@nnrp1.dejanews.com>

It depends somewhat on which version of perl you want to install.  Check the
following links:

http://ring.nacsis.ac.jp/archives/lang/perl/CPAN/ports/win32/Standard/x86/perl5.
00402-bindist04-bc.readme

(you can probably find a closer cpan archive that this one)

http://www.activestate.com/pw32/

(This is ActiveState's version of Perl for win32)

I started using build 316 of ActiveState but I switched to standard release
of perl 5.004.02 as I found that a lot of the replies in this newsgroup
referenced using the perldoc command which didn't seem to be supported by
ActiveState.  One word of warning though, the standard release contains a lot
of good modules but they are not necessarily the latest version.  You should
check the CPAN archives for the latest release of whichever modules you plan
to use.  The readme files included with both versions are quite good and
generally involve running an install.bat file and answering a couple of
simple questions.  They both associate the .pl extention with perl.exe so
that you can execute a perl script but just typing on the full file name
(e.g. 'test.pl' , not just 'test'). When you're starting out, however, it
would be better to run your programs with 'perl -w test.pl' so that you get
the diagnostic messages. The install also modifies the path to include the
bin subdirectory of whereever you elect to install perl to.  Under win95 you
will, of course, need to reboot in order for the new path command in the
autoexec to take effect. I recommend the standard version and starting out
with 'perldoc perldoc' and 'perldoc perl'.  Good luck and happy programming.

Jim Hildebrand
Novice Perl Programmer

In article <01bda961$f680cd00$3c0000c3@goce>,
  "goce" <gdimitroski@lowegroup.com.au> wrote:
>
> Hi i am new to perl i was woundering if there is a step by step
> installation guide to install perl on win95 ??
>
>


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


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

Date: Tue, 7 Jul 1998 18:25:31 -0500
From: I know Alan Wong! <shargo@students.uiuc.edu>
Subject: How can I process a data file from the Web?
Message-Id: <Pine.SOL.3.96.980707182240.2897A-100000@ux10.cso.uiuc.edu>

	I want to be able to process a .dat file from another server, and
I don't know if there's an easy way to do it or not (I expect that there
is). A co-worker suggested LWP; I don't know anything about it, and I
figured a lot of people on this newsgroup have done this before. Any help
would be appreciated. Thanks in advance.

----------------------------------------------------
Peter Shargo shargo@uiuc.edu
"The second thing I thought in the midst of this 
wonderful event was that I wish that I could
take the Pep Band with me for the next month or two 
wherever I go." -President Clinton, U of I Assembly
			Hall, Jan. 28, 1998
----------------------------------------------------



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

Date: 7 Jul 1998 23:20:16 GMT
From: ahuja@argus.cem.msu.edu (Chetan Ahuja)
Subject: manipulate /etc/passwd without expect ??
Message-Id: <6nuafg$8bd$1@msunews.cl.msu.edu>



--
Hi,
  The subject line says it all... (but I'll say it again anyway)
Has anybody figured out a way to allow users to change their 
unix passwords through a perl script ( i.e. running as a cgi script).
The idea of course is that mail users shouldn't need to learn how 
to use telnet (why not..?? but its not for me to ask) but  be able to 
change their passwords through a web interface (what a cliche this phrase
is turning out to be "through a web interface"). I am feeling too lazy to
get Tcl/expect to work and then write a perl script to use expect and 
so on...
 
  I am aware of something called the htpasswd script written in perl
which ( I think) changes the password to the http server.. can it
be modified to change the unix password file... HAs anybody grappled with
this problem before.?? Any help or pointers will be greately appreciated

  Thanks 
  Chetan

P.S. I'll appreciate it if you CC your reply to my email address also...
  


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

Date: Tue, 07 Jul 1998 22:40:58 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: new charter and moderator for comp.lang.perl.announce
Message-Id: <8c4swtjndm.fsf@gadget.cscaper.com>


It has become obvious to me over the past few months that the current
charter for comp.lang.perl.announce, which reads:

    "comp.lang.perl.announce will be a low-volume, moderated group for
    announcements of new releases of perl or its extensions (oraperl,
    sybperl, etc.) and periodic postings related to perl."

is too narrow, and has caused me to either reject worthwhile posts, or
override the charter repeatedly, often with regret.

In discussions over the past few weeks, most people agree that
allowing some degree of commercial advertising would be nice.  The
problem with this is that I have a fairly large commercial interest in
Perl (with my wildly popular books and my company's corporate
trainings), and therefore do not believe that I could be cleanly
objective in administering a charter that permitted announcements for
my potential competitors.  This would result in an awkward conflict of
interest, and I do not need the hassle (social or legal) of that at
this point in my life.

Therefore, I am beginning a short discussion period in
comp.lang.perl.misc to talk about the components of this new charter,
and to look for a new impartial moderator to implement the charter.
Key members of that discussion may be invited to join a mailing list
to hammer out the final details (if necessary), and I'll announce the
results here after that.  I hope the process will not take more than
two weeks or so.

So, what do you think a new charter should permit/deny?  Who do you
think should be moderator?

[followups set to comp.lang.perl.misc]

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Tue, 07 Jul 1998 22:59:14 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Oh man, DO I love Perl ! (References to things that go out of scope)
Message-Id: <8c1zrxjmj2.fsf@gadget.cscaper.com>

>>>>> "John" == John Chambers <jc@ral1.zko.dec.com> writes:

John> In the next edition, they might do well to radically abbreviate this
John> chapter,

You're reading the *radically abbreviated* chapter.  It's basically
the reference stuff from online, cleaned up and polished.

John>  and just refer people to the "Advanced" book.

John> Better to be vague than to pretend to be instructional in a way
John> that alienates most of your prospective users.  Maybe a brief
John> intro to the major points, a few (complete) examples of some
John> small but useful OO modules, and "To learn more about OO
John> programming in perl, see ..."

And except for that last phrase, that's exactly what we did. :-)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $22,319.19 collected, $186,159.85 spent; just 55 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Tue, 07 Jul 1998 18:17:09 -0500
From: Dan Baker <dtbaker_@flash.net>
Subject: on the fly subs with special tag markers Re: methods to insert/substitute blocks of text?
Message-Id: <35A2AC75.3BD8@flash.net>

This is pretty cool,and I think that but changing the tags used I might
even be able to leave the HTML template a working html page. There are a
couple things I'm going to have to read more about! In case anyone wants
to explain a little, I've put my questions below... I'm a novice, so be
patient.  ;)

Dan

Tom Christiansen wrote:
> 
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc,
>     dtbaker_@flash.net writes:
> :I would like to get some thoughts from the crowd on different methods to
> :substitute blocks of text into templates.
> 
> From the Perl Cookbook:
> 
>     To expand only variable references, use this template() function:
> 
>         %fields = (
>                     username => $whats_his_name,
>                     count    => $login_count,
>                     total    => $minute_used,
>         );
> 
>         print template("/home/httpd/templates/simple.template", \%fields);
> 
>     sub template {
>         my ($filename, $fillings) = @_;
---
how can both of these be assigned @_  ? I don't see what happens here,
anyone explain?

>         my $text;
>         local $/;                   # slurp mode (undef)
---
what's this? any suggested reading? i.e. why do we need to worry about
the input record separator, or is that not what it is here?


>         local *F;                   # create local filehandle
>         open(F, "< $filename")      || return;
>         $text = <F>;                # read whole file
>         close(F);                   # ignore retval
---
whups, I got lost here... doesn't reading the the whole file into a
string "lose" the line returns... how will we get them back?


>         # replace quoted words with value in %$fillings hash
>         $text =~ s{ %% ( .*? ) %% }
>                   { exists( $fillings->{$1} )
>                           ? $fillings->{$1}
>                           : ""
>                   }gsex;
---
can someone go slow and explain what each line of this expression does?


>         return $text;
>     }
---
ok, I see that this returns the now-substituted text, and I'm assuming
that since the \n weren't chomped out when the file was read into $text,
that they pop back out when returned. correct?


> 
> On a data file like this
> 
>     <!-- simple.template for internal template() function -->
>     <HTML><HEAD><TITLE>Report for %%username%%</TITLE></HEAD>
>     <BODY><H1>Report for %%username%%</H1>
>     %%username%% logged in %%count%% times, for a total of %%total%% minutes.
> 
> --tom
> --
> The human mind ordinarily operates at only ten percent of its capacity
> --the rest is overhead for the operating system.




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

Date: Tue, 07 Jul 1998 23:47:05 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
To: Ross Mullen <rmullen@mcmail.com>
Subject: Re: Pattern matching problems
Message-Id: <35A2A569.9F587325@whiterabbit.co.uk>

Hi Ross,

I didn't really understand your second question, but in answer to your
first question, you need something like:

if ($string =~ s/.*\s([\w\._\-]+\@[\w_\-]+\.[\w_\-\.]+)\s.*/$1/) {
	print "Your email address is: $string\n";
} else {
	print "No email addresses found!\n";
}


This will turn $email into anything surrounded by two space characters
including an @ somewhere in the middle and one or more full stops
following it.

It matches:

matt-pryor@whiterabbit.co.uk, matt_pryor@white-rabbit.com, 
matt@whiterabbit.co.uk

but not

matt@whiterabbit

Ross Mullen wrote:
> 
> I have a two parts of a program which I am trying to accomplish,
> 
> the first searches any text input by the user for a email address, I
> have wrote it out in theory however in practice it has proved difficult
> to implement. I have been trying to use the pattern matching functions
> to find the @ character and then find the first space before and the
> first after, then create an email hyperlink to the user. But can only
> find references in the manual I have to characters directly
> before/after.
> 
> The second also involves pattern matching, it again reads an input and
> any vowels encountered changes them to another vowel and prints out the
> first change the (whole word with the first character changed) then the
> second change in the whole word and so on. I have set-up a loop to count
> through each position in the string, and then used the substitution
> method to change to a vowel.  However if I miss out the global operator
> on the end it only changes the first occurrence if I leave it in it
> changes all occurrences in one cycle, is it possible to change it on
> every loop cycle.
> 
> If possible I don't want to use any external modules
> 
> Thanks in advance for any advice offered.

-- 
http://www.whiterabbit.co.uk/design


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

Date: Tue, 07 Jul 1998 23:04:27 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Pattern matching problems
Message-Id: <8csokdi7pw.fsf@gadget.cscaper.com>

>>>>> "Matt" == Matt Pryor <matt@whiterabbit.co.uk> writes:

Matt> if ($string =~ s/.*\s([\w\._\-]+\@[\w_\-]+\.[\w_\-\.]+)\s.*/$1/) {
Matt> 	print "Your email address is: $string\n";
Matt> } else {
Matt> 	print "No email addresses found!\n";
Matt> }

This is wrong.   Plain wrong.  For the reasons it is wrong, please
refer to the 42 other times we've discussed it here prior.
(Perhaps you weren't aware of www.dejanews.com?)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $22,319.19 collected, $186,159.85 spent; just 55 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 7 Jul 1998 21:46:49 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: question about objects
Message-Id: <6nu509$sum$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    tye@fohnix.metronet.com (Tye McQueen) writes:
:So I can see where you run into places where they expect code to
:be maintained by people who don't know the language.  It sucks and
:shouldn't happen but I'm sure it happens all too often.  Fight it
:when you can.

That I shall.

Did you intentionally ignore where I showed where using
$_ made code *more* maintainable?

:	print $outfile $_;
:	print $outfile;

Yup, that's annoying.

:It would be really nice to have a specific
:warning that you could turn on [not part of B<-w> nor C<use strict>
:but perhaps something like C<use strict "implied">] that would
:tell you when you've implied an argument so you could make code
:maximally maintainable or just temporarilly turn it on to look
:for spots where C<$_> was assumed because you decided to change
:variable names.  No, I'm not offering a patch at the moment -- my
:plate is full.  Perhaps someone else will be inspired.

I have one of those.   For example:

    #!/usr/bin/perl

    no UnderScore;

    @tests = (
	"Assignment"  => sub { $_ = "Bad" },
	"Reading"     => sub { print }, 
	"Matching"    => sub { $x = /badness/ },
	"Chop"	      => sub { chop },
	"Filetest"    => sub { -x }, 
	"Nesting"     => sub { for (1..3) { print } },
    );


    while ( ($name, $code) = splice(@tests, 0, 2) ) {
	print "Testing $name: ";
	eval { &$code };
	print $@ ? "detected" : "missed!";
	print "\n";
    } 

Of those, the only one that is permitted is the for(), because
it's localizing $_.  The rest get trapped.

    package UnderScore;

    use Carp;

    sub TIESCALAR {
	my $class = shift;
	my $dummy;
	return bless \$dummy => $class;
    } 

    sub FETCH { croak "Read access to \$_ forbidden"  } 
    sub STORE { croak "Write access to \$_ forbidden" } 

    sub unimport { tie($_, __PACKAGE__) }
    sub import { untie $_ } 

    tie($_, __PACKAGE__) unless tied $_;

    1;

--tom
-- 
Real programmers can write assembly code in any language.   :-)  
                --Larry Wall in  <8571@jpl-devvax.JPL.NASA.GOV>


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

Date: Tue, 7 Jul 1998 18:34:06 -0400
From: Joe Stevens <stevens@defiant.gsfc.nasa.gov>
Subject: Question on Win32::Process
Message-Id: <Pine.SUN.3.95.980707182136.11550A-100000@defiant.gsfc.nasa.gov>


I was trying to run the example in the Perl for Win32 "System Module
Extensions" man page for Win32::Process and I keep getting this error:

C:\Temp>perl process.pl
NOTEPAD, C:WINDOWS\NOTEPAD.EXE, C:\Temp
The system cannot find the file specified.
1 at process.pl line 19.

Here is the Perl script. 

==========
#'use' the process module.
use Win32::Process;
#theWin32:: module. Includes the Win32 error checking etc.
# see Win32:: section for included functions.
use Win32;
     
sub Error
{ 
   print Win32::FormatMessage(Win32::GetLastError());
}

$CmdLine = "NOTEPAD";
$AppName = "C:\WINDOWS\\NOTEPAD.EXE";
$CurDir = Win32::GetCwd;

print "$CmdLine, $AppName, $CurDir \n";

#Create the process object.
Win32::Process::Create($ProcessObj,$CmdLine,$AppName,0,DETACHED_PROCESS,$CurDir)
|| die &Error; 

#Set the process priority
$ProcessObj->SetPriorityClass(NORMAL_PRIORITY_CLASS) || die &Error;

#Wait for the process to end. NO timeout 
$ProcessObj->Wait(INFINITE) || die &Error;

$ProcessObj->GetExitCode($ExitCode) || die &Error;
print" Notepad exited with $ExitCode\n";

=======================

I am running the script on Windows95. I get the same message when run it
on NT 4.0. Any ideas as to why this won't work other than the obvious
reasons, like path problems. I have checked for those.

Thanks for any help.

-Joe Stevens-)))--->> URL http://nmsp.gsfc.nasa.gov/~stevens
-----------------------------------------------+
|\ | /\ (<  /\  Goddard Space Flight Center    |
| \|/  \ >)/  \ Ground Systems Hardware Branch |
Code 450/566, Greenbelt, Maryland 20771        |
Email: joe.stevens@gsfc.nasa.gov      :-)      |
Tel: (301) 286-1557   Fax: (301) 286-1724      |
-----------------------------------------------+
  _     
 ___    "Remember the mission."
(- -)   
  ^      
  V      




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

Date: Tue, 7 Jul 1998 18:59:57 -0400
From: Joe Stevens <stevens@defiant.gsfc.nasa.gov>
Subject: Re: Question on Win32::Process
Message-Id: <Pine.SUN.3.95.980707185730.11550B-100000@defiant.gsfc.nasa.gov>

This is pretty embarrassing but I just figured out what went wrong.

The Create method take arguments

Create($proc,$app,$cmdline,...);

versus

Create($proc,$cmdline,$app,...);

That's why I was getting the error message.

time to go home....

Joe

On Tue, 7 Jul 1998, Joe Stevens wrote:

| 
| I was trying to run the example in the Perl for Win32 "System Module
| Extensions" man page for Win32::Process and I keep getting this error:
| 
| C:\Temp>perl process.pl
| NOTEPAD, C:WINDOWS\NOTEPAD.EXE, C:\Temp
| The system cannot find the file specified.
| 1 at process.pl line 19.
| 
| Here is the Perl script. 
| 
| ==========
| #'use' the process module.
| use Win32::Process;
| #theWin32:: module. Includes the Win32 error checking etc.
| # see Win32:: section for included functions.
| use Win32;
|      
| sub Error
| { 
|    print Win32::FormatMessage(Win32::GetLastError());
| }
| 
| $CmdLine = "NOTEPAD";
| $AppName = "C:\WINDOWS\\NOTEPAD.EXE";
| $CurDir = Win32::GetCwd;
| 
| print "$CmdLine, $AppName, $CurDir \n";
| 
| #Create the process object.
| Win32::Process::Create($ProcessObj,$CmdLine,$AppName,0,DETACHED_PROCESS,$CurDir)
| || die &Error; 
| 
| #Set the process priority
| $ProcessObj->SetPriorityClass(NORMAL_PRIORITY_CLASS) || die &Error;
| 
| #Wait for the process to end. NO timeout 
| $ProcessObj->Wait(INFINITE) || die &Error;
| 
| $ProcessObj->GetExitCode($ExitCode) || die &Error;
| print" Notepad exited with $ExitCode\n";
| 
| =======================
| 
| I am running the script on Windows95. I get the same message when run it
| on NT 4.0. Any ideas as to why this won't work other than the obvious
| reasons, like path problems. I have checked for those.
| 
| Thanks for any help.
| 
| -Joe Stevens-)))--->> URL http://nmsp.gsfc.nasa.gov/~stevens
| -----------------------------------------------+
| |\ | /\ (<  /\  Goddard Space Flight Center    |
| | \|/  \ >)/  \ Ground Systems Hardware Branch |
| Code 450/566, Greenbelt, Maryland 20771        |
| Email: joe.stevens@gsfc.nasa.gov      :-)      |
| Tel: (301) 286-1557   Fax: (301) 286-1724      |
| -----------------------------------------------+
|   _     
|  ___    "Remember the mission."
| (- -)   
|   ^      
|   V      
| 
| 
| 
| 

-Joe Stevens-)))--->> URL http://nmsp.gsfc.nasa.gov/~stevens
-----------------------------------------------+
|\ | /\ (<  /\  Goddard Space Flight Center    |
| \|/  \ >)/  \ Ground Systems Hardware Branch |
Code 450/566, Greenbelt, Maryland 20771        |
Email: joe.stevens@gsfc.nasa.gov      :-)      |
Tel: (301) 286-1557   Fax: (301) 286-1724      |
-----------------------------------------------+
  _     
 ___    "Remember the mission."
(- -)   
  ^      
  V      




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

Date: Wed, 08 Jul 1998 07:39:52 +0800
From: "Rosemarie P. San Juan" <esor@mnl.sequel.net>
Subject: removing selected usernames in a passwd file
Message-Id: <35A2B1C7.1A958B60@mnl.sequel.net>

Hi!

     I'm a newbie in perl programming and I  have this problem wherein
I have a file which consists of usernames to be deleted in the passwd
file, my system has a shadow passwd file,  I have started with this one
, butI don't know yet how am going to continue this for usernames
deletion  :

#!/usr/bin/perl

# open tele.txt
open (FILE, "tele.txt")  # opens the filename consists of usernames
@plines1 = <FILE>;
close(FILE);

# backup master.passwd
 system " cp master.passwd master.passwd.bak"

< Don't how to continue .....>

 Please anybody who can help  me how to go with this  ...


Thanks in Advance.

Rose




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

Date: Tue, 07 Jul 1998 18:26:50 -0500
From: Dan Baker <dtbaker_@flash.net>
Subject: scalar range - Re: methods to insert/substitute blocks of text? Re: Finding a string between to known tags?
Message-Id: <35A2AEBA.3FD1@flash.net>

something like this might also work for what I was asking about in Re:
methods to insert/substitute blocks of text? right???

Instead of using a __Data__ section though, I could read in an HTML
file.

Dan


Andre L. wrote:
> 
> In article <35A22CFF.C1E7105B@mesmtp.ericsson.se>, Marcus Spangenberg
> <era.eraspma@mesmtp.ericsson.se> wrote:
> 
> > How do I find a string from a file that is located between a known
> > start-tag and a known end-tag?
> >
> > /Marcus
> 
> You can use the scalar range operator (..) .
> 
> A demo:
> 
> #!/usr/local/bin/perl -w
> 
> while (<DATA>) {
>    $s .= $_ if /^START_TAG$/../^END_TAG$/;
> }
> 
> $s =~ s/(?:START|END)_TAG\n//g; # to remove the tags
> print $s;
> 
> __DATA__
> This is the
> first paragraph.
> START_TAG
> This is the text
> we want.
> END_TAG
> This is a third
> paragraph.
> 
> HTH,
> A.L.



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

Date: Tue, 07 Jul 1998 18:20:40 -0500
From: Dan Baker <dtbaker_@flash.net>
Subject: Text::MetaText Re: methods to insert/substitute blocks of text?
Message-Id: <35A2AD48.57C7@flash.net>

looks like a good possability, I'll have to go read more about it...
Andy, please feel free to expound on the package's many pros and ease of
use for all of our education of course!  ;)




Andy Wardley wrote:
> 
> Dan Baker  <dtbaker_@flash.net> wrote:
> >I would like to get some thoughts from the crowd on different methods to
> >substitute blocks of text into templates.
> 
> There are several templating modules avilable from CPAN.
> 
> >I'd *like* to leave the HTML source page as working source so that
> >non-perl people can edit the basic format of the page (as long as they
> >don't delete start/end tags or whatever is required for substitutions.
> 
> Text::MetaText is probably what you want.
> 
> >Please let me know what modules you think would be best for this sort of
> >substitution work! Also, if you have any simple examples, or tutorial
> >type material online, let me know!
> 
> Check out the documentation which comes as part of the distribution.
> 
>   http://www.perl.com/CPAN/modules/by-module/Text/Text-MetaText-0.19.tar.gz
> 
> As the author of Text::MetaText I'm naturally biased, but you can look in
> the "Features" file in the distribution which talks about some of the pros
> and cons of other templating modules.
> 
> A
> 
> --
> Andy Wardley <abw@kfs.org>   Signature regenerating.  Please remain seated.
>      <abw@cre.canon.co.uk>   For a good time: http://www.kfs.org/~abw/




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

Date: Tue, 07 Jul 1998 22:23:48 GMT
From: otis@my-dejanews.com
Subject: tough regexp - help needed
Message-Id: <6nu75i$fc8$1@nnrp1.dejanews.com>

Hello,

perl regular expression problem :)

        I need to be able to find (and replace) string like these in a text
        file (these are HTML comments embedded in an HTML file):
        <!-- __TOKENA__ -->
        <!-- __TOKENB__ -->
        <!-- prematch __AnyStringHere__ postmatch-->

        so the regexp I was using was this:

        /<!--(.*?)__(.*?)__(.*?)-->/

        This works okay
        (e.g. $1 = "prematch", $2 = "AnyStringHere", $3 = "postmatch")
        until somebody puts other HTML comments in the file.

        So if the file looks like this:

        <!-- This document was created with HomeSite 2.5 -->
        Some Text
        <!-- __TOKENA __ -->

        I will end up with:
        $1 = " This document was created with HomeSite 2.5 --> Some Text <!--
__TOKENA -->"
        $2 = ""
        $3 = ""

        Obviously, this is not what I want....
        Can anyone suggest a better regexp? :)

Thanks!

Otis

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


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

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


Administrivia:

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

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