[17055] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4467 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 29 06:10:22 2000

Date: Fri, 29 Sep 2000 03:10:10 -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: <970222210-v9-i4467@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 29 Sep 2000     Volume: 9 Number: 4467

Today's topics:
    Re: OFFTOPIC: Was: Al Gore's Mother Invented Perl (Tony L. Svanstrom)
    Re: OT: Windows 98 / Active Perl / CGI (Tim Hammerquist)
    Re: Perl Regex (Bernard El-Hagin)
    Re: Problem w/ associative arrays (Anno Siegel)
        sending attachments with perl <hugo@fractalgraphics.com.au>
        Some kind of formatted file <ubl@schaffhausen.de>
    Re: Sorting problem nobull@mail.com
    Re: splitting lines with a regex <godzilla@stomp.stomp.tokyo>
    Re: splitting lines with a regex <jeffp@crusoe.net>
    Re: splitting lines with a regex <godzilla@stomp.stomp.tokyo>
    Re: syntax:search and replace <lr@hpl.hp.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 29 Sep 2000 09:51:41 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: OFFTOPIC: Was: Al Gore's Mother Invented Perl
Message-Id: <1ehps5a.t6wghfgelq68N%tony@svanstrom.com>

Uri Guttman <uri@sysarch.com> wrote:

> >>>>> "a" == amonotod  <amonotod@netscape.net> writes:
> 
>   a> Okay, I guess it was... Al Gore is the erstwhile Vice President of
>   a> the United States.  He has made a lot of rather loony comments about
>   a> the Internet, and has taken a lot of (deserved) media heat for them.
> 
> actually he was very misquoted but what else is new in the media. he was
> trying to point out the work he did in converting the net from a NSF (gus
> government) funded thing to a privatized one. he worked on that
> legislation but it came out like he invented the internet. oh, well, once
> that version came out it became gospel.

I don't see why that one stuck, because when I first heard about it it
didn't take that long to figure out what really had happened.

I guess it's one of those "only in America"-thing.


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Fri, 29 Sep 2000 06:38:54 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: OT: Windows 98 / Active Perl / CGI
Message-Id: <slrn8t8f1s.28b.tim@degree.ath.cx>

oi03_2000@my-deja.com <oi03_2000@my-deja.com> wrote:
> Does mod_perl
> work on regular unix machines (because all the work I do on Windows /
> Apache gets moved to production unix box)

Apache was designed for *nix.  Apache and it's perl hybrid are much more
stable on *nix servers.

> The other thing I'm curious about is how the perl/cgi scripts get
> executed.  My script basically gets input from the HTML form and writes
> it to a text file.  I was wondering what happens if the web site gets
> lot of hits approximately at the same time.  How does the cgi script get
> executed (multi/single threaded).  since I'm writing to the same file ,
> is there any chance of some data getting lost.

This is most certainly far from Perl subject, and I would probably give
a faulty answer if I tried to in any great depth.  Simple answers:
1.	The query string (form data given in the URI itself) is passed to
the CGI process as an environment variable ($QUERY_STRING on *nix,
%QUERY_STRING% on Redmondware).
2.	POST data is sent to the CGI process via STDIN.  The script may open
STDIN for reading to get the input, but CGI.pm takes care of this for
you.
3.	Perl startup time is expensive, but that's where mod_perl comes in.
One startup when you start the server.  I do not know about threading
issues in Apache nor mod_perl, but *nix has a nifty feature called
flock() which prevents more than one acces to a file at any one
time.  It may not work with Win98, but it should work on the production
box. I believe this is what you're looking for, no?

Best of luck.

-- 
-Tim Hammerquist <timmy@cpan.org>

I don't have any solution, but I certainly admire the problem.
	-- Ashleigh Brilliant


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

Date: 29 Sep 2000 07:23:37 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Perl Regex
Message-Id: <slrn8t8grm.al8.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 29 Sep 2000 00:12:55 GMT, vlad_the_impaler24@my-deja.com
<vlad_the_impaler24@my-deja.com> wrote:
>In article <8r05bi$hs5$1@nnrp1.deja.com>,
>  vlad_the_impaler24@my-deja.com wrote:
>> Here is my problem, I am working on parsing a logfile, and the logfile
>> ouputs lines that have numbers like
>> 1 2 3
>>
>> I would like to take that and put \ in between the numbers so it ends
>> up being \1\2\3\, the numbers are always different, I would guess I
>> have to use Regex, but I am very new to it, does anyone know off the
>> top of their heads how to do this?

<snipped quoted sig>

>Thanks for your help, but I think I got it worked out, I bought a book
>on regex :), For anyone who cares it is:
>$_ =~ s/([0-9]*) ([0-9]*) ([0-9]*)/\\$1\\$2\\$3\\/;

