[17183] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4595 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 12 11:10:24 2000

Date: Thu, 12 Oct 2000 08:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <971363412-v9-i4595@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 12 Oct 2000     Volume: 9 Number: 4595

Today's topics:
    Re: regular expression (Rafael Garcia-Suarez)
    Re: regular expression (Logan Shaw)
    Re: regular expression (Logan Shaw)
    Re: regular expression <jylog@netcourrier.com>
    Re: regular expression <bart.lateur@skynet.be>
    Re: regular expression (Clay Irving)
    Re: regular expression (Gary O'Keefe)
    Re: save blob from database <christopher_j@uswest.net>
    Re: Very Newbie Question - Form output to file vs mail <anders@wall.alweb.dk>
        Weekday at a date <ubl@schaffhausen.de>
    Re: What does $++ mean? <ren.maddox@tivoli.com>
    Re: will perl 5 work w/o server on my PC <jeff@vpservices.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 12 Oct 2000 13:09:02 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: regular expression
Message-Id: <slrn8ubeci.2ga.rgarciasuarez@rafael.kazibao.net>

Logan Shaw wrote in comp.lang.perl.misc:
>What you want is:
>
>	s/(word1).*?(word2)/\1my_replacement_string\2/;

Just a word here: perlre states that it's better to avoid \1 in the
right side of s///, and that $1 should be used instead. See why in
perlre.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: 12 Oct 2000 08:09:23 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: regular expression
Message-Id: <8s4d63$1rg$1@provolone.cs.utexas.edu>

In article <8s4cen$p9d$1@reader1.imaginet.fr>,
Laurent <jylog@netcourrier.com> wrote:
>In fact, i want to use the expression in PHP language

O.K., then why are you asking about it in a Perl newsgroup?

>and i translate the
>expression to work under PHP with the ereg_replace function but it seems
>that the expression doesn't work fine
>(i translate the expression in PHP as  "WORD1(.+)?WORD2" . do you know if
>it's correct?)

Oh well, I guess maybe PHP's regular expressions aren't identical to
Perl's, since they're different languages after all.

>for example i have " WORD1 words3 WORD2 words4 WORD1 words5 WORD2 words6"
>it gives me: "WORD1 my_replacement_string WORD2 words6"
>it replaces all the caractere between the first occurs of WORD1 and the LAST
>occurs of WORD2 !!
>
>arg i don't want that...
>i would like :" WORD1 my_replacement_string WORD2 words4 WORD1 words5 WORD2
>words6"

Sounds like PHP's regular expressions (like most languages') are doing
greedy matching.  Perl has an option to do non-greedy matching
instead.  I'm not sure if PHP does or not.  (In fact, I bet it doesn't,
but I could be wrong.)

  - Logan


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

Date: 12 Oct 2000 08:10:30 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: regular expression
Message-Id: <8s4d86$1s7$1@provolone.cs.utexas.edu>

In article <slrn8ubeci.2ga.rgarciasuarez@rafael.kazibao.net>,
Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
>Logan Shaw wrote in comp.lang.perl.misc:
>>What you want is:
>>
>>	s/(word1).*?(word2)/\1my_replacement_string\2/;
>
>Just a word here: perlre states that it's better to avoid \1 in the
>right side of s///, and that $1 should be used instead.

Darn.  I always get that mixed up.  Shows you how much I use
backreferences...

  - Logan


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

Date: Thu, 12 Oct 2000 15:24:49 +0200
From: "Laurent" <jylog@netcourrier.com>
Subject: Re: regular expression
Message-Id: <8s4dft$pgs$1@reader1.imaginet.fr>


>
> O.K., then why are you asking about it in a Perl newsgroup?

