[24270] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6461 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 25 14:05:41 2004

Date: Sun, 25 Apr 2004 11:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 25 Apr 2004     Volume: 10 Number: 6461

Today's topics:
    Re: does any other language even have this feature? <Juha.Laiho@iki.fi>
    Re: free source guestbook (finished) <Juha.Laiho@iki.fi>
    Re: need a good module. <bik.mido@tiscalinet.it>
        noob question: Trying to extract part of a string in a  (cayenne)
    Re: noob question: Trying to extract part of a string i <jurgenex@hotmail.com>
    Re: noob question: Trying to extract part of a string i <invalid-email@rochester.rr.com>
    Re: noob question: Trying to extract part of a string i <raisin@delete-this-trash.mts.net>
    Re: noob question: Trying to extract part of a string i <gnari@simnet.is>
    Re: noob question: Trying to extract part of a string i <noMail@fmail.com>
    Re: Novice and willing to learn <jurgenex@hotmail.com>
    Re: Object method and file handle creates "bareword" er <lawshouse.public@btconnect.com>
        Perl can't find packages that are there <noel.sant@ntlworld.com>
        Pipe outputs response to browser <e01@removethis.toao.net>
    Re: Pipe outputs response to browser <Joe.Smith@inwap.com>
    Re: Pipe outputs response to browser <me@privacy.net>
    Re: Pipe outputs response to browser <e01@removethis.toao.net>
    Re: Pipe outputs response to browser <jwillmore@remove.adelphia.net>
    Re: Pipe outputs response to browser <e01@removethis.toao.net>
    Re: Please Recommend A Good Perl Book. <jwillmore@remove.adelphia.net>
    Re: slurp not working? ideas please! <geoffacox@dontspamblueyonder.co.uk>
    Re: slurp not working? ideas please! <geoffacox@dontspamblueyonder.co.uk>
    Re: Text-oriented network protocols <Juha.Laiho@iki.fi>
    Re: Using alarm: Timeout to do something else. (Charles DeRykus)
    Re: Why are arrays and hashes this way? <Juha.Laiho@iki.fi>
    Re: Writing dupliactes to database file <Juha.Laiho@iki.fi>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 25 Apr 2004 09:07:59 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: does any other language even have this feature?
Message-Id: <c6dam0$7ku$2@ichaos.ichaos-int>

Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com> said:
>I don't think the OP was talking about heredocs. He mentioned 
>"quote-like operators" which, to me at least, refers to q// and qq// 
>which are different from heredocs. His remark seems to refer to the fact 
>that Perl gives you the option to use your favourite delimiter which is 
>very useful. I don't know of any other languages that offers this.

I guess that the freedom to use your delimiter of choice comes from
'sed', the regex-based stream editor in Unix environments. Even
though sed regexes are commonly written with / as the delimiter,
any delimiter can be used (f.ex. ':' is a good choice when the
patterns contain Unix directory paths -- as long as you can be
certain that the paths never contain ':').

s:/usr/bin:/usr/local/bin:g is so much easier to read than
s/\/usr\/bin/\/usr\/local\/bin/g -- esp. if you have a need to
have the above in a context where backslashes must be escaped,
leaving you with
s/\\/usr\\/bin/\\/usr\\/local\\/bin/g .
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: Sun, 25 Apr 2004 09:07:58 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: free source guestbook (finished)
Message-Id: <c6d8jn$71h$2@ichaos.ichaos-int>

"Robin" <robin @ infusedlight.net> said:
>> You do things at runtime that should be done on installation time. Add
>> to your README that a header file has to exist. It will simplify your
>> script if it can be sure that certain files are there.

Or alternatively, if a header/footer file doesn't exist, just generate
some default header and footer within the program, without ever creating
the files. So, try to read the relevant file, and provide default content
if errors occur.

Btw, the functionality of getheader/getfooter seems so similar that it's
waste to have separate functions for them. Just pass in relevant
parameters and use the returned value. So, combining with the above, you'd
have function "getpart" or something like that, and if that function
returns undef, you could print out a default header/footer/whatever.