What if you have more than three numbers? Larry's and Craig's answers
apart from being more efficient give you the added bonus of being
oblivious to the amount of numbers in the input string.

Cheers,
Bernard
--
perl -le 'open JustAnotherPerlHacker,""or$_="B$!e$!r$!n$!a$!r$!d$!";
print split/No such file or directory/;'


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

Date: 29 Sep 2000 09:05:19 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problem w/ associative arrays
Message-Id: <8r1m0f$1kd$1@lublin.zrz.tu-berlin.de>

Abigail <abigail@foad.org> wrote in comp.lang.perl.misc:
>Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDLXXXV
>September MCMXCIII in <URL:news:8qvn9e$ag$1@lublin.zrz.tu-berlin.de>:
>{} 
>{} Setting $[ is *strongly* discouraged.  The feature is still there to
>{} keep elderly scripts happy, but it's no longer used in production code.
>
>
>Elderly scripts that are still around are very much likely to be
>production code. Backwards compatibility isn't remained for your toy
>program you spend 5 minutes at in 1993 and never looked at again -
>it's for keeping production code in production.

Uh, yes.  s/production/newly produced/.

Anno


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

Date: Fri, 29 Sep 2000 17:50:28 +0800
From: Hugo Bouckaert <hugo@fractalgraphics.com.au>
Subject: sending attachments with perl
Message-Id: <39D465E4.F4A82AD1@fractalgraphics.com.au>

Hi 

I am still trying to send attachments with perl which don't appear in
the body of the email. 

In reply to Gwyn's email (who I cannot email directly, it seems) 
I am going to write some more terrible things. By the way, thanks for
the example Gwyn. 

Anyway, after receiving Gwyn's code, I tried to duplicate it as much as
possible in my script, and I am
finding it still does not work, thatis, I cannot get attachments NOT to
reside in the body of the email. 

This is how my code looked like (as much as possible like Gwyn's code
which works): 

At the crucial lines where Gwyn's code has: 

$msg->attach(Type => 'image/gif',
             Data => $data,
              Filename => 'userfriendly.gif'
);

I had to put: 

$msg->attach(Type => 'text/html',
             #Data => $body,
             #Filename => $att
             FH => $att
);

Because I am getting a path + filename from an upload button (as
multipart/form-data) in a html file. Using Filename didn't work - only
the FH and Path options, it seems. Note that I tried to upload both a
gif image as well as text changing to Type 'text/html' Type 'image/gif'
when appropriate - but the type shouldn't matter surely.  

I have the full script pasted in here. If anyone knows why the
attachments still appear in the body of the email, please let me know
(they shouldn't). 

Any help much appreciated. 

Thanks

Hugo 

#!/usr/sbin/perl
#----------------------------------------------------------------------------
# User variables
#----------------------------------------------------------------------------
use Email;
use CGI;
#use CGI qw(:standard);
$query = new CGI;
require Exporter;
use MIME::Lite;

$emailaddress='hugo@fractalgraphics.com.au';
$thankyoupage='http://www.fractalgraphics.com.au/fracviewer/thanks.html';
 
# Test if the forms have been filled in.

if (!$query->param('Email')) {
        &print_page_start;
        &write_form;
        &print_page_end;
        }
else {
        &print_page_start;
        &write_file;
        &print_page_end;        
        &print_refer;
}
sub print_page_start {
        print $query->header;
        print "<html><head><title>Data Conversion
Page</title>\n</head>\n<body>\n";
        print "<h1>Data Conversion page</h1>";
        }
        
sub print_page_end {
        print "</body></html>"
        }
        
sub write_form {
        print "<FORM METHOD=\"POST\" ENCTYPE=\"multipart/form-data\"
ACTION=\"http://www.fractalgraphics.com.au/cgi-bin/upload3.pl\">\n";
        print "<p>Email Address\n";
        print "<INPUT TYPE=\"TEXT\" NAME=\"Email\" SIZE=\"30\"></p>\n";
        print "<p>Name\n";
        print "<INPUT TYPE=\"TEXT\" NAME=\"Name\" SIZE=\"30\"></p>\n";
        print "<p>Company\n";
        print "<INPUT TYPE=\"TEXT\" NAME=\"Company\"
SIZE=\"30\"></p>\n";
        print "<p>File to upload\n";
        print "<INPUT TYPE=\"FILE\" NAME=\"Mdata\" SIZE=\"30\"></p>\n";
        print "<p>Submit\n";
        print "<INPUT TYPE=\"SUBMIT\" VALUE=\"Submit\"></p>";
        print "</FORM><br><br>\n";
        }

sub write_file {

$email= $query->param('Email');
$name = $query->param('Name');
$company = $query->param('Company');
$att = $query->param('Mdata');

$body  = <<MESSAGE_TO_USER;


----------------------------------------------------------------------
          These details were submitted using the WWW Form
            on the Fractal Graphics FracViewer webpage
----------------------------------------------------------------------

Please send information about the requested product to the client's
email address:

Sender's Email: $email
Name:           $name
Company:        $company

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

MESSAGE_TO_USER

my $msg = MIME::Lite->new(
                From => 'info@fractalgraphics.com.au',
                To => 'hugo@fractalgraphics.com.au',
                Subject => 'A new userfriendly image!',
                Type => 'multipart/mixed'
);

$msg->attach(Type => 'TEXT',
      Data => "Attached please find the latest image\n",
);

$msg->attach(Type => 'text/html',
             #Data => $body,
             #Filename => $att
             FH => $att
);

#----------------------------------------------------------------------------

# Generate reply for user

# Send the thankyou page to the submitter ...
print "Location: $thankyoupage\n\n";
}
exit;
 

Gwyn Judd wrote:
> 
> I was shocked! How could Hugo Bouckaert <hugo@fractalgraphics.com.au>
> say such a terrible thing:
> >Hi
> >
> >I have been trying forever now to have a perl script that sends email
> >with attachments not displayed in the body of the email. It just does
> >not want to work!! This is very frustrating.
> 
> >This is virtually identical to what is in perldoc Lite
> >
> >BUT IT DOES NOT WORK! The mail and attachment(s) are sent, but all
> >attachments, including the image, are in the body of the email
> 
> Beats me. Yours looks like it should work to my limited knowledge. Are
> you sure it's not a MUA issue? Some mailers will display any attachments
> that they know about.
> 
> >As I said, an actual working perl script would be most welcome, then I
> >can compare a working version with mine and see what goes wrong. I
> >really don't seem to get this one.
> 
> Here is a "works for me" script that attaches a gif downloaded from a
> site on the internet into a document:
> 
> #!/usr/bin/perl -w
> # get a userfriendly image and mail it
> 
> use LWP::Simple;
> use MIME::Lite;
> use strict;
> 
> my $arg = shift;
> my $debug = 0;
> 
> if (defined $arg && $arg eq '-d')
> {
>     print "setting debug option\n";
>     $debug = 1;
> }
> 
> select STDOUT; $| = 1; # make unbuffered
> select STDERR; $| = 1;
> 
> sub print_mess
> {
>     my $mess = shift or return;
> 
>     print $mess if $debug;
> }
> 
> # get a file
> sub http_get_file
> {
>     my $file = shift;
> 
>     my $data = get $file or die "Could not get $file: $!\n";
> 
>     $data;
> }
> 
> # You can change these according to the image that you want to grab
> my $document = 'http://www.userfriendly.org/static/index.html';
> my $mail_addr = 'gwyn@thislove.dyndns.org';
> 
> my $page = &http_get_file($document);
> 
> # this is the section that parses out the correct URL
> my @link = split /ALT="Latest Strip"/, $page;
> my @getlink = split />/, $link[1];
> my @findlink = split /SRC="/, $getlink[0];
> my @pullend = split /">/, $findlink[1];
> $pullend[0] =~ s/"//;
> my $the_file = $pullend[0];
> 
> &print_mess("file to get looks like $the_file\n");
> 
> my $data = &http_get_file($the_file);
> 
> my $msg = MIME::Lite->new(
>                 From => 'userf@localhost',
>                 To => $mail_addr,
>                 Subject => 'A new userfriendly image!',
>                 Type => 'multipart/mixed'
> );
> 
> $msg->attach(Type => 'TEXT',
>       Data => "Attached please find the latest userfriendly cartoon\n",
> );
> 
> $msg->attach(Type => 'image/gif',
>              Data => $data,
>              Filename => 'userfriendly.gif'
> );
> 
> $msg->send;
> 
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> About all some men accomplish in life is to send a son to Harvard.


-- 
Dr Hugo Bouckaert
R&D Support Engineer, Fractal Graphics 
39 Fairway, Nedlands Western Australia 6009
Tel: 9284 8442
Email:hugo@fractalgraphics.com.au
Web: http://www.fractalgraphics.com.au


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

Date: Fri, 29 Sep 2000 10:00:39 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Some kind of formatted file
Message-Id: <39D44C27.838FE882@schaffhausen.de>

Hi,

does anybody know about a module that enables Perl to write either Word,

Wordperfect, rich text, or some other popular formatted document (not
HTML :-))
based on templates and data from some database or a web form?

Thanx,

malte



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

Date: 29 Sep 2000 08:37:14 +0100
From: nobull@mail.com
Subject: Re: Sorting problem
Message-Id: <u91yy38uji.fsf@wcl-l.bham.ac.uk>

Justin England <jengland@enetis.net> writes:

>    foreach $year ( sort { $data{$::a} <=> $data{$::b} } keys(%data) ) {
> 	foreach $month ( sort { $data{$year}{$::b} <=> $data{$year}{$::a} }
> 		keys(%{$data{$year}})) {

You probably want to sort the keys into numerical order.  To sort the
keys into order you need to be comparing the values of the _keys_, not
the _data_.

foreach my $year ( sort { $a <=> $b } keys(%data) ) {
	foreach my $month ( sort { $b <=> $a }
 		keys(%{$data{$year}})) {

I've removed the redundant :: prefix as it has no effect except to
prevent your code from working if the current package isn't main.

I've also inserted a couple of "my"s.  For clarity of code lexical
variables should always be declared in the smallest possible scope.

> Tel: 605-341-3638			Fax: 605-341-8880

You are missing "+1" in your phone numbers.  This group is not in a
regional hierachy so if you want to quote phone numbers here you
should quote them in full.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 28 Sep 2000 21:22:59 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: splitting lines with a regex
Message-Id: <39D41923.52CCE05D@stomp.stomp.tokyo>

Jeff Pinyan wrote:

> Godzilla! wrote some stuff:
> > Robert Frost wrote better stuff:

(snippage)


My goodness. You write articles even
longer than my own. I must compliment
you for not being fearful of misusing
our English language, extensively, even
at your timid tender age of eighteen.


> Yes, I tested my code, but with a rather special set of 
> data that ended up not showing the error in my code.  
> I present a corrected version.  This even allows for 
> paragraphs to be broken up.

Ahhh so, you have rearned rittle gleen glasshoppa.
Masta Kira reward you growing wrisdom,

"Elder woman eyes lined with wrinkles of wrisdom.
 Young man eyes lined with lust and rittle wrinkles."


Godzilla!


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

Date: Fri, 29 Sep 2000 00:58:52 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: splitting lines with a regex
Message-Id: <Pine.GSO.4.21.0009290049010.5957-100000@crusoe.crusoe.net>

>I must compliment you for not being fearful of misusing our English
>language, extensively, even at your timid tender age of eighteen.
> 
>Ahhh so, you have rearned rittle gleen glasshoppa.
>Masta Kira reward you growing wrisdom,
>
>"Elder woman eyes lined with wrinkles of wrisdom.
> Young man eyes lined with lust and rittle wrinkles."

I must not compliment you for mocking the inability of many Chinese (and
Japanese and Koreans and Vietnamese, for that matter) to pronounce words
in English properly.  For someone so offended by my asking you to dispose
of tiresome anecdotes, you seem to dispense these offensive remarks with
impunity.

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/





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

Date: Thu, 28 Sep 2000 22:20:38 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: splitting lines with a regex
Message-Id: <39D426A6.E421B77A@stomp.stomp.tokyo>

Jeff Pinyan wrote:

> >I must compliment you for not being fearful of misusing our English
> >language, extensively, even at your timid tender age of eighteen.

> >Ahhh so, you have rearned rittle gleen glasshoppa.
> >Masta Kira reward you growing wrisdom,

> >"Elder woman eyes lined with wrinkles of wrisdom.
> > Young man eyes lined with lust and rittle wrinkles."
 
> I must not compliment you for mocking the inability of many Chinese (and
> Japanese and Koreans and Vietnamese, for that matter) to pronounce words
> in English properly.  For someone so offended by my asking you to dispose
> of tiresome anecdotes, you seem to dispense these offensive remarks with
> impunity.


Are you for real? 

Now don't that jist rasp yer daddle! Supposing
this here braying mule done gonna go accusing
me of being one of them thar racist folks fer
making some fun of my own Okie accent.

You are ignorant arsehole Mr. Pinyan.

Kira


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

Date: Fri, 29 Sep 2000 00:05:57 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: syntax:search and replace
Message-Id: <MPG.143ddf33553adb5a98adda@nntp.hpl.hp.com>

In article <39d40156.5195$1c4@news.op.net>, mjd@plover.com says...
> 
> In article <8r0g7l$s1t$1@nnrp1.deja.com>,  <sujh@my-deja.com> wrote:
> >I need to search "production/xml" and replace it
> >with "xmlbuild/production/xml". 
> > $targetline =~ s/production//xml/xmlbuild//production//xml/;
> 
>   $targetline =~ s{production/xml}{xmlbuild/production/xml};

Without redundant typing, hence with less opportunity for error and 
easier to maintain:

    $targetline =~ s{(?=production/xml)}{xmlbuild/};

But also perhaps too advanced for the novice poster, who didn't know how 
to write an escape, and for whom your answer is fine.

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


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

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


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