well, i don't find the PHP  newsgroup and in the french PHP newsgroup (i'am
french), nobody responds to me :-(
so, i know the regular expression are often used in perl, that's why... :-)

--

laurent




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

Date: Thu, 12 Oct 2000 13:40:06 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: regular expression
Message-Id: <2pfbus4irgtvcjd5ju077f22qmp2gldkui@4ax.com>

Logan Shaw wrote:

>What you want is:
>
>	s/(word1).*?(word2)/\1my_replacement_string\2/;

No: on the RHS \1 and \2 must be $1 and $2, respectively. \1 and \2 are
to be used for backreferences in the LHS only.

-- 
	Bart.


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

Date: 12 Oct 2000 13:49:46 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: regular expression
Message-Id: <slrn8ubgbq.mh3.clay@panix3.panix.com>

On Thu, 12 Oct 2000 14:15:02 +0200, Laurent <jylog@netcourrier.com> wrote:

>i would like to do a regular expression to replace something which is
>between two known words, with a string.

This question is asked so many times that you'd think it would be an FAQ.
Ho! It is:

  How do I find matching/nesting anything?

  This isn't something that can be done in one regular expression, no
  matter how complicated.  To find something between two single
  characters,
[...]

Try:

  perldoc -q find

-- 
Clay Irving <clay@panix.com>
I have two very rare photographs. One is a picture of Houdini locking his
keys in his car. The other is a rare photograph of Norman Rockwell beating 
up a child.
- Steven Wright 


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

Date: Thu, 12 Oct 2000 14:28:22 GMT
From: gokeefe@gssec.bt.co.uk (Gary O'Keefe)
Subject: Re: regular expression
Message-Id: <39e5c057.108800236@news.gssec.bt.co.uk>

On Thu, 12 Oct 2000 14:15:02 +0200, "Laurent" <jylog@netcourrier.com>
wrote:

>i would like to do a regular expression to replace something which is
>between two known words, with a string.

Then read perlfaq6. It came with your perl distro. But I understand:
this is the post-literate, spoon-fed, warning-hot! generation so we
have to make allowances for a spot of reticence when it comes to
reading the docs...

Ha ha!

This is comp.lang.perl.misc and here's the only spoon-feeding you are
likely to get: RTFM stands for Read The Fucking Manual.

>for example, i have: " word1 bla bla bla bla  word2 bla bla bla bla"
>then i want : " world1 my_replacement_string word2 bla bla bla bla"
>
>and only for the first occurs
>for example, i have: " word1 bla bla bla bla  word2 bla bla bla bla word1
>bla bla bla word2"
>then i want to have:" word1 my_replacement_string  word2 bla bla bla bla
>word1 bla bla bla word2"

OK. Moment of weakness time (I'm just too good natured):

s/(.*?word1\s*)\S.*?(\s*?word2.*)/$1my_replacement_string$2/;

>thanks for your help

Don't thank me yet. I ain't done with you by a long way.

Your post was an example of the lazy-arsed nonsense that fills up this
group: poorly presented, inconsistent, requesting help on a truly
trivial aspect and application of the language.

Understand this: the people who post answers to this group genuinely
want to help. They have discovered a progamming language that isn't
just functional, it's expressive. They love the language and all (OK -
maybe just some) of its idiosyncrasies. They want to help you and they
want to share some of the fun they've had with perl, but they also
don't want to end up answering the same questions over and over again.
Which is why a large number of dedicated individuals spent a lot of
their time writing the FAQs. If you post shite like this to the group
then you're being rude to the people that wrote those FAQs and you're
being rude to the people that read and post answers to this group.

This is comp.lang.perl.misc. We'll be fucking rude right back.

Posters replying to a query want something from you; they want to know
you're trying (not just trying their patience). Next time (and I hope
that you continue using perl and there is a next time) you want to:

1. Tell people what docs you've read.

2. Give examples of input and output data (make sure they are
consistent and correct)

3. Show them code you've tried (properly commented and formatted) and
tell them what you think is happening. If possible, write a harness
for the piece of code that you are unclear on.

4. Forget about getting us to do your college assignments.

Even with these trivial guidelines you'll find it's a whole different
world when you post.

Gary
--
Gary O'Keefe
gary@onegoodidea.com
+44 (0) 7976 614 336


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

Date: Thu, 12 Oct 2000 07:58:26 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: save blob from database
Message-Id: <4kkF5.385$tA6.105857@news.uswest.net>


"peter pilsl" <pilsl@goldfisch.atat.at> wrote:
> In article <cp2F5.513$505.197636@news.uswest.net>,
> christopher_j@uswest.net says...
> >
> > Or, you could do it right and use the "Content-Disposition" header
> > line.
> >
> > print "Content-Disposition: attachment; filename=$filename\n";
> > print "Content-type: $contenttype\n\n";
> > ...
> >
>
> yuppie !! ;)
> thats it. thanks a lot.
>
> The solution mentioned by another poster, to use script.pl/filename
> is working on my apacheserver, but leads to a high responsetime when
> downloading ...
>
> I guess, there are still more than the above content-types (maybe one to
> specify the filesize). Can anyone point me to a list/book or just tell me
> the ones he knows.


More than you ever wanted to know about HTTP:
http://www.w3.org/Protocols/rfc2616/rfc2616.html

The Content-Length header field:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13




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

Date: Thu, 12 Oct 2000 16:23:36 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Very Newbie Question - Form output to file vs mail
Message-Id: <yQjF5.11775$UW.322057@news010.worldonline.dk>

Bill Fulbright wrote:
> <FORM ACTION="/bin/script_library/form_handler_file" METHOD=POST>
> 
> and
> 
> <FORM ACTION="/bin/script_library/form_handler_mail" METHOD=POST>
> 
> These are statements I got from Tripod's "Form Handler" script.
> 
> 1.  Are these standard and compatible with Perl 5?

This is HTML, HTTP, CGI standards, but of cause perl handles them - perl 
handles anything...

> 2.  what do I need to do to use this in my own server?

perl
If you mean use the specific files, you need those, and knowledge of how 
the works and what they do.

> I have been asked by my company to build a simple form with output to a
> file, which we will import to Access, etc.

You'd want to look into DBI and DBD::ODBC, and put your data directly into 
your database, or you could use DBI and DBD::CVS to store your data in a 
cvs file which can be imported.

If oyu installed perl5, most of theese will be present, missing modules can 
be found at www.cpan.org fo cause.

> I am using Perl Builder Software with the CGI Wizard, and have looked
> through the help for how to output to file, and have not been able to find
> anything.
> 
> Any help understanding this will be very much appreciated.