The other way would be to require the files to be in place, and emit an
error message if they're not accessible.

Whichever way you choose, don't attempt to write the files from within
your script, and you'll save quite a lot of hassle from your code:
supposing that the users of your script use an editor to edit the
header/footer contents: editors don't lock the files anyway (or at least
you can't universally trust them to), so if you know your program only
reads the files, there's no point in locking them (because concurrent
read access doesn't need locking).

So, from your current design:

does it exist?
- yes, read (locking the file for access) and return (or possibly just print
  out an error and exit)
- no;
  - try to create with default contents (locking for access)
  - read and return (locking for access)
  - and for both cases, possibly print out an error and exit

you change to:
- read (without locking), returning undef if read failed

and in the calling code, depending on your design choice, either:
- if read failed, provide default content
or:
- if read failed, produce an error message

>Although I might add code like
>if (! gethead ($headerfile))
>    {
>    @head = ('<html>', '<body>, 'etc');
>    }
>else
>    {
>    @head = gethead ($headerfile);
>    }

Ouch. First gethead just to determine whether or not the file exists,
and if it did succeed, do it again to actually store the read contents.
So, opening/locking/reading/unlocking/closing the file twice for each
request (if using your original gethead code)? In addition there would
of course be the possible race condition that the header file gets
removed between the two gethead calls; the first call to gethead telling
that the file is there, and thus default content is not needed, and the
second trying to read content from the file that no longer exists.

Also, what's the point of having the head variable as an array instead
of a scalar; anyway you're not editing it in your code, so you an just
slurp it in and spit it out. Using an array for that variable doesn't
make any sense.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: Sun, 25 Apr 2004 11:08:48 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: need a good module.
Message-Id: <fqsm80lgu0el4plclvm4t8khuvl6bhmhjl@4ax.com>

On Fri, 23 Apr 2004 22:34:29 GMT, Uri Guttman <uri@stemsystems.com>
wrote:

>  MD> $uri->kindness->increase_by(10);
>  MD> $uri->elitarism->increase_by(-10);
>
>and i don't think i was being elistist at all. i was just expressing my
>opinion that i am tired of robin who won't listen properly.

It was just my gut feeling. AFAICS I was not the only one... as I said
though I do share at least (a large) part of your opinion about Robin,
or better to say: about what he is repeatedly doing!


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: 25 Apr 2004 08:59:35 -0700
From: chilecayenne@yahoo.com (cayenne)
Subject: noob question: Trying to extract part of a string in a variable to another variable
Message-Id: <2deb3d1.0404250759.7676bbb5@posting.google.com>

Hello all,
I'm a perl noob...and just can't quite figure out how to do something
that should be pretty simple.

Here's an example.

I have $mail_address = 'fred jones <fred_jones@somewhere.com>'

I want to use regular expressions to just parse out the userid here of
fred_jones

I'm trying things like this:

$mail_address =~ /\w+@/;

But, doesn't seem to work. I'm a little hazy on exactly how the =~
works...through examples I've successfully used it for substitutions
like x =~ s/tom/joe/g; but, I'm just wanting to match a regular
expression and extract it to the variable...or even to another
variable leaving $mail_address unchanged.

I've looked in books at the substr() function, but, I don't know how
to use regular expressions to find the offset point, etc.

Can someone give me an example...or pointers to a good reference on
this type of thing?

Thanks in advance,

chilecayenne


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

Date: Sun, 25 Apr 2004 16:27:50 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: noob question: Trying to extract part of a string in a variable to another variable
Message-Id: <aGRic.36511$Aq.12342@nwrddc03.gnilink.net>

cayenne wrote:
> Here's an example.
>
> I have $mail_address = 'fred jones <fred_jones@somewhere.com>'
>
> I want to use regular expressions to just parse out the userid here of
> fred_jones
>
> I'm trying things like this:
>
> $mail_address =~ /\w+@/;
>
> But, doesn't seem to work.

Please define "doesn't seem to work". What exactly do you expect that
statement to do and what do you observe instead? Like, what do you mean by
"parse out"? Do you want to remove the userid from the string? Or do you
want to capture the userid in a different variable?

> I'm a little hazy on exactly how the =~
> works...

It is the binding operator. If used the substitute or match will be applied
to the variable on it's left side instead of to the default $_.

> through examples I've successfully used it for substitutions
> like x =~ s/tom/joe/g; but, I'm just wanting to match a regular
> expression and extract it to the variable...or even to another
> variable leaving $mail_address unchanged.

Well, Perl regular expressions do that automatically. Just use grouping:

my $mail_address = 'fred jones <fred_jones@somewhere.com>';
$mail_address =~ /(\w+)@/;
print $1;

Further details "perldoc perlretut" or for the advanced part "perldoc
perlre"

However, I hope you are aware that '\w' does not even begin to cover the
full set of possible email aliases.
Please see "perldoc -q valid", third paragraph for further information.

> I've looked in books at the substr() function, but, I don't know how
> to use regular expressions to find the offset point, etc.

You don't. You would use index() to find the position of a character or
string in a text.

jue




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

Date: Sun, 25 Apr 2004 16:32:21 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: noob question: Trying to extract part of a string in a variable to another variable
Message-Id: <408BE809.6090607@rochester.rr.com>

cayenne wrote:

 ...


> I have $mail_address = 'fred jones <fred_jones@somewhere.com>'
> 
> I want to use regular expressions to just parse out the userid here of
> fred_jones
 ...


> Can someone give me an example...or pointers to a good reference on
> this type of thing?
 ... 
> chilecayenne
> 

Try:

     my($userid)=$mail_address=~/(\w+)@/;

References:

    perldoc perlre
    perldoc perlretut
    perldoc perlop

The books:  "Learning Perl (3rd edition)", "Programming Perl (3rd 
edition)" and "Mastering Regular Expressions (2nd edition)".

