[22508] in Perl-Users-Digest
Perl-Users Digest, Issue: 4729 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 19 09:06:06 2003
Date: Wed, 19 Mar 2003 06:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 19 Mar 2003 Volume: 10 Number: 4729
Today's topics:
Re: Adding Perl library to default OS X Server install <sbour@niaid.nih.gov>
Re: Anyone For Golf? (Resistor Colour Codes) (Jay Tilton)
Re: Anyone For Golf? (Resistor Colour Codes) (Jasper)
Re: Anyone For Golf? (Resistor Colour Codes) (Anno Siegel)
Re: Anyone For Golf? (Resistor Colour Codes) <flavell@mail.cern.ch>
Re: Can I use session Variables in Perl <tore@aursand.no>
Re: Can we integrate PERL into PHP ? <tassilo.parseval@post.rwth-aachen.de>
Re: Cannot get authenticated to Yahoo's SMTP servers wh <aknntp@yahoo.com>
Re: Cannot get authenticated to Yahoo's SMTP servers wh (Tad McClellan)
Data 'thinning' with Perl MySQL (Steve)
Re: Data 'thinning' with Perl MySQL <neil.shadrach@corryn.com>
Re: Data 'thinning' with Perl MySQL <spamfilter@cheiron-it.nl>
Re: Data 'thinning' with Perl MySQL <Jodyman@hotmail.com>
Emacs modules for Perl programming (Jari Aalto+mail.perl)
Re: Find&Replace only in a certain scope <tassilo.parseval@post.rwth-aachen.de>
Re: Find&Replace only in a certain scope (Anno Siegel)
Re: How to create a file in cgi/perl? <programmer@brooknet.co.uk>
Re: Mangled Regular Expressions with '|' Operator <please@no.spam>
Re: new Perl feature request: call into shared libs <nospam-abuse@ilyaz.org>
Re: perl ssh background process <otkinva@yahoo.com>
Prob with socket & perl 5.8.0 <spp@monaco377.com>
Why can not use this regexp to determine the prime? (W.J cnqin )
Re: Why can not use this regexp to determine the prime <dthomson@NOSPAMusers.sf.net>
Re: Why can not use this regexp to determine the prime <NoSpamPleaseButThisIsValid2@gmx.net>
Re: Why can not use this regexp to determine the prime (Tad McClellan)
Re: Why can not use this regexp to determine the prime (Anno Siegel)
Re: Win32 Perl newsgroup? (Helgi Briem)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 19 Mar 2003 08:43:17 -0500
From: Stephan Bour <sbour@niaid.nih.gov>
Subject: Re: Adding Perl library to default OS X Server install
Message-Id: <BA9DDE25.63F3%sbour@niaid.nih.gov>
in article 1fs222m.2f0h2n1kmk0nyN%tony@svanstrom.com, Tony L. Svanstrom at
tony@svanstrom.com wrote on 3/19/03 00:34:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>
>> perl.h is part of a standard Perl installation. Under 10.1.5 it's under
>> /Library/Perl/darwin/CORE/perl.h, though that may have changed.
>
> 10.2.4 (non-server, as if that should matter in this case):
>
> /System/Library/Perl/darwin/auto/Apache/include/modules/perl/mod_perl.h
> /System/Library/Perl/darwin/CORE/perl.h
>
Yes, that's how it is under OS 10.2.4 "client". However, the Server version
doesn't have this lib. As a matter of fact, the ONLY lib in the CORE
directory is libperl.dylib in OS X Server. I'm just wondering whether this
is by design or whether something bad happened during my own installation.
If anybody is running OS X Server 10.2 or later would you let me know
whether you have the standard libs in the CORE directory?
Thank you.
------------------------------
Date: Wed, 19 Mar 2003 08:15:23 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Anyone For Golf? (Resistor Colour Codes)
Message-Id: <3e7825b9.49239512@news.erols.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
: Jasper <jasper@mccrea.demon.co.uk> wrote in comp.lang.perl.misc:
: > #!perl -l
: > print map{.5*index acowdzanlleeueoleyit,/..(..?)/&&$1}@ARGV
: >
: > think this is around 62
:
: None of your solutions interprets the third ring as so many zeroes.
:
: Under Perl 5.8.0, sprintf can do this at little letter cost:
:
: printf "%d%d%0*d", @three_numbers, 0;
:
: The third of @three_numbers gives the number of trailing zeroes. Except
: when the third ring is black, when it prints a zero it shouldn't. I'm
: not that familiar with color code, but by Murphy the third ring *can*
: be black.
Murphy's got your number. Reistors smaller than 100 ohms do exist.
The best I can do with it, bringing in a clue from Benjamin, adds a
lot of characters and looks decidedly anti-golfish. A change of
Jasper's very slick technique shaves two strokes inside the map block.
#!perl
print 0+sprintf"%d%de%d\n",map{/..(..?)/;
acowdzanlleeueoleyit=~$1;"@-"/2}@ARGV
------------------------------
Date: 19 Mar 2003 02:45:06 -0800
From: jasper@mccrea.demon.co.uk (Jasper)
Subject: Re: Anyone For Golf? (Resistor Colour Codes)
Message-Id: <b6891527.0303190245.7840c30e@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<b58489$b3h$1@mamenchi.zrz.TU-Berlin.DE>...
> Jasper <jasper@mccrea.demon.co.uk> wrote in comp.lang.perl.misc:
> > #!perl -l
> > print map{.5*index acowdzanlleeueoleyit,/..(..?)/&&$1}@ARGV
> >
> > think this is around 62
>
> None of your solutions interprets the third ring as so many zeroes.
Ahem. Embarrassment all round.
> Under Perl 5.8.0, sprintf can do this at little letter cost:
>
> printf "%d%d%0*d", @three_numbers, 0;
>
> The third of @three_numbers gives the number of trailing zeroes. Except
> when the third ring is black, when it prints a zero it shouldn't. I'm
> not that familiar with color code, but by Murphy the third ring *can*
> be black.
printf"%d%d0*d",@a,0;
print@a[0,1],0 x$a[2]; (copied from everyone else)
Only one more to get the clean solution. Unless you factor in the
return character, when it's three more.
@a=map{.5*index acowdzanlleeueoleyit,/..(..?)/&&$1}@ARGV;
print@a[0,1],0 x$a[2],$\
That's still an 81.
Jasper
------------------------------
Date: 19 Mar 2003 11:34:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Anyone For Golf? (Resistor Colour Codes)
Message-Id: <b59kkp$g0d$3@mamenchi.zrz.TU-Berlin.DE>
Jasper <jasper@mccrea.demon.co.uk> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> news:<b58489$b3h$1@mamenchi.zrz.TU-Berlin.DE>...
> > Jasper <jasper@mccrea.demon.co.uk> wrote in comp.lang.perl.misc:
> > > #!perl -l
> > > print map{.5*index acowdzanlleeueoleyit,/..(..?)/&&$1}@ARGV
> > >
> > > think this is around 62
> >
> > None of your solutions interprets the third ring as so many zeroes.
>
> Ahem. Embarrassment all round.
>
> > Under Perl 5.8.0, sprintf can do this at little letter cost:
> >
> > printf "%d%d%0*d", @three_numbers, 0;
> >
> > The third of @three_numbers gives the number of trailing zeroes. Except
> > when the third ring is black, when it prints a zero it shouldn't. I'm
> > not that familiar with color code, but by Murphy the third ring *can*
> > be black.
>
> printf"%d%d0*d",@a,0;
> print@a[0,1],0 x$a[2]; (copied from everyone else)
>
> Only one more to get the clean solution. Unless you factor in the
> return character, when it's three more.
They have the same length. You forgot one "%" in the printf format.
But that's not the point.
> @a=map{.5*index acowdzanlleeueoleyit,/..(..?)/&&$1}@ARGV;
> print@a[0,1],0 x$a[2],$\
>
> That's still an 81.
If the printf solution were applicable, you wouldn't need the intermediate
@a:
printf"%d%d%0*d",map{.5*index acowdzanlleeueoleyit,
/..(..?)/&&$1}@ARGV,0;
That's a few characters shorter.
Note that the final "0" is run through the map, but comes out as 0
all the same.
Anno
------------------------------
Date: Wed, 19 Mar 2003 12:53:57 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Anyone For Golf? (Resistor Colour Codes)
Message-Id: <Pine.LNX.4.53.0303191245550.25086@lxplus093.cern.ch>
On Tue, Mar 18, Anno Siegel inscribed on the eternal scroll:
> None of your solutions interprets the third ring as so many zeroes.
Right...
> The third of @three_numbers gives the number of trailing zeroes.
See below
> Except
> when the third ring is black, when it prints a zero it shouldn't. I'm
> not that familiar with color code, but by Murphy the third ring *can*
> be black.
Certainly it can, and in some versions the third ring can be gold or
silver (division by 10 or 100). (Don't confuse that with use of a
fourth ring to denote %age tolerance).
Better to think in terms of multiplying by 10**n , where n can be
zero or negative, than in terms of merely adding zeroes? Then there'd
be no need for "exceptions".
Pity to spoil good golf with pedantry, but there it is. :-}
------------------------------
Date: Tue, 18 Mar 2003 17:10:00 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Can I use session Variables in Perl
Message-Id: <pan.2003.03.18.09.22.42.671784@aursand.no>
On Tue, 18 Mar 2003 10:44:56 +0200, Yurij Nykon wrote:
> How can I install module CGI:Session on Windows OS?
Depends on your Perl distribution. Read the documentation that comes with
the distribution you're using.
> Is this modul intended only for Apache Servers?
No.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: 19 Mar 2003 08:15:26 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Can we integrate PERL into PHP ?
Message-Id: <b598uu$486$1@nets3.rz.RWTH-Aachen.DE>
Subject: Re: Can we integrate PERL into PHP ?
Reading your post, you have the Subject backwards, I think. :-)
Also sprach Sushant:
> I am new to this group. I have some doubts about wether is it
> possible to have PHP modules itegrated with existing Perl made site?
>
> We already have site made with Perl. Now for some new modules,
> which are in PHP, we want to integrate those module in existing Perl
> site.
>
> Is is possible to do so? Is there any documentation available?
You could try Include::PHP as available from the CPAN. Don't exepct this
module to do all your work. According to the docs it can only work with
simple PHP files but this module could at least do _some_ necessary work
for you.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Wed, 19 Mar 2003 03:24:10 -0500
From: AK <aknntp@yahoo.com>
Subject: Re: Cannot get authenticated to Yahoo's SMTP servers while sending mail using Net::SMTP
Message-Id: <ui8g7vkpkeu2vkid19t9hgljlo8bnbuing@4ax.com>
On Wed, 19 Mar 2003 00:54:57 -0500, AK <aknntp@yahoo.com> wrote:
>The next thing I am planning to try this with is Mail::Sender. What's
>the emoticon for "cross your fingers" :-)
Ok, so finally a combination of Mail::Sender and Net::POP3 did the trick.
I can now send/receive Yahoo email with Perl... Yay!!
- AK
--------------
the code
(constructive suggestions/criticism for improvement are always welcome)
--------------
use strict;
use warnings;
use Mail::Sender;
use Net::Pop3;
&doPOP3;
&doSMTP;
# ------------------------------------------------------------------------------
sub doSMTP() {
my $SMTPServer = "smtp.mail.yahoo.com";
my $SMTPUsername = "<username>";
my $SMTPPassword = "<password>";
my $Sender = '<username>@yahoo.com';
my $ReplyTo = '<username>@yahoo.com';
my $Recipient1 = '<whoever@wherever.what>';
my $Subject = "foo";
my $Message = "bar";
print "Attempting SMTP connection...\n";
my $MailSender = new Mail::Sender
{
smtp => $SMTPServer,
auth => 'LOGIN', # yahoo supports 'PLAIN' & 'LOGIN'
authid => $SMTPUsername,
authpwd => $SMTPPassword,
from => $Sender,
to => $Recipient1,
subject => $Subject,
msg => $Message
}
or die "Error > Mail Sender > new: $Mail::Sender::Error\n";
if ($Mail::Sender::Error) { print "*ERROR*
Mail_Sender_Error_new=$Mail::Sender::Error \n" };
$MailSender->Open()
or die "Error > Mail Sender > Open: $Mail::Sender::Error\n";
if ($Mail::Sender::Error) { print "*ERROR*
Mail_Sender_Error_Open=$Mail::Sender::Error \n" };
$MailSender->SendLineEnc($Message)
or die "Error > Mail Sender > SendLineEnc: $Mail::Sender::Error\n";
if ($Mail::Sender::Error) { print "*ERROR*
Mail_Sender_Error_SendLineEnc=$Mail::Sender::Error \n" };
if (!$Mail::Sender::Error) { print "Mail sent Ok!" };
$MailSender->Close(1);
}
# ------------------------------------------------------------------------------
sub doPOP3() {
my $mail_server = "pop.mail.yahoo.com";
my $username = "<username>";
my $password = "<password>";
print "Attempting POP3 connection...\n";
my $pop = Net::POP3->new($mail_server)
or die "Can't open connection to $mail_server : $!\n";
defined ($pop->login($username, $password))
or die "*ERROR* POP3 authentication for $username failed: $!\n";
print "Authenticated $username with POP3!\n";
}
------------------------------
Date: Wed, 19 Mar 2003 06:11:25 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Cannot get authenticated to Yahoo's SMTP servers while sending mail using Net::SMTP
Message-Id: <slrnb7gnjd.3ki.tadmc@magna.augustmail.com>
AK <aknntp@yahoo.com> wrote:
> (constructive suggestions/criticism for improvement are always welcome)
> use strict;
> use warnings;
Good. Very good.
> &doSMTP;
> sub doSMTP() {
There is not much point in declaring a prototype if you are going
to then instruct Perl to ignore the prototype.
Check what the various forms of subroutine calls do at the top of
perlsub.pod. You may also want to see the "Prototypes" section.
I suggest not using prototypes, particularly if you are new to Perl.
You can add _your own_ code to do argument checking if you like:
doSMTP();
sub doSMTP {
die "doSMTP() must be called with no arguments\n" if @_;
> my $SMTPServer = "smtp.mail.yahoo.com";
It is better for maintenance if you use single quotes when possible.
Seeing double quotes says "I am going to use one of the extra things
that double quotes provides" (interpolation and/or backslash escapes).
Why declare that you are going to do something special, only to *not*
do anything special in the actual fact? You are tricking the maintenance
programmer into paying special attention where it is not needed.
> my $SMTPPassword = "<password>";
> my $Sender = '<username>@yahoo.com';
Why not just put them into a hash straightaway rather than putting
them in scalars and later copying them from the scalars to a hash?
my %sender_args = (
authpwd => '<password>',
from => '<username>@yahoo.com'
# ...
);
> my $MailSender = new Mail::Sender
my $MailSender = new Mail::Sender \%sender_args;
> {
> smtp => $SMTPServer,
> auth => 'LOGIN', # yahoo supports 'PLAIN' & 'LOGIN'
> authid => $SMTPUsername,
> authpwd => $SMTPPassword,
> from => $Sender,
> to => $Recipient1,
> subject => $Subject,
> msg => $Message
> }
> or die "Error > Mail Sender > new: $Mail::Sender::Error\n";
^^^^^^
Does this actually work?
Can you get that die() to be evaluated under some circumstance?
From the description of the new()'s return codes in Mail::Sender's docs,
I would think not. You get a "true" when it succeeds and a "true" when
it fails.
You should be testing the return from ref() instead, as shown in the
"EXAMPLES" section of the module's docs.
> $MailSender->Close(1);
^
^
The Close() method does not take an argument.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Mar 2003 02:16:34 -0800
From: ineverlookatthis@yahoo.com (Steve)
Subject: Data 'thinning' with Perl MySQL
Message-Id: <f0d57f86.0303190216.5e215139@posting.google.com>
Dear All
I have a problem which might be of interest:
I have an application based on perl and MySQL that logs data from a
series of instruments, logging interval ranges from minutes to hours
on different instruments. I don't need to keep it all forever but I
need to 'thin' it in a defined way. For example, on data over 1 week
old reduce observations to a max of one record per hour per
instrument, over two weeks old reduce to 1 per 2 hours etc etc. This
would allow me to see recent performance in great detail, provide a
historical record and provide an indefinite archive of sample values.
I cannot come-up with an algorithm that does this in a remotely
elegant way. Either I read everything into an array, thin that and
then rewrite it - I don't like that because I worry about the size of
the array in future developments, or I repeatedly read the table,
delete records, reread the table in a very ugly way - which I presume
to have huge overheads. In particularly I don't want a solution that
depends on being run only once a day or once a week!
This must be a common problem with data gathering programmes but I
have not been able to find a solution that lets MySQL do the work.
Any thoughts or suggestions.
Thanks
Steve
------------------------------
Date: Wed, 19 Mar 2003 11:14:11 +0000
From: Neil Shadrach <neil.shadrach@corryn.com>
Subject: Re: Data 'thinning' with Perl MySQL
Message-Id: <3E785103.1020901@corryn.com>
Steve wrote:
> I have an application based on perl and MySQL that logs data from a
> series of instruments, logging interval ranges from minutes to hours
> on different instruments. I don't need to keep it all forever but I
> need to 'thin' it in a defined way.
Is it an option to mark the data with an expirey time ( or some other value to indicate how long it should be retained ) when it is logged?
------------------------------
Date: Wed, 19 Mar 2003 12:35:42 +0100
From: "Frank Maas" <spamfilter@cheiron-it.nl>
Subject: Re: Data 'thinning' with Perl MySQL
Message-Id: <3e78560f$0$136$e4fe514c@dreader5.news.xs4all.nl>
"Steve" <ineverlookatthis@yahoo.com> schreef in bericht
news:f0d57f86.0303190216.5e215139@posting.google.com...
> Dear All
>
> I have a problem which might be of interest:
>
> I cannot come-up with an algorithm that does this in a remotely
> elegant way. Either I read everything into an array, thin that and
> then rewrite it - I don't like that because I worry about the size of
> the array in future developments, or I repeatedly read the table,
> delete records, reread the table in a very ugly way - which I presume
> to have huge overheads. In particularly I don't want a solution that
> depends on being run only once a day or once a week!
>
> This must be a common problem with data gathering programmes but I
> have not been able to find a solution that lets MySQL do the work.
I doubt that you'll find something reusable as the 'thinning'-method is
rather specific for each goal. What you could do is insert all measure-
ments with an expirydate set to 'NOW() + 7 days' and a recordtype set
to 'measurement'. Also make sure that the entrydate is never equal to
the whole current hour (you might want to programatically set the seconds
to at least '01'. After this insert, use a 'replace' to update a record
with recordtype 'hour_average' with the average of the current hour (set
the timestamp to the current whole hour) and an expirydate set to 'NOW()
+ 14 days'. You can continue this for all thinning you want to do.
Now simply delete all records of which the expirydate lies before NOW().
Where does this leave you: if you do a 'select ... where entrydate <=
enquirydate order by entrydate desc limit 1' you always get the less
thinned result and MySQL does all the work.
On that last note: the standard flame would probably be that this has
nothing especially to do with Perl. Hope this helps though.
--Frank
------------------------------
Date: Wed, 19 Mar 2003 12:53:43 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: Data 'thinning' with Perl MySQL
Message-Id: <rLZda.8832$pK4.780777@newsread1.prod.itd.earthlink.net>
"Steve" <ineverlookatthis@yahoo.com> wrote in message
[snip]
> I have an application based on perl and MySQL that logs data from a
> series of instruments, logging interval ranges from minutes to hours
> on different instruments. I don't need to keep it all forever but I
> need to 'thin' it in a defined way. For example, on data over 1 week
> old reduce observations to a max of one record per hour per
> instrument, over two weeks old reduce to 1 per 2 hours etc etc. This
Could you elaborate on the etc. etc. etc.? Do you want to keep ANY
data after it is two weeks old or for example:
Minutes:
if timestamp > now + 7 and ((min/4) = (min % 4)) delete record
Hours:
if timestamp > now + 7 and ((hour/4) = (hour % 4)) delete record
This would reduce your data by one quarter after 7 days
likewise:
if timestamp > now + 14 and ((min/2) = (min % 2)) delete record
would half your data after 14 days
you determine what your archive detail will be.
> would allow me to see recent performance in great detail, provide a
> historical record and provide an indefinite archive of sample values.
>
> I cannot come-up with an algorithm that does this in a remotely
> elegant way. Either I read everything into an array, thin that and
> then rewrite it - I don't like that because I worry about the size of
> the array in future developments, or I repeatedly read the table,
> delete records, reread the table in a very ugly way - which I presume
> to have huge overheads. In particularly I don't want a solution that
> depends on being run only once a day or once a week!
>
> This must be a common problem with data gathering programmes but I
> have not been able to find a solution that lets MySQL do the work.
>
HTH,
Jody
------------------------------
Date: 19 Mar 2003 10:55:18 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1048071134@rtfm.mit.edu>
Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto <jari.aalto@poboxes.com>
Announcement: "What Emacs lisp modules can help with programming Perl"
Preface
Emacs is your friend if you have to do anything comcerning software
development: It offers plug-in modules, written in Emacs lisp
(elisp) language, that makes all your programmings wishes come
true. Please introduce yourself to Emacs and your programming era
will get a new light.
Where to find Emacs/XEmacs
o Unix:
http://www.gnu.org/software/emacs/emacs.html
http://www.xemacs.org/
o Unix Windows port (for Unix die-hards):
install http://www.cygwin.com/ which includes native Emacs 21.x.
XEmacs port is bundled in XEmacs setup.exe available from
XEmacs site.
o Pure Native Windows port
http://www.gnu.org/software/emacs/windows/ntemacs.html
ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe
o More Emacs resources at
http://tiny-tools.sourceforge.net/ => Emacs resource page
Emacs Perl Modules
Cperl -- Perl programming mode
ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
http://www.perl.com/CPAN-local/misc/emacs/cperl-mode/
<ilya@math.ohio-state.edu> Ilya Zakharevich
CPerl is major mode for editing perl files. Forget the default
`perl-mode' that comes with Emacs, this is much better. Comes
standard in newest Emacs.
TinyPerl -- Perl related utilities
http://tiny-tools.sourceforge.net/
If you ever wonder how to deal with Perl POD pages or how to find
documentation from all perl manpages, this package is for you.
Couple of keystrokes and all the documentaion is in your hands.
o Instant function help: See documentation of `shift', `pop'...
o Show Perl manual pages in *pod* buffer
o Grep through all Perl manpages (.pod)
o Follow POD references e.g. [perlre] to next pod with RETURN
o Coloured pod pages with `font-lock'
o Separate `tiperl-pod-view-mode' for jumping topics and pages
forward and backward in *pod* buffer.
o Update `$VERSION' variable with YYYY.MMDD on save.
o Load source code into Emacs, like Devel::DProf.pm
o Prepare script (version numbering) and Upload it to PAUSE
o Generate autoload STUBS (Devel::SelfStubber) for you
Perl Module (.pm)
TinyIgrep -- Perl Code browsing and easy grepping
[TinyIgrep is included in Tiny Tools Kit]
To grep from all installed Perl modules, define database to
TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
how to set up dattabases for Perl5, Perl4 whatever you have
installed
TinyIgrep calls Igrep.el to to do the search, You can adjust
recursive grep options, set search case sensitivity, add user grep
options etc.
You can find latest `igrep.el' module at
<http://groups.google.com/groups?group=gnu.emacs.sources> The
maintainer is Jefin Rodgers <kevinr@ihs.com>.
TinyCompile -- To Browse grep results in Emacs *compile* buffer
TinyCompile is a minor mode for *compile* buffer from where
you can collapse unwanted lines or shorten file URLs:
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT
-->
cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
file1:NNN: MATCHED TEXT
file1:NNN: MATCHED TEXT
End
------------------------------
Date: 19 Mar 2003 08:15:26 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Find&Replace only in a certain scope
Message-Id: <b598uu$486$2@nets3.rz.RWTH-Aachen.DE>
Also sprach Marek Stepanek:
> On 15.03.2003 23:15 Uhr, in article
> 6g977vg5jfo283mjj316pu93d8b3ais9on@4ax.com, "w i l l" <will@com.yahoo>
> wrote:
>
>> id first look at HTML::TableExtract or HTML::TokeParser to seperate
>> your data from your HTML.
> but my question was not to strip out the HTML of my file. In contrary, like
> that I would cut out my delimiters, which I need for my replace-scope.
>
> Come on, perlers! Is there no means to make an replace only in a certain
> scope ??? ( In my example in a <table> with _keyword_ </table> ) I asked
> this question already in a mailing list and never got an answer ! I have
> already the impression, that this is not possible with perl ...
If course it is possible, but Perl does not have a replace_in_scope()
function so that's what you have to come up yourself. The problem you
are describing isn't as trivial as you think.
It might be necessary to use HTML::Parser for that. Basically you parse
the HTML till you find the part that needs to be replaced, change this
part and write out the new HTML. Every part that needs no changes is
written unchanged. So what you do is parse and re-create the document.
Some other CPAN modules might be of help, too. Just have a look at
http://search.cpan.org/ to gather those that could be useful for a
problem like yours. It can only make your task easier.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 19 Mar 2003 09:27:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Find&Replace only in a certain scope
Message-Id: <b59d5u$ahu$1@mamenchi.zrz.TU-Berlin.DE>
Marek Stepanek <mstep@t-online.de> wrote in comp.lang.perl.misc:
> On 15.03.2003 23:15 Uhr, in article
> 6g977vg5jfo283mjj316pu93d8b3ais9on@4ax.com, "w i l l" <will@com.yahoo>
> wrote:
>
> > id first look at HTML::TableExtract or HTML::TokeParser to seperate
> > your data from your HTML.
> >
> > -w i l l
> >
> >
> > On Sat, 15 Mar 2003 10:44:08 +0100, Marek Stepanek <mstep@t-online.de>
> > wrote:
> >
>
> Thank you Will,
>
>
> but my question was not to strip out the HTML of my file. In contrary, like
> that I would cut out my delimiters, which I need for my replace-scope.
>
> Come on, perlers! Is there no means to make an replace only in a certain
> scope ??? ( In my example in a <table> with _keyword_ </table> ) I asked
> this question already in a mailing list and never got an answer ! I have
> already the impression, that this is not possible with perl ...
Your problem isn't how to limit the effect of a text substitution to
part of a string. That is trivial:
substr( $str, $start, $length) =~ s///;
deals only with the substring and leaves other parts alone. Your
problem is how to find the substring(s) you want to work on. This
is where HTML parsing enters because regex matching just doesn't cut
it.
Anno
------------------------------
Date: Wed, 19 Mar 2003 11:38:29 -0000
From: "programmer" <programmer@brooknet.co.uk>
Subject: Re: How to create a file in cgi/perl?
Message-Id: <b59l8o$3ng$1@pheidippides.axion.bt.co.uk>
"Trond Johansen" <trond@bwsnett.no> wrote in message
news:b57kij$25sts3$1@ID-175630.news.dfncis.de...
> Hi.
>
> I'm a beginner in perl
> I know how to write into a file that allready exist on my server,
> but I don't know the script to write a new file.
>
> I wan't to write a file with variables from a form as ex:
> $date$year.html
> The file should be readable for everyone.
> Anyone who can help me with that little script?
If you're trying to create the file on your ISP's server, you need to make
sure that the containing directory is writable by the CGI user ID.
------------------------------
Date: Wed, 19 Mar 2003 10:31:06 +0000
From: Chris Lowth <please@no.spam>
Subject: Re: Mangled Regular Expressions with '|' Operator
Message-Id: <FHXda.77$j_3.31@newsfep3-gui.server.ntli.net>
Tom Keenan wrote:
>
> System:
> Mac OS X 10.2.4
>
> When I write a Perl script,
> and it contains an alternation operator (|)
> in a regular expression,
> the pattern never seems to match correctly.
>
> For example, the following little script should 'accept' a
> string of 1s and 0s containing an even number of 1s,
> and 'reject' anything else.
> In fact, it 'accepts' ANY string.
>
> #! /usr/bin/perl
> print "Input a string of 1's and 0's: ";
> while (<>){
> chomp;
> if (/^0*|(0*10*10*)*$/){
> print "accepted\n";
> }
> else {print "rejected\n"};
> }
>
> But it works fine if I write it like this:
>
> #! /usr/bin/perl
> print "Input a string of 1's and 0's: ";
> while (<>){
> chomp;
> if (/^(0*10*10*)*$/ || /^0*$/){
> print "accepted\n";
> }
> else {print "rejected\n"};
> }
>
>
> Am I missing some completely obvious problem???
> Is there something strange about the Perl interpreter in OS X?
>
> Tom
Perl not strange - your code wrong - it's a matter or correct placement of
brackets in the regex.
Rewrite the "if" in your first example as
if ( /^(0*|(0*10*10*)*)$/ ) ....
Trouble is that your original example matches
- "^0*" (which matches every possible string)
- or "(0*10*10*)*$"
Chris
--
My real address is: chris at lowth dot sea oh em
Author of "protector" (http://protector.sourceforge.net)
-- OpenSource (free) e-mail virus protection
------------------------------
Date: Wed, 19 Mar 2003 08:50:38 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <b59b0u$17iv$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Matt Taylor
<para@tampabay.rr.com>], who wrote in article <JVQda.1167$M7.131309@twister.tampabay.rr.com>:
> > This the regparam(6) calling convention may cause significant savings
> > even if spill happens.
>
> It might simply because it moves the latency. If the OOOE engine handles it
> well, it could be a win. Anyway, it's moot since nobody (except Watcom)
> supports this.
... from "pure" C. Yes.
If the sufficient need arises, any compiler allows to code the
solution in ASM. The need to interface to such routines from Perl is
not very probable, but if a solution allows this without a big hassle,
why not support such functions anyway? ;-)
> Either I am not following your description or it breaks when $A gets passed
> in esi and $B gets passed in [sp+4] (which is the usual mechanism).
I'm not describing how to do "usual mechanism". I describe a
mechanism which allows simple interface to many input calling
conventions, and moderately complicated (rearranging of args)
interface to an arbitrary calling convention.
Ilya
------------------------------
Date: Wed, 19 Mar 2003 08:20:26 GMT
From: "Bill Sellers" <otkinva@yahoo.com>
Subject: Re: perl ssh background process
Message-Id: <pan.2003.03.19.08.21.04.762980@yahoo.com>
On Tue, 18 Mar 2003 07:11:44 +0000, Omega wrote:
> Respected Group,
>
> I have a problem while executing remote perl script. I use ssh from
> machine A. My perl script reside on Machine B.
> Machine A> ssh -l user machineB 'cd /home/user/cron; ./foo.pl
> 1>/dev/null 2>/dev/null' < /tmp/bar
Try sending the output to a real file. It might tell you something.
------------------------------
Date: Wed, 19 Mar 2003 09:54:32 +0100
From: =?ISO-8859-15?Q?S=E9bastien?= Cottalorda <spp@monaco377.com>
Subject: Prob with socket & perl 5.8.0
Message-Id: <3e78304a$0$7883$626a54ce@news.free.fr>
Hi all,
I encoutered problem using sockets with perl 5.8.0.
Here is my config:
Mandrake 9.0 + Perl 5.8.0
Normaly :
- the server program listen on a TCP port,
- fork when it receive a connexion,
- the son manage the socket with the remote client
* it first receive datas, from the server, ended with "\r" char
and print them on STDOUT,
* According to the presence or not of the end character
it replies "ACK\r" or "NACK\r",
* then the child socket close,
* the son dies.
- the father return listening for new connexions.
The problem is that the father end instead of return listening.
I didn't have this problem with perl 5.6.0 (this program use to run from
many years on that platform).
Any help would be welcomed.
Sebastien
Here is the log I received:
Wed Mar 19 09:23:57 2003 (pid:2634) : Starting server on port 19040
Wed Mar 19 09:24:04 2003 (pid:2634) : My son has pid n° 2635
Wed Mar 19 09:24:04 2003 (pid:2635) : Connexion from 1.0.0.14 on port 3525
Wed Mar 19 09:24:04 2003 (pid:2635) : Reception : FIN_GAC
Wed Mar 19 09:24:04 2003 (pid:2635) : Answer sent : ACK
Wed Mar 19 09:24:04 2003 (pid:2635) : End of transmission
Wed Mar 19 09:24:04 2003 (pid:2635) : FIN_GAC
Wed Mar 19 09:24:04 2003 (pid:2634) : The process 2635 is finished
Wed Mar 19 09:24:04 2003 (pid:2634) : I go listening again ...
Wed Mar 19 09:24:19 2003 (pid:2634) : My son has pid n° 2636
Wed Mar 19 09:24:19 2003 (pid:2636) : Connexion from 1.0.0.14 on port 3528
Wed Mar 19 09:24:19 2003 (pid:2634) : I go listening again ...
Wed Mar 19 09:24:19 2003 (pid:2636) : Reception : FIN_GAC
Wed Mar 19 09:24:19 2003 (pid:2636) : Answer sent : ACK
Wed Mar 19 09:24:19 2003 (pid:2636) : End of transmission
Wed Mar 19 09:24:19 2003 (pid:2636) : FIN_GAC
Wed Mar 19 09:24:19 2003 (pid:2634) : The process 2636 is finished
Wed Mar 19 09:24:19 2003 (pid:2634) : End of Father : Abnormal ....
and Here is the server code:
#!/usr/bin/perl -w
#
use POSIX qw(strftime);
use strict;
use IO::Socket;
use IO::Select;
use POSIX "sys_wait_h";
use POSIX "signal_h";
my $port_recep='19040'; # reception port
my $debug= 9;
my $SOCK_LENGTH = 256;
my $time_out_sending = my $time_out_receiving = 20;
#======== VARIABLES INITIALISATION ==========================
my $PARAM='';
my $start_car = '';
my $end_car = "\r"; # char used to end the transmission
my $pid = 0;
my $phrase = '';
my $data_read = my $data_work = '';
my $client='';
my $iaddr = my $port = '';
my $to_send='';
my $chaine_envoyee='';
my $lance = '';
my @pid=();
#=============== SOCKET CREATION ============================
my $server= IO::Socket::INET->new(LocalPort=> $port_recep,
Type=> SOCK_STREAM,
Reuse=>1,
Listen=>10)
or die "Couln\'t be a tcp server on $port_recep $@\n";
&logmsg("Starting server on port $port_recep\n");
#=======/ SIGNALS INTERCEPTION \============================
$SIG{CHLD} = sub { &REAPER };
#======/ STARTING LISTENING \==============================
my $s=IO::Select->new();
while ($client=$server->accept()) { # waiting for connexions
$pid = fork (); # connexion ==> forking
unless (defined($pid)) {
&logmsg("Impossible to fork: $!");
exit 1;
}
if ($pid == 0){ # **********/ STARTING SON -->
$s->add($client);
$port = $client->peerport();
$iaddr= $client->peerhost();
&logmsg("Connexion from $iaddr on port $port\n");
#------------------------/ Reception \---------------------
if ($data_read = &receive($SOCK_LENGTH)){
$data_read =~ s/$start_car//;
$data_read =~ s/$end_car//;
&logmsg("Reception : $data_read \n");
$to_send="ACK";
}
else {
&logmsg("Reception Problem\n");
$to_send = "NACK";
}
#------------------------/ Answer \------------------------
if (&send($start_car.$to_send.$end_car)){
&logmsg("Answer sent : $to_send\n");
}
else {
&logmsg("Failed sending answer : $to_send \n");
}
#-----------------------/ End of transmission \--------------
&logmsg("End of transmission\n");
$s->remove($client);
$client->autoflush();
close($client); # closing socket
&logmsg("$data_read\n");
exit; # <---- STOPPING SON ************************
}
&logmsg("My son has pid n° $pid\n"); -A
&logmsg("I go listening again ...\n");
}
&logmsg("End of Father : Abnormal ....\n");
close($server); # closing server (normaly never ...)
exit 0;
#======================================================================
# LOG MANAGEMENT
#======================================================================
sub logmsg {
return unless ($debug);
my $phrase = '';
$phrase = scalar localtime(time)." (pid:$$) : ";
$phrase .= (join " ", @_);
print $phrase;
}
#======================================================================
# REAPER
#======================================================================
sub REAPER {
my $process_id = waitpid(-1,&WNOHANG);
return unless ($process_id);
return if ($process_id == -1);
if (WIFEXITED($?)){
&logmsg("The process $process_id is finished\n");
}
elsif (WIFSTOPPED($?)){
&logmsg("The process $process_id has been stopped\n");
}
else {
&logmsg("Death of the Process $process_id\n");
}
my @temp = ();
foreach (@pid){
@temp = (@temp,$_) if ($_ != $process_id);
}
@pid = @temp;
# $SIG{CHLD} = \&REAPER;
}
#===========================================================
# Socket Management
#===========================================================
sub send{
my $a_envoyer=$_[0];
if ($s->can_write($time_out_sending)){
unless ($client->send("$a_envoyer",'')){
&logmsg("Impossible to sent something $!\n");
return;
}
}
else {
&logmsg("Time out sending \n");
return;
}
return 1;
}
sub receive {
my $rec_buf = $_[0];
my $data_read = '';
if ($s->can_read($time_out_receiving)){
unless ($client->recv($data_read,$rec_buf)){
&logmsg("Impossible to receve something $!\n");
return;
}
}
else {
&logmsg("Time out receving \n");
return;
}
return $data_read;
}
------------------------------
Date: 19 Mar 2003 19:23:30 +0800
From: qin@freebsd.lzu.edu.cn (W.J cnqin )
Subject: Why can not use this regexp to determine the prime?
Message-Id: <864r5z1txp.fsf@freebsd.lzu.edu.cn>
I use this regexp to find the prime:
@ARGV = (3..15);
while($count = shift){
$_ = '1' x $count;
print $count,"\n" if ! m/^(11+)+\1$/; #if not match so it is a prime
}
I find this topic with google , But it can not give me a statisfactory answer.
why the regexp must be written as /^(11+)\1+$/ ?
------------------------------
Date: Wed, 19 Mar 2003 22:11:09 +1000
From: Derek Thomson <dthomson@NOSPAMusers.sf.net>
Subject: Re: Why can not use this regexp to determine the prime?
Message-Id: <3e785e87$0$11661$afc38c87@news.optusnet.com.au>
W.J cnqin wrote:
> I use this regexp to find the prime:
>
> @ARGV = (3..15);
>
> while($count = shift){
> $_ = '1' x $count;
> print $count,"\n" if ! m/^(11+)+\1$/; #if not match so it is a prime
> }
>
> I find this topic with google , But it can not give me a statisfactory answer.
>
> why the regexp must be written as /^(11+)\1+$/ ?
>
Because the first case allows *different* matches against the (11+)
pattern to match one or more times, then tries to finish by matching
against the *last* successfully matched string. The second case makes a
match against (11+) *once*, *then* checks if that exact string is
repeated one or more times.
Interesting use of regexes! Where is this taken from, or is it your own
example of craziness? :)
--
Derek.
------------------------------
Date: Wed, 19 Mar 2003 13:30:15 +0100
From: Wolf Behrenhoff <NoSpamPleaseButThisIsValid2@gmx.net>
Subject: Re: Why can not use this regexp to determine the prime?
Message-Id: <3E7862D7.6DC66B03@gmx.net>
"W.J cnqin" wrote:
>
> I use this regexp to find the prime:
>
> @ARGV = (3..15);
>
> while($count = shift){
> $_ = '1' x $count;
> print $count,"\n" if ! m/^(11+)+\1$/; #if not match so it is a prime
> }
>
> I find this topic with google , But it can not give me a statisfactory answer.
>
> why the regexp must be written as /^(11+)\1+$/ ?
For a detailed explanation see
http://montreal.pm.org/tech/neil_kandalgaonkar.shtml
But why do you want to test if a number is prime with a RE?
What about:
sub primeQ($) {
my $input=shift;
return 0 if $input==1;
$input % $_ or return(0) for (2 .. sqrt($input));
1;
}
Surely there are better functions but I'm sure you'll find them with any
search engine.
Wolf
------------------------------
Date: Wed, 19 Mar 2003 06:47:59 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Why can not use this regexp to determine the prime?
Message-Id: <slrnb7gpnv.3nm.tadmc@magna.augustmail.com>
Derek Thomson <dthomson@NOSPAMusers.sf.net> wrote:
> W.J cnqin wrote:
>> I use this regexp to find the prime:
[ snip non-working regex ]
>> why the regexp must be written as /^(11+)\1+$/ ?
> Interesting use of regexes! Where is this taken from, or is it your own
> example of craziness? :)
It is Abigail's craziness.
See the thread from 1998 rooted at:
Message-ID: <r8zpcyvrju.fsf_-_@asc.sps.mot.com>
(which may help answer the OP's question too):
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Mar 2003 13:25:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Why can not use this regexp to determine the prime?
Message-Id: <b59r4i$obb$1@mamenchi.zrz.TU-Berlin.DE>
W.J cnqin <qin@freebsd.lzu.edu.cn> wrote in comp.lang.perl.misc:
>
> I use this regexp to find the prime:
>
> @ARGV = (3..15);
>
> while($count = shift){
> $_ = '1' x $count;
> print $count,"\n" if ! m/^(11+)+\1$/; #if not match so it is a prime
> }
The logic is wrong. Think about what /(11+)+/ matches. The parenthesized
part must match once or more, but it isn't obliged to match the same
number of ones each time. IOW, it can match any sufficiently long string
of ones. The content of \1 will be the last match used.
> I find this topic with google , But it can not give me a statisfactory answer.
>
> why the regexp must be written as /^(11+)\1+$/ ?
I don't know if it *must* be written this way, but now the logic works.
The total match is always a repetition of the same number of ones.
Anno
------------------------------
Date: Wed, 19 Mar 2003 11:18:46 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Win32 Perl newsgroup?
Message-Id: <3e784f08.3453578723@news.cis.dfn.de>
On Tue, 18 Mar 2003 17:24:41 -0500, AK <aknntp@yahoo.com>
wrote:
>Like I mentioned, the issue I have right now is finding a way to send an email
>via Yahoo's SMTP server from a Perl script running on my Win2K laptop. I do not
>have access to any other SMTP server right now, unlike Unix boxes where a
>functional sendmail (or equivalent) is practically assumed to work without any
>explicit SMTP authentication. Yahoo's SMTP servers require you to explicitly
>authenticate before they will relay the email.
Well, whatever your problem, it has nothing whatsoever
to do with either Win32 or Perl, so looking for answers
in newsgroups or mailing lists about those two subjects
is a lost cause.
>Anyway, if you have an example using MIME::Lite (or any other module for that
>matter) where you can authenticate with the SMTP server before sending out an
>email, I'd appreciate it if you could share it with me.
perldoc Net::SMTP
or
http://www.perldoc.com/perl5.8.0/lib/Net/SMTP.html
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
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.
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 4729
***************************************