Personally, I'll recommend the core perl installation (from cpan), and a 
nice text editor, and I guess it wouldnt hurt you to start a DOS window and 
read through the perl documentation using the perldoc program. Start by 
typing >perldoc perl

-anders
-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Thu, 12 Oct 2000 16:44:29 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Weekday at a date
Message-Id: <39E5CE4D.F2032C0B@schaffhausen.de>

Dies ist eine mehrteilige Nachricht im MIME-Format.
--------------DCBBC8E925A06F4C78339F39
Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D4F5353"
Content-Transfer-Encoding: 7bit

Hi,

I've been looking at the several Date modules provided but I wasnt
able to figure out which one owuld be the right one to use for me,
except probably DATE:Manip and that one states that it shouldnt be
used in applicatons where performance is critical.

My problem is that I need to know which day was on a particular
date. An example problem would be to find out on which day of
the week you were born.

I basically need to implement this function:

sub weekday_of_date(someDate) {
    ...
}

I'am currently working on my own solution for this, but I figure
that it wont be a fast one because it will do a lot computation.

I guess one way to make this faster to let Perl once build a database
of all possible days (Range would be between 1955 and now)
and then access that database instead of doing a computation.

Anyway, maybe someone here knows about a module which solves
this problem or somebody has solved a similar problem before and
has some suggestions on what to do...

Your comments are very appreciated,

malte

--------------DCBBC8E925A06F4C78339F39
Content-Type: text/x-vcard; charset=us-ascii;
 name="ubl.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Visitenkarte fŸr Malte Ubl
Content-Disposition: attachment;
 filename="ubl.vcf"

begin:vcard 
n:Ubl;Malte
tel;cell:+49 173 9237521
tel;fax:+49 4121 472938
tel;home:+49 4121 438297
tel;work:+49 4121 472964
x-mozilla-html:FALSE
url:http://www.schaffhausen.de
org:Schaffhausen | Interactive
adr:;;Daimlerstrasse 17;Elmshorn;;25337;Germany
version:2.1
email;internet:ubl@schaffhausen.de
title:Developer for web-based applications
x-mozilla-cpt:;1
fn:Malte Ubl
end:vcard

--------------DCBBC8E925A06F4C78339F39--



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

Date: 11 Oct 2000 20:30:40 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: What does $++ mean?
Message-Id: <m31yxm6e2n.fsf@dhcp11-177.support.tivoli.com>

vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse) writes:

> On Mon, 9 Oct 2000 11:40:12 -0400,
>                   Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
> 
> >On Mon, 9 Oct 2000, Greg Miller wrote:
> >
> >> 	Even if it's a misprint, it's still incrementing a variable
> >> which hasn't been initialized.
> >
> >Uh, actually, as it is, it's not doing anything because it won't compile.
> >That's what led me to believe that it was a misprint.
> 
> What variable would that be? 

You're just not opening your mind far enough on the concept of
"misprint".  Based on various clues of context and experience, the
intended code is actually:

$|++;

Note that the OP has also verified that the vertical bar was omitted
by his printer, so this is the original code.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Thu, 12 Oct 2000 07:09:46 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: will perl 5 work w/o server on my PC
Message-Id: <39E5C62A.4CAEE745@vpservices.com>

[in the future, please put your response *after* a suitably trimmed
version of what you are responding to, thanks]

ericio wrote:
> 
> i have decided to download apache server from www.apache.org but i noticed
> that it have several option like Java apache, mod_perl, Php. Should i choose
> the mod perl or just download the apache server for Win32???my main purpose
> is to learn CGI using perl script

This is just my $0.02, others may (undoubtedly will) have a different
path to suggest.

Java and PHP are powerful technologies and if you intend to be a long
term professional developer you should possibly eventually include them
in your toolkit but I wouldn't advise trying to learn them at the same
time you learn CGI and Perl.  Mod_Perl is undoubtedly the most
sophisticated way to use Perl in a web environment, but again, since you
are just starting with CGI and Perl, I would recommend not jumping
straight into that unless you already have a gig somewhere that is using
it.

I would recommend that you approach things in this order 1) experiment
with the basics of Perl, plain Perl -- simple scripts that you can run
on the command line that are not CGI, that just do the basics like
parsing text, reading and writing files, other tasks found in books and
tutorials for beginners 2) if you don't already know it, learn and
experiment with plain non-CGI HTML 3) install apache (without Mod_Perl
etc) and experiment with CGI scripts using CGI.pm that you can run in
your browser and integrate with HTML forms 3) more advanced Perl like
database accessing etc. 4) more advanced CGI like multi-part forms etc
5) other advanced server techniques like Mod_Perl. 6) other technologies
like Java.

One of the best things you can do to start out is learn to differentiate
between those different pieces, to know when a problem is an HTML
problem and when it is a Perl problem, to know when something is a web
server issue and when it is a browser or script issue.  So in that
sense, perhaps even before the list above, try to get an overview of how
the client-server model of the web works and of what role the various
software and design tasks play in it.

Good luck!

-- 
Jeff


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4595
**************************************


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