Online:  learn.perl.org, www.perl.com, www.perldoc.com

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Sun, 25 Apr 2004 11:47:10 -0500
From: Web Surfer <raisin@delete-this-trash.mts.net>
Subject: Re: noob question: Trying to extract part of a string in a variable to another variable
Message-Id: <MPG.1af5a7843830fab298980e@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <2deb3d1.0404250759.7676bbb5@posting.google.com>, 
chilecayenne@yahoo.com says...
> Hello all,
> I'm a perl noob...and just can't quite figure out how to do something
> that should be pretty simple.
> 
> Here's an example.
> 
> I have $mail_address = 'fred jones <fred_jones@somewhere.com>'
> 
> I want to use regular expressions to just parse out the userid here of
> fred_jones
> 
> I'm trying things like this:
> 
> $mail_address =~ /\w+@/;
> 
> But, doesn't seem to work. I'm a little hazy on exactly how the =~
> works...through examples I've successfully used it for substitutions
> like x =~ s/tom/joe/g; but, I'm just wanting to match a regular
> expression and extract it to the variable...or even to another
> variable leaving $mail_address unchanged.
> 
> I've looked in books at the substr() function, but, I don't know how
> to use regular expressions to find the offset point, etc.
> 
> Can someone give me an example...or pointers to a good reference on
> this type of thing?
> 
> Thanks in advance,
> 
> chilecayenne
> 


#!/usr/bin/perl -w

use strict;

my ( $mail_address , $userid );

$mail_address = 'fred jones <fred_jones@somewhere.com>';
$mail_address =~ /(\w+)@/;

$userid = $1;

print "Userid = [$userid]\n";

exit 0;


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

Date: Sun, 25 Apr 2004 16:19:51 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: noob question: Trying to extract part of a string in a variable to another variable
Message-Id: <c6goce$lp1$1@news.simnet.is>

