[16273] in Perl-Users-Digest
Perl-Users Digest, Issue: 3685 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 16 18:10:32 2000
Date: Sun, 16 Jul 2000 15:10:20 -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: <963785420-v9-i3685@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 16 Jul 2000 Volume: 9 Number: 3685
Today's topics:
HELP me please!!!!!!!!!!!! <nikitta@ica.net>
How can I print date on an include file <john99@NOSPAMcanada.com>
Re: How do I set/get cookies ? <jraff@home.com>
Re: Is there a Perl bug list? <gellyfish@gellyfish.com>
Re: Locking a file <bart.lateur@skynet.be>
Re: NEt::POP3 difficulties <gellyfish@gellyfish.com>
Re: Net::Smtp problems <gellyfish@gellyfish.com>
Re: Net::Smtp problems <jdNOjdSPAM@syncon.ie.invalid>
Re: Net::Smtp problems <tony_curtis32@yahoo.com>
New beginner with execution problems <stefan.jonsson@chello.se>
Re: New beginner with execution problems <bcaligari@shipreg.com>
newbie - like it so far - <us004258@mindspring.com>
Re: newbie - like it so far - <joe.kline@sdrc.com>
Re: newbie - like it so far - <DNess@Home.Com>
Re: newbie - like it so far - <bart.lateur@skynet.be>
Re: NEWBIE QUESTION !!!!! <pavel@gingerall.cz>
Re: NEWBIE QUESTION !!!!! <thoren@southern-division.com>
Re: NEWBIE QUESTION !!!!! <abuse@localhost>
Re: parsing cronjob emails (Clinton A. Pierce)
Re: parsing cronjob emails tony_barratt@my-deja.com
perl cgi that makes web pages from text file <pad755@libero.it>
Re: Perl Expert? I need help! <akurczyn@usa.net>
Re: Perl Expert? I need help! <scottlm@visi.com>
Re: Perl Expert? I need help! <akurczyn@usa.net>
Re: Perl Expert? I need help! <flavell@mail.cern.ch>
Re: perl prog to change UNIX password through CGI oct1pm@hotmail.com
Re: Please criticise this text extraction script <gellyfish@gellyfish.com>
Re: Please criticise this text extraction script <gellyfish@gellyfish.com>
Re: Please criticise this text extraction script (Keith Calvert Ivey)
Re: sub selects <gellyfish@gellyfish.com>
Substitution with variables fvision@my-deja.com
Re: Substitution with variables (Keith Calvert Ivey)
Re: Understanding the regex in "commify" (perlfaq5) (Andrew Johnson)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 16 Jul 2000 17:46:40 -0700
From: nikita <nikitta@ica.net>
Subject: HELP me please!!!!!!!!!!!!
Message-Id: <3972576F.54F9B52D@ica.net>
Hi everybody.
I need your help.
How to force the program read and show only, in my case, 10 lines of a
database
and then continue until all database are shown?
This fragment of program counts 10 lines of a database and stops.
How to continue next 10 lines until all the database will be shown?
Thanks in advance,
Serguei
# a flat data is written in $filename in this way:
# ($num,$one,$two,$line1,$line2,$line3,$three,$four,$five,$six,$seven,);
#========================================================================
$display_num = 10;
&get_number();
#========================================================================
sub get_number {
open(DATA,"$filename") || die $!;
@datafile = <DATA>;
close(DATA);
my $num_display = @datafile;
my $counter = 0;
my $start_num = $counter;
my $stop_num = $counter + $display_num;
if ($stop_num > $num_display ) {
$stop_num = $num_display;
}
foreach (@datafile) {
chomp;
my @data = split /\|/;
my $number = shift(@data);
if ($number != 0) {
&write data;
$counter++;
until ($counter == $stop_num);
}
return ($num_display, $start_num, $stop_num);
}
------------------------------
Date: Sun, 16 Jul 2000 21:52:39 GMT
From: John <john99@NOSPAMcanada.com>
Subject: How can I print date on an include file
Message-Id: <39722DAE.5B7E1E4@NOSPAMcanada.com>
Hello,
I have a perl script running on my site.
It has a feature that enables me to add headers and footers of my own.
They look like this:
sub Header { print qq!
<head>
<title>myheader</title>
</head>
<body>
$date
!;
}1;
Within the place where it says $date i would like to call my date
program. It is also a perl script.
Does anyone one how can I implement this?
SSI doesn't work.
Thank you all in advance
------------------------------
Date: Sun, 16 Jul 2000 17:44:49 GMT
From: "jraff" <jraff@home.com>
Subject: Re: How do I set/get cookies ?
Message-Id: <lwmc5.68122$lU5.466667@news1.rdc1.nj.home.com>
One might want to look at;
http://search.cpan.org/doc/LDS/CGI.pm-2.68/CGI/Cookie.pm
------------------------------------------------------------------
<martho@my-deja.com> wrote in message news:8ksimn$t9$1@nnrp1.deja.com...
> How do I set/get cookies in Perl-CGIs ?
------------------------------
Date: 16 Jul 2000 14:02:47 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Is there a Perl bug list?
Message-Id: <8ksbpn$av5$1@orpheus.gellyfish.com>
On Sun, 16 Jul 2000 03:18:58 GMT Mark Lewis wrote:
> Hello,
>
> Where can a comprehensive list of confirmed Perl bugs be found? The only
> thing I have be able to find is an outdated list at perl.com.
>
<http://bugs.perl.org> at a guess ...
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Sun, 16 Jul 2000 19:45:58 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Locking a file
Message-Id: <d4t3nsk77op6he3m8h28pi5s7sgs2h8c91@4ax.com>
martin@radiok2r.de wrote:
>What's the best way to lock/unlock a file while one user is working with
>ist ? I could use flock(), but if the user aborts or the connections
>breaks down, the file would be locked forever...
I think the OS will automatically free a lock if you don't do it before
the program quits; even if it's forced to quit.
--
Bart.
------------------------------
Date: 16 Jul 2000 14:47:58 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: NEt::POP3 difficulties
Message-Id: <8kseee$jla$1@orpheus.gellyfish.com>
In comp.lang.perl.misc Somebody Special <someone@msn.com> wrote:
>
> I am having some trouble accessing message content with Net::POP3
>
> I can get the correct number of messages with:
>
> my $pop = Net::POP3->new($server);
> my $numMsgs = $pop3->login($user,$pass);
Heres an example I prepared earlier :
#!/usr/bin/perl -w
use strict;
use Net::POP3;
use Mail::Internet;
use Mail::Header;
my $postoffice = Net::POP3->new('localhost') || die "No POP !\n";
my $no_mesgs = $postoffice->login('gellyfish','fru1tbat')
|| die "Cant login - @{[$postoffice->message]}\n";
#
# message() is a method of Net::Cmd from which Net::POP3 is derived
# and returns the last message received from the server - we will use
# it to give a diagnostic if anything goes wrong.
#
my $msg_list = $postoffice->list;
|| die "Cant list messages - @{[$postoffice->message]}\n";
#
# list() returns a hash whose keys are the undeleted msg numbers and the
# values are the sizes of the messages.
#
foreach my $msgnum (sort keys %{$msg_list} )
{
my $message = $postoffice->get($msgnum)
|| die "Cant get msg $msgnum - @{[$postoffice->message]}\n";
# get() returns a reference to an array of the lines of the message
# Create a new Mail::Internet object from the retrieved message
my $mail = Mail::Internet->new($message);
my $head = $mail->head; # A Mail::Header;
print "Mail from : ",$head->get('From'),
"Subject : ", $head->get('Subject'),"\n";
foreach my $body_line (@{$mail->body})
{
# do something with each line of the message
print $body_line;
}
}
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 16 Jul 2000 14:12:24 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Net::Smtp problems
Message-Id: <8kscbo$csm$1@orpheus.gellyfish.com>
On Sat, 15 Jul 2000 17:34:15 -0700 deno wrote:
>
>
> Any1 had any problems with net::smtp ?
>
> the following only works 25% of the time
>
> use Net::SMTP;
>
> $smtp = Net::SMTP->new('192.168.0.99', Timeout => 30);
>
> print $smtp->banner,"\n";
> $smtp->quit;
>
>
You really do need to check the success of the call to new before
you carry on and try to use $smtp. You also will want to use the
Debug mode of Net::SMTP to determine what it was that went wrong.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Sun, 16 Jul 2000 12:20:14 -0700
From: deno <jdNOjdSPAM@syncon.ie.invalid>
Subject: Re: Net::Smtp problems
Message-Id: <0b623134.739f271f@usw-ex0105-036.remarq.com>
js>>You really do need to check the success of the call to new
js>>before you carry on and try to use $smtp. You also will want
js>>to use the Debug mode of Net::SMTP to determine what it was
js>>that went wrong.
use Net::SMTP;
$smtp = Net::SMTP->new('192.168.0.100', Timeout => 100);
print "smtp is $smtp";
print $smtp->banner,"\n";
$smtp->quit;
$smtp prints as "Net::SMTP=GLOB(0x1b3cd50"
Also none of the net:dns examples from the perldocs appear to
work on win 98, is this known problem?
Thanks,
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: 16 Jul 2000 16:20:31 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Net::Smtp problems
Message-Id: <87vgy53h7k.fsf@limey.hpcc.uh.edu>
>> On Sun, 16 Jul 2000 12:20:14 -0700,
>> deno <jdNOjdSPAM@syncon.ie.invalid> said:
js> You really do need to check the success of the call to
js> new before you carry on and try to use $smtp. You also
js> will want to use the Debug mode of Net::SMTP to
js> determine what it was that went wrong.
> use Net::SMTP;
> $smtp = Net::SMTP->new('192.168.0.100', Timeout => 100);
> print "smtp is $smtp"; print $smtp->banner,"\n";
> $smtp->quit;
> $smtp prints as "Net::SMTP=GLOB(0x1b3cd50"
The person you cited above, without naming them, suggested
using the Debug mode, which you haven't done. That, along
with testing the defined()ness of the new(), is probably
going to help pinpoint this problem.
> Also none of the net:dns examples from the perldocs
> appear to work on win 98, is this known problem?
Shouldn't think so. It sounds like your network is badly
setup if you're having all these problems with standard
network services.
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: Sun, 16 Jul 2000 20:12:46 GMT
From: "Stefan Jonsson" <stefan.jonsson@chello.se>
Subject: New beginner with execution problems
Message-Id: <2Hoc5.1180$u21.277042@nntp1.chello.se>
Hi! I am a newbeginner on Perl programming. How do I execute an
Perlprogram - from the doswindow by writing "perl helloworld.pl" or how?
When I do this i get a message "wrong commando or filename".
I have installed the "Perl 5.6.0.616" - package on a Window 95 system and a
AMD K6 200 mhz processor. I downloaded InstMsi.exe (Installer 1.1) to make
it possible to install the "Perl 5.6.0.616" - package on to it, and the
installation procedure runned smoth. What am I doing wrong?
------------------------------
Date: Sun, 16 Jul 2000 23:52:57 +0200
From: "Brendon Caligari" <bcaligari@shipreg.com>
Subject: Re: New beginner with execution problems
Message-Id: <8kta88$bdj$1@news.news-service.com>
"Stefan Jonsson" <stefan.jonsson@chello.se> wrote in message
news:2Hoc5.1180$u21.277042@nntp1.chello.se...
> Hi! I am a newbeginner on Perl programming. How do I execute an
> Perlprogram - from the doswindow by writing "perl helloworld.pl" or how?
> When I do this i get a message "wrong commando or filename".
> I have installed the "Perl 5.6.0.616" - package on a Window 95 system and
a
> AMD K6 200 mhz processor. I downloaded InstMsi.exe (Installer 1.1) to make
> it possible to install the "Perl 5.6.0.616" - package on to it, and the
> installation procedure runned smoth. What am I doing wrong?
>
>
616!!!! a week ago it was 615!!!...ah well :-(
check that perl.exe is in your path
if you followed the default installation it should be in c:\perl\bin
and said directory should be in your path
if not, add the following line to your autoexec.bat file
set PATH=%PATH%;c:\perl\bin
(and reboot)
if you have a perl program, say, runme.pl which you want to run
all you have to type is
perl runme.pl
Brendon
------------------------------
Date: Sun, 16 Jul 2000 12:52:32 -0400
From: Art Heyman <us004258@mindspring.com>
Subject: newbie - like it so far -
Message-Id: <3971E850.48BF@mindspring.com>
2 simple questions -
How do I get a sub string ? I want to grab all text between two known
characters -
And - where do I find the socket add on for network calls ? I've
found a fine site for a lesson on how to do , but no pointer to the add
in code -
It's a wonderful language - CGI/text database programming was a
pleasure - but the substring idea is daunting - Many thanks -
------------------------------
Date: Sun, 16 Jul 2000 13:47:22 -0400
From: Joe Kline <joe.kline@sdrc.com>
To: us004258@mindspring.com
Subject: Re: newbie - like it so far -
Message-Id: <3971F52A.BE3F651B@sdrc.com>
[posted and mailed]
Art Heyman wrote:
> 2 simple questions -
> How do I get a sub string ? I want to grab all text between two known
> characters -
perldoc -f substr
However, this is for the indices within the string, not between 2 arbitrary
characters (i.e. between 4th and 10th character as opposed to first
occurrence of 'a' and the last occurrence of 'k'). In which case you'll want
to do:
perldoc perlre
This explains Perl's regex implementation.
>
> And - where do I find the socket add on for network calls ? I've
> found a fine site for a lesson on how to do , but no pointer to the add
> in code -
Take a gander at:
perldoc perlipc
It explains client/server apps using sockets (TCP and UDP). It will also
point you to other modules that minimize the drudgery of creating the
connections.
joe - just sitting in Monterey waiting for the conference to start...
------------------------------
Date: Sun, 16 Jul 2000 18:11:20 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: newbie - like it so far -
Message-Id: <3971FAC4.7B7D259D@Home.Com>
Art Heyman wrote:
>
> 2 simple questions -
> How do I get a sub string ? I want to grab all text between two known
> characters -
> And - where do I find the socket add on for network calls ? I've
> found a fine site for a lesson on how to do , but no pointer to the add
> in code -
>
> It's a wonderful language - CGI/text database programming was a
> pleasure - but the substring idea is daunting - Many thanks -
Try
perldoc -f substr
------------------------------
Date: Sun, 16 Jul 2000 23:22:37 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: newbie - like it so far -
Message-Id: <2r84nsgh3ksuahdlf7fplkj361n6bd9qu0@4ax.com>
Art Heyman wrote:
> How do I get a sub string ? I want to grab all text between two known
>characters
People usually uses regexes for that. For example, if that character is
a quote, this will work:
$string = 'He said: "Hello, how are you?"';
($quote) = $string =~ /"(.*?)"/;
print $quote;
The question mark makes the regex non-greedy, so the search stops at the
second quote found -- not at the last, which is what you'd get without
it.
--
Bart.
------------------------------
Date: Sun, 16 Jul 2000 18:24:24 +0200
From: Pavel Hlavnicka <pavel@gingerall.cz>
Subject: Re: NEWBIE QUESTION !!!!!
Message-Id: <3971E1B8.4060101@gingerall.cz>
Hi,
I don't like this my solution, but is works:
sub replnl {
$a =3D shift;
$a =3D~ s/\n//sg;
$a;
}
$sun =3D~ s/(\[.*?])/ replnl($1) /esg;
Pavel
> Hello everybody,
> =
> i have a little question in perl :
> =
> i have this string :
> =
> $sun =3D <<'FF';
> =
> aaaaa [
> bbbbbb
> bbb
> ]
> aaaaaa
> [
> bbbbbbbb
> bbb
> ]
> =
> FF
> =
> and i want to delete all newline \n characters inside all brackets
> [...]. Can someone help me ???
> I know there is an easy solution but i tried everything and didn't foun=
d
> anything.
> =
> Thanx
> =
> F=E9lix Gourdeau
> felix.gourdeau@videotron.ca
------------------------------
Date: Sun, 16 Jul 2000 18:36:53 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: Re: NEWBIE QUESTION !!!!!
Message-Id: <8ksoc6$14n$14$1@news.t-online.com>
Félix Gourdeau <felix.gourdeau@videotron.ca> wrote in message
news:3971C773.8408B5E4@videotron.ca...
> i have this string :
>
> $sun = <<'FF';
>
> aaaaa [
> bbbbbb
> bbb
> ]
> aaaaaa
> [
> bbbbbbbb
> bbb
> ]
>
> FF
>
> and i want to delete all newline \n characters inside all brackets
> [...]. Can someone help me ???
> I know there is an easy solution but i tried everything and didn't
> found anything.
please use a better (and not all Caps) subject next time - more people might
help you then.
perhaps there is an easier solution, but what i found does what it should.
brackets must come in pairs, nested brackets are not supported:
################################
#!/usr/local/bin/perl -w
use strict;
sub swap {
my $list = shift;
$list =~ s/\n//g;
return '[' . $list . ']';
}
my $sun = <<'FF';
aaaaa [
bbbbbb
bbb
]
aaaaaa
[
bbbbbbbb
bbb
]
FF
$sun =~ s/\[(.+?)\]/swap($1)/esg;
print $sun;
################################
gruß
thoren
8#X
--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com
------------------------------
Date: Mon, 17 Jul 2000 01:13:34 +0800
From: "multiplexor" <abuse@localhost>
Subject: Re: NEWBIE QUESTION !!!!!
Message-Id: <8ksq19$brq3@imsp212.netvigator.com>
###
$sun =~ s!
(\[.*?])
!
my $temp = $1; # Including square bracket
$temp =~ s/\n//g; # Remove new line
$temp; # Return it
!esgx; # Needs x modifier
###
Or in more compact form:
###
$sun =~ s!(\[.*?])! my $temp = $1; $temp =~ s/\n//g; $temp; !esg;
###
"Félix Gourdeau" <felix.gourdeau@videotron.ca>wrote
Hello everybody,
i have a little question in perl :
i have this string :
$sun = <<'FF';
aaaaa [
bbbbbb
bbb
]
aaaaaa
[
bbbbbbbb
bbb
]
FF
and i want to delete all newline \n characters inside all brackets
[...]. Can someone help me ???
I know there is an easy solution but i tried everything and didn't found
anything.
Thanx
------------------------------
Date: Sun, 16 Jul 2000 16:18:27 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: parsing cronjob emails
Message-Id: <nflc5.39424$fR2.361962@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <8kse6e$ts4$1@nnrp1.deja.com>,
tony_barratt@my-deja.com writes:
> Hi,
> I'd like to implement some perl code to react to incoming emails to root
> and look for keywords like failed and generate an event if found.
> [...]
> But I'm not clear on how to react to emails. I expect there's a hard way
> and a very hard way, but is there perhaps an easy way?
A combination of Perl and a package called procmail will do this job
quite nicely. And easily. Search the fine web for both. :)
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Sun, 16 Jul 2000 19:22:48 GMT
From: tony_barratt@my-deja.com
Subject: Re: parsing cronjob emails
Message-Id: <8kt21q$b5o$1@nnrp1.deja.com>
I've compiled and installed procmail. It will as you suggest do the job
nicely. But it's a bit complex for what I want to do. It looks like I'd
need to use some procmail, some shellscripting some piping and some perl
coding. Which is OK but a bit challenging to maintain after I've moved
on.
Just perl would be good. A quick search of the Internet reveals that
perl POP3 and SMTP could replace fetchmail (for simple requirements).
I didn't find anything to replace procmail though.
Maybe it can't be done?
<wiser_now>
thanks for the input so far..
In article <nflc5.39424$fR2.361962@news1.rdc1.mi.home.com>,
clintp@geeksalad.org (Clinton A. Pierce) wrote:
> [Posted and mailed]
>
> In article <8kse6e$ts4$1@nnrp1.deja.com>,
> tony_barratt@my-deja.com writes:
> > Hi,
> > I'd like to implement some perl code to react to incoming emails to
root
> > and look for keywords like failed and generate an event if found.
> > [...]
> > But I'm not clear on how to react to emails. I expect there's a hard
way
> > and a very hard way, but is there perhaps an easy way?
>
> A combination of Perl and a package called procmail will do this job
> quite nicely. And easily. Search the fine web for both. :)
>
> --
> Clinton A. Pierce Teach Yourself Perl in 24 Hours!
> clintp@geeksalad.org for details see
http://www.geeksalad.org
> "If you rush a Miracle Man,
> you get rotten Miracles." --Miracle Max, The Princess Bride
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 16 Jul 2000 21:42:33 +0200
From: "Ðyl@ñ" <pad755@libero.it>
Subject: perl cgi that makes web pages from text file
Message-Id: <8kt3c7$esk$1@sirmdpsin17.inwind.it>
Hi, I'm making a script that makes web pages from text files, what I don't
know is how to tell to the cgi wich text file it has to use to make the web
page.
this is the link that I wanto to use to build the web page
http://sito.com/script.cgi?fileA.txt
thanks
#!/usr/local/bin/perl
print "Content-type: text/html\n\n" ;
print <<EOF ;
<html>
<head><title>$title</title></head>
<body>
||||||||| here should go the text file
</body>
</html>
EOF
------------------------------
Date: Sun, 16 Jul 2000 02:02:59 -0500
From: "Alejandro Kurczyn" <akurczyn@usa.net>
Subject: Re: Perl Expert? I need help!
Message-Id: <3971d8bd_2@excalibur.gbmtech.net>
From: "Tad McClellan" <tadmc@metronet.com>
> [ Please put your comments *following* the quoted text that you
> Please do not quote an _entire_ article. Quote just enough to
> Please do not quote .sigs
Yeah, sorry about that. It's been some years since I posted on Usenet :-)
> That looks just like the code I posted in a different subthread
> (except you've made it harder to read).
I don't mind loosing a few spaces...
> If you have a question about my code, followup to the article
> where I posted the code.
It's not about "your code", it's a valid question regarding Perl. I've seen
some tricks performed using regex, when other functions are available. I
just want to know if there is any difference whatsoever.
> Please don't break stuff by copying it from one subthread
> to another.
I didn't copied anything, my post includes "my code", I didn't even had your
message available on the server when I responded.
> >Is it better to use regexps if there is already a function to do it?
>
> We cannot answer unless "better" is defined.
>
> What is "better" depends on what you want to optimize.
>
>
> Speed?
>
> Size of source code?
>
> Size of executable?
>
> Memory usage?
>
> Disk usage?
>
> Development time?
>
> Maintenance time?
>
>
>
> For code that I post, you can nearly always assume the last one there.
OK, can you give any light on the other ones? Myself I prefer good
performance (that's a function of Speed, I/O, and Memory).
Regards,
-Alejandro
------------------------------
Date: Sun, 16 Jul 2000 11:12:32 -0500
From: Scott McGerik <scottlm@visi.com>
Subject: Re: Perl Expert? I need help!
Message-Id: <walc5.1314$6E.225840@ptah.visi.com>
Alejandro Kurczyn wrote:
> From: "Tad McClellan" <tadmc@metronet.com>
> > [ Please put your comments *following* the quoted text that you
> > Please do not quote an _entire_ article. Quote just enough to
> > Please do not quote .sigs
>
> Yeah, sorry about that. It's been some years since I posted on Usenet :-)
[snip]
How many times are you going to post this article? This is the third
posting of this article that I have seen.
Scott McGerik
------------------------------
Date: Sun, 16 Jul 2000 02:02:59 -0500
From: "Alejandro Kurczyn" <akurczyn@usa.net>
Subject: Re: Perl Expert? I need help!
Message-Id: <3971e114_2@excalibur.gbmtech.net>
From: "Tad McClellan" <tadmc@metronet.com>
> [ Please put your comments *following* the quoted text that you
> Please do not quote an _entire_ article. Quote just enough to
> Please do not quote .sigs
Yeah, sorry about that. It's been some years since I posted on Usenet :-)
> That looks just like the code I posted in a different subthread
> (except you've made it harder to read).
I don't mind loosing a few spaces...
> If you have a question about my code, followup to the article
> where I posted the code.
It's not about "your code", it's a valid question regarding Perl. I've seen
some tricks performed using regex, when other functions are available. I
just want to know if there is any difference whatsoever.
> Please don't break stuff by copying it from one subthread
> to another.
I didn't copied anything, my post includes "my code", I didn't even had your
message available on the server when I responded.
> >Is it better to use regexps if there is already a function to do it?
>
> We cannot answer unless "better" is defined.
>
> What is "better" depends on what you want to optimize.
>
>
> Speed?
>
> Size of source code?
>
> Size of executable?
>
> Memory usage?
>
> Disk usage?
>
> Development time?
>
> Maintenance time?
>
>
>
> For code that I post, you can nearly always assume the last one there.
OK, can you give any light on the other ones? Myself I prefer good
performance (that's a function of Speed, I/O, and Memory).
Regards,
-Alejandro
------------------------------
Date: Sun, 16 Jul 2000 19:50:43 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Perl Expert? I need help!
Message-Id: <Pine.GHP.4.21.0007161947120.8895-100000@hpplus03.cern.ch>
On Sun, 16 Jul 2000, Alejandro Kurczyn wrote:
> From: "Tad McClellan" <tadmc@metronet.com>
> > [ Please put your comments *following* the quoted text that you
[...]
> Yeah, sorry about that. It's been some years since I posted on Usenet :-)
That's not funny. Usenet self-discipline in this respect was better
'some years' ago than it is now, so, by claiming to be an old-time
poster, you put yourself into an even worse light.
[f'up set]
------------------------------
Date: Sun, 16 Jul 2000 21:17:38 GMT
From: oct1pm@hotmail.com
Subject: Re: perl prog to change UNIX password through CGI
Message-Id: <8kt8p7$fjt$1@nnrp1.deja.com>
In article <8kngop$kt3$1@nnrp1.deja.com>,
spock0000@my-deja.com wrote:
> You can type "system ("passwd")" the problem is that it runs a
different
> program but I don't know how to write the required passwords for that
> program, maybe someone else can answer that.
>
> In article <396dd536$1_2@nexus.comcen.com.au>,
> "Kiel Stirling" <taboo@doofa.net> wrote:
> >
> > oct1pm@hotmail.com wrote:
> > >Hi,>
> > >I am trying to write a Perl CGI program so that when a user click
> 'reset
> > >password' button through webpage, he can update his UNIX password.
> > >One can type 'passwd' interactively to reset the password. Is there
a
> > >way I can reset it using something like "system("passwd")" in
> Perl/CGI ?
> > >
> > >thanks for your info,
> > >
> > >Andrew
> > >
> > >
> > >Sent via Deja.com http://www.deja.com/
> > >Before you buy.
> >
> > Try looking at poppasswd or maybe if your running FreeBSD
> > pw(8) which if your working on a localhost is more efficient.
> >
Kiel,Spock000 thanks for your reply. What is 'poppasswd' ?
I am running Sun OS 5.6.
When I run "system"passwd username"", I still need to type in
new password interactively. That is not what I want. What I want is:
I choose a password and set it as the user's password. The question is
how can I let the machine accept my chosen password without asking
stupid questions. Any idea ?
Andrew
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Jul 2000 15:21:26 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Please criticise this text extraction script
Message-Id: <8ksgd6$q35$1@orpheus.gellyfish.com>
On Sat, 15 Jul 2000 18:07:45 +0000 rhys wrote:
> I would be grateful for suggestions on how I could have done this better
> (although I am pleased that I finally got it working at all).
>
> The objective is to extract email addresses from html pages - I have
> already used it to email British members of parliament!.
>
Spam is evil, even against MPs.
Your enterprise is foolish anyhow, parsing e-mail addresses from plain text
(you are treating the HTML as plain text here) is verging on the impossible,
there is a monstrous regular expression that makes an attempt to do this in
Mastering Regular Expressions and this has its limitations. I would also
recommend you to search Deja News for articles in this group discussing
the issue. Parsing HTML that you dont have any control over is also
something that is not recommended - there are modules for this which make
a better attempt than the regular expressions you are likely to come up
with.
The only reliable e-mail addresses that you are likely to get from HTML are
those that are marked as such by being in the HREF attribute of an A tag
with a mailto: scheme, of course these still might be invalid but they
are being presented as valid ....
The following snippet will get all such e-mail addresses from an HTML
document :
#!/usr/bin/perl -w
use strict;
use HTML::LinkExtor;
use URI;
# File given on command line or standard input
my $file = shift || '-';
my $parser = HTML::LinkExtor->new();
# We'll handle any problems in parse_file ourself
eval
{
$parser->parse_file($file);
};
if ($@)
{
die "Parsing of $file failed = $@\n";
}
foreach my $link ( $parser->links )
{
my ( $tag, %links ) = @{$link};
next unless $tag eq 'a';
if( exists $links{'href'} )
{
my $uri = URI->new($links{'href'});
next unless $uri->scheme eq 'mailto';
print $uri->to,"\n";
}
}
If I find that you have been spamming with this I will come round and
stuff Sanford Wallace's pony up your nose.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 16 Jul 2000 15:27:56 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Please criticise this text extraction script
Message-Id: <8ksgpc$rb9$1@orpheus.gellyfish.com>
On 15 Jul 2000 18:27:15 GMT Decklin Foster wrote:
> rhys <rhys.tucker@dtn.ntl.com> writes:
>
>> $outfile = shift;
>> open(OUTFILE,">$outfile") or die "Unable to open \$outfile $outfile :
>> $!\n";
>
> Once again, bad; print to stdout. I want to be able to redirect or
> pipe the output and name multiple input files.
>
A general solution to this kind of thing is to check whether STDOUT is
redirected with -t and if it isnt then open STDOUT to the file :
if ( -t STDOUT )
{
open(STDOUT,">$outfile") || die "Cant reopen STDOUT to $outfile - $!\n";
}
Now do all output to STDOUT ...
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Sun, 16 Jul 2000 21:01:05 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Please criticise this text extraction script
Message-Id: <39761d02.4986806@news.newsguy.com>
Stephen Kloder <stephenk@cc.gatech.edu> wrote:
>Just use /(\w+\.)*\w+@\w+(\.\w+)*/g and place all matching strings into a hash.
That will only get some proportion of addresses and will
sometimes get pieces of addresses. And I'm not talking about
the bizarre geekish or comment-containing addresses people
usually post in these threads. Consider perfectly normal
addresses like jsmith@ohio-state.edu, which you turn into
jsmith@ohio. And you can have all sorts of characters other
than \w and . before the @ -- + is popular, for example.
If the original poster wants to use a regex to extract
addresses, he should read the FAQ and then consider carefully
whether a regex will meet his needs. If he decides to use one,
he'd better put some thought into the design (and read the
relevant RFCs) and be aware of its limitations.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)
------------------------------
Date: 16 Jul 2000 19:44:09 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: sub selects
Message-Id: <8ksvpp$cph$1@orpheus.gellyfish.com>
On Wed, 12 Jul 2000 13:12:20 GMT brainmuffin@excite.com wrote:
> Does anyone know if mySQL supports sub-selects, and if so, what the
> syntax is?
No MySQL does not support, sub-selects - this is one of the reasons why it
is crap. Why you didnt ask in a MySQl oriented goup beats me though...
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Sun, 16 Jul 2000 17:14:21 GMT
From: fvision@my-deja.com
Subject: Substitution with variables
Message-Id: <8ksqh3$5ul$1@nnrp1.deja.com>
I have a script that searches through lines of text for commands and then
executes those commands and needs to put the result back in the line
where it found the command like this:
#Find all of the commands in the line
@commands = $line =~ /regularexpression/gi;
foreach $command (@commands) {
$result = &getresult($command);
$line =~ s/$command/$result/;
}
When I try to execute this I get the following error:
Can't modify constant item in substitution (s///) at ./mytest.pl line 30,
near "s/$commmand/"$result"/;"
Has anyone here attempted the same and could help me out?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 16 Jul 2000 21:01:58 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Substitution with variables
Message-Id: <39751be2.4698795@news.newsguy.com>
fvision@my-deja.com wrote:
>@commands = $line =~ /regularexpression/gi;
>
>foreach $command (@commands) {
> $result = &getresult($command);
> $line =~ s/$command/$result/;
>}
Why not just
$line =~ s/(regularexpression)/getresult($1)/gie;
? The way you're doing it might make substitutions within the
results of previous commands rather than where you're expecting.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)
------------------------------
Date: Sun, 16 Jul 2000 19:33:01 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Understanding the regex in "commify" (perlfaq5)
Message-Id: <N5oc5.8479$k5.105540@news1.rdc1.mb.home.com>
In article <39711E25.8FA76108@netstorm.net>,
Jim Mauldin <mauldin@netstorm.net> wrote:
[snip]
> Then it starts over with the while loop, with ([-+]?\d+) matching
> everything up to the comma on the first pass, and then working backward
> as before.
>
> Is that what's going on, or is it something else?
Yes, that is what is going on -- you can even see the re itself in
action using: use re 'debug'; in recent versions. Try this, for
example:
#!/usr/bin/perl -w
use strict;
use re 'debug';
$_ = '12345678';
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
print;
This will show you the steps the re engine takes to successfully
match on the first and second while loop tests, and then fail on
the third.
andrew
--
Andrew L. Johnson http://members.home.net/andrew-johnson/
It may be that your sole purpose in life is simply to
serve as a warning to others.
------------------------------
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 3685
**************************************