"cayenne" <chilecayenne@yahoo.com> wrote in message
news:2deb3d1.0404250759.7676bbb5@posting.google.com...
> I'm trying things like this:
>
> $mail_address =~ /\w+@/;
>
> But, doesn't seem to work.

'doesn't seem to work' does not tell us anything
except that you expected it to do something other
than what it does. many of us have negligent PSI
powers, so it helps us not a lot.

on the other hand, maybe what you want is:

  my ($id)= $mail_address =~ /(\w+)@/;

>
> I've looked in books at the substr() function, but, I don't know how
> to use regular expressions to find the offset point, etc.

>
> Can someone give me an example...or pointers to a good reference on
> this type of thing?


take a look at the perl documentation:
  perldoc perlop
  perldoc perlre

gnari





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

Date: Sun, 25 Apr 2004 18:38:57 +0200
From: Milo Minderbinder <noMail@fmail.com>
Subject: Re: noob question: Trying to extract part of a string in a variable to another variable
Message-Id: <c6gpj2$bsor8$1@ID-231611.news.uni-berlin.de>

cayenne schrieb:
> Hello all,
> I'm a perl noob...and just can't quite figure out how to do something
> that should be pretty simple.
> 
> Here's an example.
> 
> I have $mail_address = 'fred jones <fred_jones@somewhere.com>'
> 
> I want to use regular expressions to just parse out the userid here of
> fred_jones
> 
> I'm trying things like this:
> 
> $mail_address =~ /\w+@/;
> 
> But, doesn't seem to work. I'm a little hazy on exactly how the =~
> works...through examples I've successfully used it for substitutions
> like x =~ s/tom/joe/g; but, I'm just wanting to match a regular
> expression and extract it to the variable...or even to another
> variable leaving $mail_address unchanged.
> 
> I've looked in books at the substr() function, but, I don't know how
> to use regular expressions to find the offset point, etc.
> 
> Can someone give me an example...or pointers to a good reference on
> this type of thing?
> 
> Thanks in advance,
> 
> chilecayenne

Hi,

you have to mark the part you want to get.

$mail_address =~ m/(\w+?)@/;
$name = $1;

Take brackets to mark what you want. You will find the result in $1. If 
you specify more then one part, you will find the second hit in $2. The 
questionsign within the brackets avoids, that you get as much as 
possible into your result (if there two or more @).
Other way to get results is:

my @result = $mail_address =~ m/(\w+?)@/;

In $result[0] you will find then name.

Milo





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

Date: Sun, 25 Apr 2004 09:53:58 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Novice and willing to learn
Message-Id: <WULic.39576$G_.12569@nwrddc02.gnilink.net>

Sherm Pendley wrote:
> Jürgen Exner wrote:
>
>> See "perldoc perl": "What's the difference between "perl" and
>> "Perl"?" last sentence.
>
> I think you mean "perldoc perlfaq1".

No, I did mean the last sentence in the answer to "What's the difference
between "perl" and "Perl"?" which is one of the many answers you get when
querying for "perl".
Of course, the same answer will pop up as part of perlfaq1, too.

> According to the (nearly) last sentence in "perldoc perl", it stands
> for "Pathologically Eclectic Rubbish Lister". For some reason I doubt
> that's what you were referring to... ;-)

Nice one. Fine with me, too. But why is it listed under "bugs"?

jue




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

Date: Sun, 25 Apr 2004 09:39:19 +0100
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: Object method and file handle creates "bareword" error.  How to code?
Message-Id: <30um805ceqkr7bkfl1a8qqd8tjgce9u10f@4ax.com>

On Fri, 23 Apr 2004 23:18:13 +0100, Henry Law <news@lawshouse.org>
wrote:

>I also blundered around with *$xmlout and \*$xmlout with the same
>failure message.  So with your help I've at least cured the syntax
>error and obtained a consistent error message.  Is that progress?

This is getting really odd ... hoping someone can help me understand
this.  I examined the blundering about options more.   This code

open XMLOUT, '>F:\p\xmlout.xml';
my $rc = $fdtwig->print(\*XMLOUT);
unless ($rc) {
	print "\$rc:$rc.\n";
	print "Failed to write modified XML file:$!\n";
}
close XMLOUT;

in which I have split out the return from the "print" method for
inspection, WORKS but produces an error message.  In other words
xmlout.xml is created, with the desired new element in it, but the
return code is a zero-length string (failure) and $! is set.  Here's
the output:

F:\p>perl tryit.pl
$rc:.
Failed to write modified XML file:Bad file descriptor

Can I safely ignore the return value, would you say?  I'd rather not -
what would happen if it *really* failed.

Henry Law       <><     Manchester, England 


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

Date: Sun, 25 Apr 2004 18:57:10 +0100
From: "Noel Sant" <noel.sant@ntlworld.com>
Subject: Perl can't find packages that are there
Message-Id: <rZSic.151$TZ6.142@newsfe2-gui.server.ntli.net>

I run a nightly Perl program which uses WinZip's command-line version
(WZZIP) to archive data that has changed. It is a scheduled job and has been
running fine and ran OK last night (Sat/Sun) at five minutes past midnight.
I am using Windows 2000 and ActivePerl 5.8.0.

I  ran it "manually" to-day (i.e. right-click on the scheduled job icon and
clicked "Run") and got a message:

=============== DOS box ====================================
Can't locate strict.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/lib
 .) a
t D:\Housekeeping\BackupWithZip\Scripts\BackupWithZip.pl line 264.
BEGIN failed--compilation aborted at
D:\Housekeeping\BackupWithZip\Scripts\Backu
pWithZip.pl line 264.
Return code from BackupWithZip was 2
=============== End of DOS box ===============================

Line 264 is "use strict;".

But if I use Windows explorer to look at C:/Perl/lib I can see strict.pm
there!

I've done nothing to Perl to-day. I _have_ used Norton Ghost to create an
image of my C: drive to a disk in a mobile rack, my H: and I: partitions,
and I then removed this hard drive and replaced it with another. My Perl
program writes to the I: drive but it's nowhere near that bit. I've
re-booted but it still happens: before the re-boot it was Carp.pm it was
complaining about, and at "use diagnostics;" on the line following "use
strict;". Carp.pm is also in C:/Perl/lib, plus there's a folder called
"Carp" which contains "Heavy.pm".

My path is:
C:\Perl\bin\;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;"C:\Program
Files\Norton SystemWorks\Norton Ghost\";C:\Program Files\UltraEdit;C:\Batch.
I can't find an environment variable @INC but I assume this is a temporary
one that Perl sets up when it runs.

I just can't imagine what's going on. HELP!

Regards,

    Noel




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

Date: Sun, 25 Apr 2004 08:40:43 GMT
From: "Experienced but Undocumented" <e01@removethis.toao.net>
Subject: Pipe outputs response to browser
Message-Id: <fQKic.8316$en3.4090@edtnps89>

I'm using the following script which outputs the response from the SMTP
server to the browser.  What should I do to make it work silently?  Using
PERL 5.6.1 on Redhat Linux 7.3.
Thanks



open(MAIL, "|/usr/sbin/sendmail -bs") or die "Could not launch Mailer";

print MAIL "HELO LONGLOSTFRIEND\n";
print MAIL "MAIL FROM: $mailfrom\n";
print MAIL "$rcpt_to";
print MAIL "DATA\n";
print MAIL "From: $from\n";
print MAIL "Reply-to: $replyto\n";
print MAIL "Bcc:\n";
print MAIL "Subject: $subject\n";
print MAIL "\n";
print MAIL "$message\n";
print MAIL ".\n";
print MAIL "QUIT\n";

close MAIL;




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

Date: Sun, 25 Apr 2004 09:36:00 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Pipe outputs response to browser
Message-Id: <qDLic.28687$aQ6.1578644@attbi_s51>

Experienced but Undocumented wrote:

> print MAIL "HELO LONGLOSTFRIEND\n";
> print MAIL "MAIL FROM: $mailfrom\n";
> print MAIL "$rcpt_to";
> print MAIL "DATA\n";
> ...
> print MAIL ".\n";
> print MAIL "QUIT\n";

That sort of SMTP dialog is what you send to a socket connected to
TCP port 25.  You do _not_ send that to a pipe to sendmail!

   open(MAIL, "|/usr/sbin/sendmail -oi -t") or die "Could not launch Mailer";
   print MAIL <<EOM;
From: $from
Reply-to: $replyto
Subject: $subject

$message
EOM


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

Date: Sun, 25 Apr 2004 22:34:03 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: Pipe outputs response to browser
Message-Id: <c6g45i$b2shk$1@ID-172104.news.uni-berlin.de>


"Experienced but Undocumented" <e01@removethis.toao.net> wrote in message
news:fQKic.8316$en3.4090@edtnps89...
> I'm using the following script which outputs the response from the SMTP
> server to the browser.  What should I do to make it work silently?  Using
> PERL 5.6.1 on Redhat Linux 7.3.

You're not connecting to a SMTP server, you're connecting to a MTA.






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

Date: Sun, 25 Apr 2004 16:36:18 GMT
From: "Experienced but Undocumented" <e01@removethis.toao.net>
Subject: Re: Pipe outputs response to browser
Message-Id: <6ORic.8792$en3.1375@edtnps89>

"Tintin" <me@privacy.net> wrote
> You're not connecting to a SMTP server, you're connecting to a MTA.


I was curious about that; the admin at my web host told me to do it this way
because I was sending the same message to multiple recipients ("RCPT TO:
<a@b.com>\nRCPT TO: <b@b.com>\nRCPT TO: <c@b.com>\n")

Are there any better ways?  My mailing list is about 100 people and could
potentially grow to 5-600.

Thanks




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

Date: Sun, 25 Apr 2004 13:12:28 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Pipe outputs response to browser
Message-Id: <pan.2004.04.25.17.12.23.66500@remove.adelphia.net>

On Sun, 25 Apr 2004 08:40:43 +0000, Experienced but Undocumented wrote:

> I'm using the following script which outputs the response from the SMTP
> server to the browser.  What should I do to make it work silently?  Using
> PERL 5.6.1 on Redhat Linux 7.3.

[ ...]

Wrap the code in an 'eval'.

---code---
eval{

> open(MAIL, "|/usr/sbin/sendmail -bs") or die "Could not launch Mailer";
> 
> print MAIL "HELO LONGLOSTFRIEND\n";
> print MAIL "MAIL FROM: $mailfrom\n";
> print MAIL "$rcpt_to";
> print MAIL "DATA\n";
> print MAIL "From: $from\n";
> print MAIL "Reply-to: $replyto\n";
> print MAIL "Bcc:\n";
> print MAIL "Subject: $subject\n";
> print MAIL "\n";
> print MAIL "$message\n";
> print MAIL ".\n";
> print MAIL "QUIT\n";
> 
> close MAIL;
};

die "Content-type: text/html\n\nCouldn't send email\n" if $@;

print "Content-type: text/html\n\n Email sent\n";
--end code--

This code is untested and off the top of my head.  I prefer to use the
Net::SMTP, but the idea is still the same.  OTOH, since it's a pipe, it
may still kick something out into '$@', so it *may* not work as expected.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
 Carmel, New York, has an ordinance forbidding men to wear coats 
 and trousers that don't match. 
 


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

Date: Sun, 25 Apr 2004 18:03:03 GMT
From: "Experienced but Undocumented" <e01@removethis.toao.net>
Subject: Re: Pipe outputs response to browser
Message-Id: <r3Tic.9471$en3.3681@edtnps89>

> On Sun, 25 Apr 2004 08:40:43 +0000, Experienced but Undocumented wrote:
>
> > I'm using the following script which outputs the response from the SMTP
> > server to the browser.  What should I do to make it work silently?
Using
> > PERL 5.6.1 on Redhat Linux 7.3.

"James Willmore" <jwillmore@remove.adelphia.net> wrote
> Wrap the code in an 'eval'.

Didn't help I'm afraid but thanks anyway :-)




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

Date: Sun, 25 Apr 2004 12:30:41 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Please Recommend A Good Perl Book.
Message-Id: <pan.2004.04.25.16.30.33.297736@remove.adelphia.net>

On Sat, 24 Apr 2004 16:15:25 +0000, Fred wrote:

> Rating a book is very subjective, I know. I am an expereinced programmer
> but have never used perl. (Got sort of hooked on a2p however... :))
> 
> At any rate, I need a good perl book to cover middle to advanced topics.
> It would have prehaps only 2 pages on control structures. Cover all the
> operators on another page, etc.. Then cover real life topics, date
> processing, using modules, etc.

I have a book recommendation that I don't think has been in the mix
before.  Since you've been hooked on a2p, I take it you want to use Perl
to data munge.  If so, you might want to get yourself a copy of "Data
Munging with Perl" by David Cross (Manning publishing).

It touches upon some of the basics of Perl, but the focus is on how to
take data from one format and convert it into another format (which sed
and awk do).  I can't say it was much use to me, but it may be to someone
starting out (which, I think, was a comment made at Amazon on this book).

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
 What I want is all of the power and none of the responsibility. 
 
 


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

Date: Sun, 25 Apr 2004 17:35:57 GMT
From: Geoff Cox <geoffacox@dontspamblueyonder.co.uk>
Subject: Re: slurp not working? ideas please!
Message-Id: <iktn8057fm2cr7akjkthfriks4ib6ajhu8@4ax.com>

On 25 Apr 2004 04:55:42 GMT, "Tassilo v. Parseval"
<tassilo.parseval@rwth-aachen.de> wrote:

>  package main;
>    use IO::Handle;
>
>    open OUT, ">>results.htm" or die $!;
>    OUT->autoflush(1);

Tassilo,

Sorry for the delay in replying. Have tried above but still get the
wrong order!

Cheers

Geoff



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

Date: Sun, 25 Apr 2004 17:40:21 GMT
From: Geoff Cox <geoffacox@dontspamblueyonder.co.uk>
Subject: Re: slurp not working? ideas please!
Message-Id: <dstn809v84bfjqpamsepclh9o3g7m6ri5k@4ax.com>

On Sun, 25 Apr 2004 00:03:12 +0900, ko <kuujinbo@hotmail.com> wrote:


>I haven't followed this thread in its entirety, but if you're only 
>interested in a small set of events and doing relatively straightforward 
>parsing as in your example, you can also use regular subroutines to 
>parse the HTML. Something like this:

Keith,

Thanks for the thoughts - will give it a try!

Cheers

Geoff





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

Date: Sun, 25 Apr 2004 09:07:59 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Text-oriented network protocols
Message-Id: <c6d9r4$7ku$1@ichaos.ichaos-int>

Mike Mimic <ppagee@yahoo.com> said:
>I have just read in Programming Perl that Network protocols
>should be text based (ASCII, UTF-8 ...). Why is this
>better than binary data? Would not binary data be more
>compact and so it would require less bandwith?

In case you're concerned about transport speeds, remember that there are
two factors determining speed limits; bandwidth and latency. And as you
mentioned in the later message, what you're planning is a protocol for
a game. Most often these are much more sensitive to latency than to
bandwidth (so, the amount of data transferred is not that great).

As an example, I'm located in Europe, and just tried to ping a host in
the US. With default-sized packets (84 bytes), the average round-trip
time was just under 200 milliseconds. With larger packets (1052 bytes),
the average round-trip time was around 230 milliseconds. My last link
is a residential DSL that in itself seems to be making most of the
difference; pinging the router at my ISP gives me ~21 msecs for default-
sized packets, and ~55 msecs for large packets.

So, effect of packet size depends a lot -- if I was communicating with
someone close by, the latency increase would be huge (multiplying the
round-trip time), but if I was communicating across the Atlantic, the
RTT difference would be about 15% (and this for data amount that is more
than 10 times the original). So, the data throughput for the larger
packets seem to be something like 10 times that of the throughput with
the small packets.

Of course, if your paydata has such huge volume that the volume makes
a bottleneck, by all means do everything you can to reduce that volume.
But as long as the data volume is not an issue, keep the protocol easy
to test and monitor (which most often means text-based).
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: Sun, 25 Apr 2004 16:00:16 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Using alarm: Timeout to do something else.
Message-Id: <HwqHsG.I58@news.boeing.com>

In article <e7774537.0404220727.5c3405b6@posting.google.com>,
Prabh <Prab_kar@hotmail.com> wrote:
>Hello all,
>I need to monitor availability of a webserver for x no. of sec.s and
>trigger
>an alert mechanism after the time elapses and webserver still doesnt
>respond.
>
>Am thinking of using the 'alarm' function to do this, along the lines,
>
>==========================================
>use LWP::Simple ;
>alarm(60) ;
>my $url = head("http://abc.xyz.com") ;
>==========================================
>
>When the webserver doesnt respond after 60 sec.s, I want to shoot off
>a mail to the webadmins that the webserver isnt responding. So, where
>do I get the "at this point 60 sec.s have elapsed and theres no
>reponse from webserver, its ok to send mail now" point.
>
>Paraphrasing the alarm example from the Camel book:
>
>===========================================
>print "Answer in 60 sec.s\n" ;
>alarm(60) ;
>$answer = <STDIN> ;
>$timeleft = alarm(0) ;
>print "You had $timeleft sec.s remaining.\n" ;
>===========================================
>
>I here, where do I print "Hey, 60 sec.s elapsed and you still didnt
>answer. Goodbye." All I get after 60 sec.s is the message "Alarm
>clock". I dont know where its coming from.
>

I seem to recall you can do something like this to
access the underlying agent:

use LWP::Simple qw($ua head);

$ua->timeout(60);
foreach my $url (@list_of_urls) {
   head($url) or send_mail(...);
}

Of course,  head() might fail because of something
other than a timeout but you might want to report 
those problems too.

hth,
--
Charles DeRykus 



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

Date: Sun, 25 Apr 2004 09:07:53 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Why are arrays and hashes this way?
Message-Id: <c5an9m$7ct$1@ichaos.ichaos-int>

fxn@hashref.com (Xavier Noria) said:
>When I introduce references the first thing I mention is that they
>allow us to build nested structures. However, the importance of that
>feature is a consequence of the fact that structures cannot be nested
>themselves.
>
>Does anybody know why structures were designed so that they could just
>hold scalars?

Making guesses:
- space management for structures becomes easier
- allows for more complex data structures - f.ex. to have structures
  A, B and C so that both B and C refer to a single instance of
  structure A (so, if you change something in the 'A' referred to in
  structure 'B', the same change is seen through 'C')

-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: Sun, 25 Apr 2004 09:07:58 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Writing dupliactes to database file
Message-Id: <c6d610$71h$1@ichaos.ichaos-int>

extended@operamail.com (Testor) said:
>I am writing a simple perl script to learn in the process. The script
>is supposed to grab a receipt number from the query-string and write
>it into a file.
 ...
>This works OK though not sure if it's the best way because I'm writing
>duplicate receipt numbers.

Depending on what you're going to do with the file later (i.e. whether
you need that actual file to be in some certain format, or whether you
can utilise another program to extract the file contents for you), it
might not be a bad idea to look at "tied hashes". There the regular
properties of a hash would make sure you don't have duplicates, and
storing the hash contents into the file would be transparent for you.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V10 Issue 6461
***************************************


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