[22205] in Perl-Users-Digest
Perl-Users Digest, Issue: 4426 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 18 18:05:52 2003
Date: Sat, 18 Jan 2003 15: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 Sat, 18 Jan 2003 Volume: 10 Number: 4426
Today's topics:
Re: A Good Perl Developing Enviroment Andrew Lee
Re: A Good Perl Developing Enviroment (Ben Morrow)
Re: Arrays. What don't I get? <usenet@tinita.de>
Re: Arrays. What don't I get? (Anno Siegel)
compare variable with next variable in a loop: Not an e (FMAS)
Re: compare variable with next variable in a loop: Not <usenet@tinita.de>
Re: compare variable with next variable in a loop: Not (Anno Siegel)
Re: Day of the month redirection - revised Andrew Lee
DBI::rows reliability on SELECT statements <mbudash@sonic.net>
Re: DBI::rows reliability on SELECT statements <jeff@vpservices.com>
Re: DBI::rows reliability on SELECT statements (Anno Siegel)
Re: DBI::rows reliability on SELECT statements <mbudash@sonic.net>
Re: DBI::rows reliability on SELECT statements <uri@stemsystems.com>
Re: DBI::rows reliability on SELECT statements <jeff@vpservices.com>
Re: DBI::rows reliability on SELECT statements <mbudash@sonic.net>
Re: hard <jurgenex@hotmail.com>
Re: hard <jurgenex@hotmail.com>
How are named unary operators that take $_ created? (J. Romano)
How can a SMTP mail be deleted from a Unix mailbox by a (Markus Elfring)
Re: How do I calculate today minus any given number Andrew Lee
Re: How to execute a perl script from within a perl scr <jurgenex@hotmail.com>
Re: Link of the day <jurgenex@hotmail.com>
Re: Most efficient way to do this DBI thing? <Jeff@aetherweb.co.uk>
Re: Most efficient way to do this DBI thing? <uri@stemsystems.com>
Re: Most efficient way to do this DBI thing? (Anno Siegel)
Re: Most efficient way to do this DBI thing? ctcgag@hotmail.com
OT Re: Append a text at the top an existing file <jurgenex@hotmail.com>
Re: perl hashes seems to slow down ctcgag@hotmail.com
Re: perl hashes seems to slow down ctcgag@hotmail.com
Re: perl installation question Andrew Lee
Re: Using domain.com/?query+string and domain.com/index Andrew Lee
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 18 Jan 2003 10:56:26 -0500
From: Andrew Lee
Subject: Re: A Good Perl Developing Enviroment
Message-Id: <a7ui2vg5g6d16e3ed5k0cnet8mvss304eb@4ax.com>
On Sat, 18 Jan 2003 04:17:18 GMT, "A. Fuentes" <alvarof2@hotmail.com>
wrote:
>
>
>Fellow Perl Netters:
>
>I have a newbie question:
>
>What would be a good Perl Developing Enviroment for
>managing and developing Perl projects?
vi and cvs come in handy ...
------------------------------
Date: Sat, 18 Jan 2003 21:08:25 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: A Good Perl Developing Enviroment
Message-Id: <b0cfo9$69$1@wisteria.csv.warwick.ac.uk>
"A. Fuentes" <alvarof2@hotmail.com> wrote:
>What would be a good Perl Developing Enviroment for
>managing and developing Perl projects?
>(Visual Developer Studio-like)
While I agree with the other posters that IDEs are not useful, I feel that
ActiveState Komodo may be more what you're looking for than vi... :)
Ben
------------------------------
Date: 18 Jan 2003 18:06:51 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Arrays. What don't I get?
Message-Id: <tinh8x8pc$197$tina@news01.tinita.de>
wrk <wkrempa@erols.com> wrote:
> The foreach looping construct has another feature: each time through the loop,
> the iterator variable becomes not a copy of but rather an alias for the current
> element. This means that when you change that iterator variable, you really
> change each element in the list:
[ snip example ]
> If you didn't know about it, you might accidentally change
> something. Now
> you know about it.
what made you think i didn't know? i mentioned "alias" in
my other post.
regards, tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/ \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: 18 Jan 2003 18:29:52 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Arrays. What don't I get?
Message-Id: <b0c6f0$btr$1@mamenchi.zrz.TU-Berlin.DE>
Tina Mueller <usenet@tinita.de> wrote in comp.lang.perl.misc:
> wrk <wkrempa@erols.com> wrote:
>
> > The foreach looping construct has another feature: each time through the loop,
> > the iterator variable becomes not a copy of but rather an alias for
> the current
> > element. This means that when you change that iterator variable, you really
> > change each element in the list:
>
> [ snip example ]
>
> > If you didn't know about it, you might accidentally change
> > something. Now
> > you know about it.
>
> what made you think i didn't know? i mentioned "alias" in
> my other post.
That was my reaction too, until I realized that the entire posting
(excepting the first line) is quoted from the Cookbook. This clown
did about everything wrong that can be wrong in a Usenet posting, but
he (or she) probably didn't direct "Now you know..." at you personally.
Anno
------------------------------
Date: 18 Jan 2003 12:12:15 -0800
From: massion@gmx.de (FMAS)
Subject: compare variable with next variable in a loop: Not an easy issue
Message-Id: <f0b3f4c9.0301181212.2050a77d@posting.google.com>
Hi Tina,
I apologize if you get the impression that I don't think carefully
about the advices given. I have spent so far many many hours trying to
work out a solution, but I am not a programmer and I do this in my
spare time when there is some. I probably make many basic mistakes.
Many thanks to all of you for your suggestions.
Let me give you a little bit more background. The script should help
create terminology lists in a few languages. I know that creating a
model to stem lexems is a task which takes a full team of computer
linguists. But in my daily work it would already help to reduce an
existing list of special terms (extracted from documentations with
other tools) by taking a way the most frequent endings.
My test file in German:
Abbau
abbauen
Abbild
Abbildung
Abbildungen
abbindenden
Abfüllvorgang
Abfüllvorgangs
Abgabe
Abgaben
abgabestation
abgabestationen
abgebrochen
abgebrochene
abgebrochenem
abgebrochener
RESULTS:
-----------
Matija (first proposal)
-----------------------
(empty line)
Abbau
(empty line)
abbauen
(empty line)
Abbild
(empty line)
Abbildung
(empty line)
Abbildungen
(empty line)
abbindenden
(empty line)
Abfüllvorgang
(empty line)
Abfüllvorgangs
(empty line)
Abgabe
(empty line)
Abgaben
(empty line)
abgabestation
(empty line)
abgabestationen
(empty line)
abgebrochen
(empty line)
abgebrochene
(empty line)
abgebrochenem
(empty line)
Matija (second proposal)
--------------------------
Same as first but with error messages:
next if $word =~ m/\b$nextword+e?n?\b/i; # use of uninitialzed value
print "$_\n"; # use of uninitialed value
Tad:
-----------
(empty line)
abbauen
Abbild
abbindenden
Abfüllvorgang
Abgabe
abgabestation
abgebrochen
abgebrochener
Janek:
----------
Empty results file
Tina proposal on German group:
-------------------------------
my $last="";
while (<>) {
chomp;
next if ($last && m/^${last}e?n?m?s?$/i);
$last = $_;
print "$_\n"
}
Result:
Loop doesn't end + empty file
Ingo's proposal:
----------------
("Stammwort" = "root word")
my @stammwort;
while (my $wort = <FH>) {
#I have a new root word ...
push @stammwort,$wort unless
#... when there hasn't yet been a word containing $wort
grep { $_ eq substr($wort,length($_)) } @stammwort;
}
#print a root word per line
print join $/,@stammwort;
Result:
-----------
Error message:
grep { $_ eq substr($wort,length($_)) } @stammwort; # use of
uninitialized value
Result file:
Abbau
(empty line etc.)
abbauen
Abbild
Abbildung
Abbildungen
abbindenden
Abfüllvorgang
Abfüllvorgangs
Abgabe
Abgaben
abgabestation
abgabestationen
abgebrochen
abgebrochene
abgebrochenem
abgebrochener
Tina' proposed changes to Ingo (Closest result so far):
-------------------------------------------------------
chomp $wort;
grep { $_ eq substr($wort,0,length($_)) } @stammwort;
Result list:
Abbau
abbauen
Abbild
abbindenden
Abfüllvorgang
Abgabe
abgabestation
abgebrochen
As you see it is not as easy as it seems. I guess the problem is to
get 2 variables, one with the basic word which should occur first and
another with as many variation of the first variable.
Once this works I'll try to find a formula for as many words
variations as possible.
------------------------------
Date: 18 Jan 2003 21:17:27 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: compare variable with next variable in a loop: Not an easy issue
Message-Id: <tinh8xhjz$1j4$tina@news01.tinita.de>
FMAS <massion@gmx.de> wrote:
> My test file in German:
> Abbau
> abbauen
> Abbild
[snip]
> RESULTS:
> Tina proposal on German group:
> -------------------------------
> my $last="";
> while (<>) {
> chomp;
> next if ($last && m/^${last}e?n?m?s?$/i);
> $last = $_;
> print "$_\n"
> }
> Result:
> Loop doesn't end + empty file
o'really...
must be a bug in your perl version.
for me it outputs:
Abbau
Abbild
Abbildung
abbindenden
Abfüllvorgang
Abgabe
abgabestation
abgebrochen
abgebrochener
is that, what you want?
> Tina' proposed changes to Ingo (Closest result so far):
> -------------------------------------------------------
you forgot to mention that i said that this solution has
a problem, e.h. with "product" and "production".
> chomp $wort;
> grep { $_ eq substr($wort,0,length($_)) } @stammwort;
> Result list:
> Abbau
> abbauen
so if you say this is the closest so far, you want the
result to be case-sensitive? you didn't
tell that in your original post, did you?
drop the /i from my version.
> As you see it is not as easy as it seems. I guess the problem is to
> get 2 variables, one with the basic word which should occur first and
> another with as many variation of the first variable.
soory, i don't get the problem. you just have to remember the
word from the last loop iteration. if it matches the
current word, keep it, if not, set it to the new word.
and i still don't understand why you are getting an endless
loop with my version.
regards, tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/ \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: 18 Jan 2003 22:28:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: compare variable with next variable in a loop: Not an easy issue
Message-Id: <b0ckej$lim$1@mamenchi.zrz.TU-Berlin.DE>
FMAS <massion@gmx.de> wrote in comp.lang.perl.misc:
> Hi Tina,
>
> I apologize if you get the impression that I don't think carefully
> about the advices given. I have spent so far many many hours trying to
> work out a solution, but I am not a programmer and I do this in my
> spare time when there is some. I probably make many basic mistakes.
>
> Many thanks to all of you for your suggestions.
>
> Let me give you a little bit more background. The script should help
> create terminology lists in a few languages. I know that creating a
> model to stem lexems is a task which takes a full team of computer
> linguists. But in my daily work it would already help to reduce an
> existing list of special terms (extracted from documentations with
> other tools) by taking a way the most frequent endings.
While I'm still not clear what the exact problem is, identifying the
endings from a list of word forms appears to be part of the task.
An ending in this sense would be a string $ending, such that for a
word $word in the wordlist "$word$ending" is also a word in the wordlist.
Suppose the set of word forms is represented as the keys of a hash %words
(with arbitrary values), chomped and lower-cased as in
do { chomp; undef $words{ lc $_} } while <DATA>;
Then build a hash that contains the statistics of endings like this:
my %endings;
for my $word ( keys %words ) {
my ( $prefix, $ending) = find_ending( \ %words, $word);
$endings{ $ending}++ if length $prefix;
}
The work-horse of this loop is, of course, find_ending, which takes
a wordlist like above (given as a hashref), and a word. It splits
an ending for which there is evidence in the wordlist off the given
word:
sub find_ending {
my ( $words, $word) = @_;
my ( $prefix, $ending) = ( $word, '');
for my $i ( 1 .. length( $word) ) {
$prefix = substr( $word, 0, length( $word) - $i);
$ending = substr( $word, -$i);
last if exists $words->{ $prefix};
}
( $prefix, $ending);
}
Applied to your sample data (which I leave in below), this finds the
following endings (with frequencies):
e: 1
en: 3
m: 1
n: 1
r: 1
s: 1
station: 1
ung: 1
Note that "stationen" is not recorded as an ending with "abgabe", but
as a case of "en" with "abgabestation". That is because find_ending
prefers long prefixes. reverse() the list in the loop condition for
the opposite behavior.
Anno
> My test file in German:
> Abbau
> abbauen
> Abbild
> Abbildung
> Abbildungen
> abbindenden
> Abfüllvorgang
> Abfüllvorgangs
> Abgabe
> Abgaben
> abgabestation
> abgabestationen
> abgebrochen
> abgebrochene
> abgebrochenem
> abgebrochener
------------------------------
Date: Sat, 18 Jan 2003 11:49:03 -0500
From: Andrew Lee
Subject: Re: Day of the month redirection - revised
Message-Id: <3r0j2v4viu8intq702h49j3ijsq8fcn7ks@4ax.com>
On 17 Jan 2003 23:57:12 -0800, ralph@beseenmg.com (Ralph) wrote:
>Please help - I'm a rookie.
That is an understatement.
>I'm searching for a script that will
I presume, then, that after getting excellent advice from several
knowledgable people on this exact subject that you have given up and
now want someone to write you such a script. (which Randal, et al
have already done (at least the interesting part)).
But that will cost money -- what are you willing to pay?
Or did your version of Perl come with a guaranty that c.l.p.misc would
be your personal help desk?
Funny, mine didn't
------------------------------
Date: Sat, 18 Jan 2003 17:44:02 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: DBI::rows reliability on SELECT statements
Message-Id: <mbudash-597D2A.09440318012003@typhoon.sonic.net>
In article <slrnb2iq5r.7f1.tadmc@magna.augustmail.com>,
tadmc@augustmail.com (Tad McClellan) wrote:
> > How reliable is DBI::rows as a count of the number of fetchable rows?
>
> If you read the docs for "rows" it will tell you that it is not
> reliable at all if you are doing a SELECT query.
>
> Those docs also offer an alternative that _is_ reliable.
thanks for that, tad. with this knowledge, i must admit i've been using
rows() (alias DBI::rows) incorrectly for years! wonder why it hasn't bit
me in the butt by now...? anyway, thanks again...
obviously, reading the docs is the right thing to do even in cases where
you think you already *know* them!
------------------------------
Date: Sat, 18 Jan 2003 10:39:54 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: DBI::rows reliability on SELECT statements
Message-Id: <3E299F7A.90807@vpservices.com>
Michael Budash wrote:
> In article <slrnb2iq5r.7f1.tadmc@magna.augustmail.com>,
> tadmc@augustmail.com (Tad McClellan) wrote:
>
>
>>>How reliable is DBI::rows as a count of the number of fetchable rows?
>>>
>>If you read the docs for "rows" it will tell you that it is not
>>reliable at all if you are doing a SELECT query.
That's a good rule of thumb, but a bit of an overstatement.
>>
>>Those docs also offer an alternative that _is_ reliable.
>>
>
> thanks for that, tad. with this knowledge, i must admit i've been using
> rows() (alias DBI::rows) incorrectly for years! wonder why it hasn't bit
> me in the butt by now...?
What the docs actually say is (my emphasis) "For SELECT statements, it
is ***generally*** not possible". In other words, the rows() method is
not a general solution to the problem of getting the number of rows
returned by a SELECT statement. However, specific drivers do implement
rows() in a way that it does return the number of rows from a SELECT
statement correctly. So it's quite possible that you've been using DBDs
where the general rule doesn't apply.
I'm pointing this out as a matter of clarification, not to suggest that
anyone continue to use rows() as a way to count returns from a SELECT,
even in those cases where it happens to work.
--
Jeff
------------------------------
Date: 18 Jan 2003 18:45:03 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: DBI::rows reliability on SELECT statements
Message-Id: <b0c7bf$btr$3@mamenchi.zrz.TU-Berlin.DE>
Michael Budash <mbudash@sonic.net> wrote in comp.lang.perl.misc:
> In article <slrnb2iq5r.7f1.tadmc@magna.augustmail.com>,
[...]
> obviously, reading the docs is the right thing to do even in cases where
> you think you already *know* them!
Oooh, another contribution to the art of rtfm:
Part of rtfm is to know when to r the fm again
------------------------------
Date: Sat, 18 Jan 2003 19:00:48 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: DBI::rows reliability on SELECT statements
Message-Id: <mbudash-E27D59.11004918012003@typhoon.sonic.net>
In article <3E299F7A.90807@vpservices.com>,
Jeff Zucker <jeff@vpservices.com> wrote:
> Michael Budash wrote:
>
> > In article <slrnb2iq5r.7f1.tadmc@magna.augustmail.com>,
> > tadmc@augustmail.com (Tad McClellan) wrote:
> >
> >
> >>>How reliable is DBI::rows as a count of the number of fetchable rows?
> >>>
> >>If you read the docs for "rows" it will tell you that it is not
> >>reliable at all if you are doing a SELECT query.
>
>
> That's a good rule of thumb, but a bit of an overstatement.
>
>
> >>
> >>Those docs also offer an alternative that _is_ reliable.
> >>
> >
> > thanks for that, tad. with this knowledge, i must admit i've been using
> > rows() (alias DBI::rows) incorrectly for years! wonder why it hasn't bit
> > me in the butt by now...?
>
>
> What the docs actually say is (my emphasis) "For SELECT statements, it
> is ***generally*** not possible". In other words, the rows() method is
> not a general solution to the problem of getting the number of rows
> returned by a SELECT statement. However, specific drivers do implement
> rows() in a way that it does return the number of rows from a SELECT
> statement correctly. So it's quite possible that you've been using DBDs
> where the general rule doesn't apply.
>
> I'm pointing this out as a matter of clarification, not to suggest that
> anyone continue to use rows() as a way to count returns from a SELECT,
> even in those cases where it happens to work.
my point is that i was hoping to not have to read up on each and every
DBD's implementation of rows() to decide whether i should use it on
SELECT statements... one of the primary reasons i use the DBI framework
at all is the warm and fuzzy i get knowing that i don't *have* to think
about such things...
------------------------------
Date: Sat, 18 Jan 2003 19:08:28 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: DBI::rows reliability on SELECT statements
Message-Id: <x7ptqu2s44.fsf@mail.sysarch.com>
>>>>> "MB" == Michael Budash <mbudash@sonic.net> writes:
MB> my point is that i was hoping to not have to read up on each and every
MB> DBD's implementation of rows() to decide whether i should use it on
MB> SELECT statements... one of the primary reasons i use the DBI framework
MB> at all is the warm and fuzzy i get knowing that i don't *have* to think
MB> about such things...
well, dash those hopes. rows() is DBD dependent and you shouldn't rely
upon it if you want easier porting to any DB. i have dbi code that
uses a mysql dbd feature but it is isolated in a method that can be
replaced if needed for porting. you can choose nonstandard dbd stuff if
you know that you may have to deal with porting issues later.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Sat, 18 Jan 2003 11:27:56 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: DBI::rows reliability on SELECT statements
Message-Id: <3E29AABC.2080309@vpservices.com>
Michael Budash wrote:
> In article <3E299F7A.90807@vpservices.com>,
> Jeff Zucker <jeff@vpservices.com> wrote:
>>
>>I'm pointing this out as a matter of clarification, not to suggest that
>>anyone continue to use rows() as a way to count returns from a SELECT,
>>even in those cases where it happens to work.
>>
>
> my point is that i was hoping to not have to read up on each and every
> DBD's implementation of rows() to decide whether i should use it on
> SELECT statements... one of the primary reasons i use the DBI framework
> at all is the warm and fuzzy i get knowing that i don't *have* to think
> about such things...
Which is why I didn't suggest anyone use rows() for counting SELECTS
even if it happens to work. However, I think it is very wrong to read
only the DBI docs without reading the DBD docs for your chosen DBD(s).
Even if there was 100% agreement between DBDs in terms of DBI
implementation, there would still be specifics relating to the
underlying database and SQL implementation that would make reading the
DBD docs a must.
--
Jeff
------------------------------
Date: Sat, 18 Jan 2003 22:26:42 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: DBI::rows reliability on SELECT statements
Message-Id: <mbudash-3C90E6.14264218012003@typhoon.sonic.net>
In article <x7ptqu2s44.fsf@mail.sysarch.com>,
Uri Guttman <uri@stemsystems.com> wrote:
> >>>>> "MB" == Michael Budash <mbudash@sonic.net> writes:
>
> MB> my point is that i was hoping to not have to read up on each and every
> MB> DBD's implementation of rows() to decide whether i should use it on
> MB> SELECT statements... one of the primary reasons i use the DBI framework
> MB> at all is the warm and fuzzy i get knowing that i don't *have* to think
> MB> about such things...
>
> well, dash those hopes. rows() is DBD dependent and you shouldn't rely
> upon it if you want easier porting to any DB. i have dbi code that
> uses a mysql dbd feature but it is isolated in a method that can be
> replaced if needed for porting. you can choose nonstandard dbd stuff if
> you know that you may have to deal with porting issues later.
>
> uri
perldoc DBD::mysql makes no specific mention of how it handles the
rows() method... so where does *that* leave me?
------------------------------
Date: Sat, 18 Jan 2003 16:38:58 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: hard
Message-Id: <CqfW9.8245$V75.7878@nwrddc02.gnilink.net>
KT wrote:
[When I saw the subject line my first thought was: "Oh no, yet another
'insert-your-favourite-body-part' enhancement spam"; you may want to pick a
more descriptive line in the future]
> assume there are two users.A ,B
>
> is that a way to inform B about A's ip address via B's email address
> when A is online
Please define "is online" and how this relates to IP addresses.
Thinking about multiuser systems, broadband connections (computers with BB
are always online, but the user may change), ....
> that mean. when A is online. then a program send A's ip address to B's
> email account.
Easiest way would be to add a hook to the program that makes A 'online' to
send a mail.
> ( are there any module to perform this function in perl ?)
Many. Just search CPAN for sendmail, mail, ....
jue
------------------------------
Date: Sat, 18 Jan 2003 16:45:26 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: hard
Message-Id: <GwfW9.12036$xx4.7579@nwrddc01.gnilink.net>
Abigail wrote:
> KT (kennedyel_5000@yahoo.com) wrote on MMMCDXXVII September MCMXCIII
> in <URL:news:6495f466.0301180044.7fa4eca3@posting.google.com>:
[...]
>>> that mean. when A is online. then a program send A's ip address to
>>> B's email account.
>
> Well, it depends what you mean by "online". The most logical way is to
> modify whatever program brings the computer of A in the state of
> "being online" (a script from /etc/init.d, perhaps), and to have it
> send a message to B.
Not necessarily. That would send a message when the computer 'goes online'.
But what about broadband connections which are permanently online? Or
multiuser systems? Or LANs? Or if user A logs out and user C logs on to the
same computer. Is A still online?
There is no relation between a computer being online and a user being
online.
Of course you are quite right: the question is rather vague and it is hard
to guess what the OP meant.
jue
------------------------------
Date: 18 Jan 2003 11:35:08 -0800
From: jl_post@hotmail.com (J. Romano)
Subject: How are named unary operators that take $_ created?
Message-Id: <b893f5d4.0301181135.734b532f@posting.google.com>
Dear Perl community,
I have a question concerning named unary operators:
How do you create named unary operators that operate on $_ by
default?
Creating a function that takes $_ by default isn't too hard. I can
just use it in my function definition:
sub hello { $_[0] = $_ unless @_; print "Hello, @_!\n"; }
$_ = "world"; hello; # prints "Hello, world!"
And creating a named unary operator isn't too hard, either:
sub bonjour ($) { print "Bonjour, @_!\n"; }
We know that the bonjour function is a named unary operator (or at
least acts like one) because the following call:
bonjour 3|4;
prints "Bounjour, 3!" (not 7), just like named unary operators (that
is, the call is equivalent to "(bonjour 3)|4" ). Compare this to:
sub buenos_dias { print "!Buenos dias, @_!\n"; }
buenos_dias 3|4;
This will print "!Buenos dias, 7!" even though its call looks
identical to the call to bonjour above.
So how do we create a new function that behaves like a named unary
operator (like bonjour) but operates on $_ (like hello)? Examples of
existing Perl named unary operators that work on $_ are ord and chr:
$_ = "A"; print ord; # prints 65
$_ = 65; print chr; # prints "A"
print 1 + ord 3|4; # equivalent to: print( (1+(ord 3))|4 );
I thought about creating a prototyped subroutine that requires no
parameters but optionally allows a scalar:
sub buongiorno (;$) {
$_[0]=$_ unless @_; print "Buongiorno, @_!\n";
}
This makes the following call act the way I want it:
$_ = "amore mio"; buongiorno; # prints "Buongiorno, amore mio!"
but not the following call:
Buongiorno 3|4; # prints "Buongiorno, 7!", not 3
So my main question is: Is there a way to create a function that
acts like a named unary operator that also defaults to $_ (if no
parameters are specified)? I would like a function that does the
following:
$_ = "Eguskina"; egun_on; # prints "Egun on, Eguskina!"
egun_on 3|4; # prints "Egun on, 3!", not "Egun on, 7!"
Is such a function possible to write in Perl?
Thanks in advance for any insight.
-- J.
------------------------------
Date: 18 Jan 2003 13:54:19 -0800
From: Markus.Elfring@web.de (Markus Elfring)
Subject: How can a SMTP mail be deleted from a Unix mailbox by a script?
Message-Id: <40ed1d8f.0301181354.4738f7dc@posting.google.com>
Hallo,
I want to continue the discussion about this topic that started with
my request (http://groups.google.de/groups?selm=8utj4k%24cbi%241%40news.messer.de)
on 2000-11-15.
I thank all parties for their comments and suggestions.
The term "SMTP mail" that I've chosen specifies a message according to
the standard "RFC 822" (http://ietf.org/rfc/rfc0822.txt). This format
can be send over the communication protocol "SMTP" and some others.
Excerpt from the book "Programming Internet Email" - Chapter 4
"MIME-compliant messages", Page 60:
"...
the simplest MIME-compliant message is just an RFC 822 simple text
message with an added MIME-Version header.
..."
This request's subject is the deletion of messages in the file "mbox".
1. Some programmes provide the prompt/command line as their
programming interface.
The deletion can be performed manually by typing the letter "d" with a
following message number inside the programmes "mail". (This step can
be performed by a script, too.)
I encounter the difficulty to scroll through all exististing messages
by a command to find the right number for the message that should be
deleted. I am looking for an efficient algorithm.
2. I've spot that the "landscape" of comfortable programming
interfaces has improved.
2.1 PHP
http://pear.php.net/packages.php?catpid=14&catname=Mail
What a pity - The package "mailparse" has got the state "0.9.1
beta" und the package "Mail_Mbox" has got the state "0.1.5 alpha".
2.2 TCL
http://tcllib.sourceforge.net/doc/index.html
mime - Manipulation of MIME body parts
Tcl MIME - generates and parses MIME body parts
2.3 Perl
http://search.cpan.org/modlist/Mail_and_Usenet_News/Mail/
The package "Mail::Box" (Mail folder manager and MUA backend,
http://perl.overmeer.net/mailbox/) has got the state "2.034 beta".
The package "Mail::MboxParser" (read-only access to
UNIX-mailboxes) has got the state "0.38".
The package "Mail::Field" (Base class for manipulation of mail
header fields) has got the state "1.58".
2.4 Python
http://www.python.org/doc/lib/netdata.html
12.2 email -- An email and MIME handling package
12.4 mailbox -- Read various mailbox formats
2.5 Ruby
http://www.ruby-lang.org/raa/cat.rhtml?category_major=Library;category_minor=Mail
The package "mbox" (mbox Read and write UNIX' mbox mail-format)
has got the state "20001026 unstable".
2.6 Java
http://java.sun.com/products/javamail/
The package "JavaMail" has got the state "1.3, 26. Juni 2002".
Is a protocol provider for the format "Mbox" available?
3. A method for the deletion seems to be missing. I come to a
fundamental programming problem now.
How can a piece be cut out from the file "mbox" that can be huge in
size and that is accessed rapidly and perhaps without breaks while new
messages are appended to the file end?
(The programme "mailx" has got a built-in solution. I don't want to
look at the source files.)
3.1 I do not know yet how to put the ends of the gap together again.
3.2 The file can always be written (without the deleted contents) to a
new version. The updated version replaces the old one. Is this
applicable if you think about speed?
A problem detail is also to acquire a lock for the write access to
update the file.
Sincerely,
Markus Elfring
------------------------------
Date: Sat, 18 Jan 2003 11:55:01 -0500
From: Andrew Lee
Subject: Re: How do I calculate today minus any given number
Message-Id: <5j1j2vk7hk86j7s0f8737eojghlku3ai50@4ax.com>
On 18 Jan 2003 05:49:43 GMT, Tina Mueller <usenet@tinita.de> wrote:
>Sherman Willden <sherman.willden@hp.com> wrote:
>> Problem: Given today minus some number I have to know what that past
>> date is. Example: If the user enters 30, what is the date 30 days ago
>> from today. Today is 01/17/03 so what is the algorithm to return the
>> December 2002 date?
>
>stolen from <aml33n$7c2$03$1@news.t-online.com>:
>
>$past_date = time;
>sleep(24*60*60 * $days);
>(but see the other posts about the problems with DST etc.)
>
Would that make the OP a sort of Rip Van Winkle?
------------------------------
Date: Sat, 18 Jan 2003 16:47:33 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to execute a perl script from within a perl script and return info
Message-Id: <FyfW9.8289$V75.237@nwrddc02.gnilink.net>
Anders Torvill Bjorvand wrote:
> "Pete" <falconflyr@snet.net> skrev i melding
> news:4ca21189.0301141059.5d946602@posting.google.com...
>> system("/home/www/myserver/mydir/b.cgi");
>
> But how can I get the printed output from b.cgi into a variable
> $content in a.cgi?
Which part of "perldoc -f system" did you have problems with?
The return value is the exit status of the program as returned
by the "wait" call. [...] This is
*not* what you want to use to capture the output from a command,
for that you should use [...]
jue
------------------------------
Date: Sat, 18 Jan 2003 16:48:42 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Link of the day
Message-Id: <KzfW9.8295$V75.309@nwrddc02.gnilink.net>
TJ wrote:
> I wonder if there are anyone who know about a "link of the day"
> script that is free, and doesn't show the link
> randomly?
What do you have so far?
Show us your code and probably we can help you to improve it.
jue
------------------------------
Date: Sat, 18 Jan 2003 17:26:42 -0000
From: "Jeff Snoxell" <Jeff@aetherweb.co.uk>
Subject: Re: Most efficient way to do this DBI thing?
Message-Id: <b0c2ob$9pf$1@news8.svr.pol.co.uk>
> > It
> > doesn't seem to be in my manual.
> ^^^^^^^^^
>
> What manual is that?
>
> Use the docs Luke!
:)
My manual was MySQL by Paul Dubois. And ->rows() isn't in there!
I looked again in the DBI docs and low and behold, there it was all the
time!
Thanks,
Jeff
------------------------------
Date: Sat, 18 Jan 2003 17:32:29 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Most efficient way to do this DBI thing?
Message-Id: <x7adhy4b4i.fsf@mail.sysarch.com>
>>>>> "JS" == Jeff Snoxell <Jeff@aetherweb.co.uk> writes:
JS> My manual was MySQL by Paul Dubois. And ->rows() isn't in there!
because rows() is a DBI method and not a mysql thing. the mysql book is
not a dbi reference.
JS> I looked again in the DBI docs and low and behold, there it was all the
JS> time!
part of rtfm is knowing which fm to r.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: 18 Jan 2003 18:40:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Most efficient way to do this DBI thing?
Message-Id: <b0c73l$btr$2@mamenchi.zrz.TU-Berlin.DE>
Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> part of rtfm is knowing which fm to r.
...and part is knowing which part of the fm to r.
Anno
------------------------------
Date: 18 Jan 2003 19:39:00 GMT
From: ctcgag@hotmail.com
Subject: Re: Most efficient way to do this DBI thing?
Message-Id: <20030118143900.110$be@newsreader.com>
"Jeff Snoxell" <Jeff@aetherweb.co.uk> wrote:
> > > It
> > > doesn't seem to be in my manual.
> > ^^^^^^^^^
> >
> > What manual is that?
> >
> > Use the docs Luke!
>
> :)
>
> My manual was MySQL by Paul Dubois. And ->rows() isn't in there!
My manual is MySQL by Paul DuBois, And ->rows() is in there, along with
the warning not to use it on selects. I guess the capital B makes all the
difference :)
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Sat, 18 Jan 2003 16:29:10 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: OT Re: Append a text at the top an existing file
Message-Id: <qhfW9.4832$FT2.1708@nwrddc03.gnilink.net>
Matija Papec wrote:
> X-Ftn-To: Jürgen Exner
>
> "Jürgen Exner" <jurgenex@hotmail.com> wrote:
>>> Is it another character than ">>" I could us in order to have the
>>> appending happening at the top of the file ?
>>
>> Which part of PerlFAQ5 "How do I change one line in a file/delete a
>> line in a file/insert a line in the middle of a file/append to the
>> beginning of a file?" is unclear and needs improvement?
>
> Did you ever get any feedback on this famous question? :)
Actually yes. Typically it boils down to (paraphrasing): "None. I just
didn't find it [those are the nice people]/didn't bother to look for it".
Real changes: no, not yet.
jue
------------------------------
Date: 18 Jan 2003 20:13:30 GMT
From: ctcgag@hotmail.com
Subject: Re: perl hashes seems to slow down
Message-Id: <20030118151330.132$Ct@newsreader.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> Given the slowness of tie()d variables, I've occasionally bypassed
> tieing altogether, and done:
>
> my $db = SDBM_File->TIEHASH('filename', O_RDWR|O_CREAT, 0666);
> my $x = $db->FETCH($key);
> $db->STORE($key, $value);
> undef $db;
>
> This is generally much faster, with the only drawback being that you
> can't use $db in places where a hashref is expected... you can only use
> it in places that "know" that it's an object.
Couldn't you do
my $db = tie %hash, 'SDBM_File', 'filename', O_RDWR|O_CREAT, 0666;
Then use $db->*() where you are really concerned about speed, while
still having the flexibility of using \%hash in legacy code that
isn't used as intensively and you don't want to rewrite?
Or does tieing cause some generalized slowdown, like $' and $` do
for regexes?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: 18 Jan 2003 20:55:24 GMT
From: ctcgag@hotmail.com
Subject: Re: perl hashes seems to slow down
Message-Id: <20030118155524.598$RR@newsreader.com>
nayeem@ntlworld.com (nayeem) wrote:
> fellow japhs,
> ive been using perl hashes for a recent project, but it seems for some
> reason it gives a speed issue when i am browsing through the hash.
> the hash is roughly the following structure :
>
> $rs = {'SUGGESTED_WORDS' => [
> {'NAME' => '...'},
> {'NAME' => '...'},
> {'NAME' => '...'},
> {'NAME' => '...'},
> ...
> ]
> };
That seems like a rather unclever design.
> =1= for (my $i=0;$i<scalar(@{$rs->{SUGGESTED_WORDS}});$i++) {
> =2= my $word = $rs->{SUGGESTED_WORDS}->[$i];
> =3= my $the_word = $rs->{SUGGESTED_WORDS}->[$i]->{WORD};
> =4= $word->{URL} = "abc";
> =5= }
>
> now questions:
> 1) if i change line =3= to be
> my $the_word = $word->{WORD}
> the system becomes extremely slow in making this simple assignment...
> anyone knows why this happens?
I do not believe you. Please post a complete, compact, working program
that demonstrates this effect.
> is it a bug built-into perl? or am i
> missing something obvious?
I suspect that what you are missing lies in a part of the code that
you did not post.
>
> 2) if i change line =4= to be
> $rs->{SUGGESTED_WORDS}->[$i]->{URL} = "abc"
> the assignment never happens. again, anyone knows what reason lies
> behind this?
Again, I do not believe you.
use strict;
my $rs = {'SUGGESTED_WORDS' => [
map {+{'NAME' => join "", map chr(65+rand(26)), 1..3}} 0..100000
]
};
for (my $i=0;$i<scalar(@{$rs->{SUGGESTED_WORDS}});$i++) {
my $word = $rs->{SUGGESTED_WORDS}->[$i];
# Toggle1
# my $the_word = $rs->{SUGGESTED_WORDS}->[$i]->{WORD};
my $the_word = $word->{WORD};
# Toggle2
# $word->{URL} = join "", map chr(97+rand(26)), 1..3;
$rs->{SUGGESTED_WORDS}->[$i]->{URL} = join "", map chr(97+rand(26)),
1..3;
}
By toggling the comment between the first set of two lines, I see
that what you say is slower is, for me, faster.
By toggling the comment between the 2nd set of two lines, and adding
a Data::Dumper call at the end, I see that the assignment is performed
in either case.
> 3) i am a bit concerned about use of hashes in general. the
> application i am writing is very mission critical in that it requires
> very fast response time, if there is any way i can improve on the
> speed by replacing hash with something else
Depends on the use of the hash. If you are simply using the hash
to represent C's equivalent of a data structure, which it appears you
may be doing, using an array (or even separate parallel structures) would
be faster (and more memory efficient). Ask yourself, do I, as the
programmer, know what all allowed keys of the hash are at compile time? If
so, you could use an array instead. Instead of saying
{Name=>'Dubya', Rank=>'CinC', SerialNo=>'2'}, you could use
['Dubya','CinC','2'], and just remember that slot 0 is name, slot 1 is
Rank, and slot 2 is SerialNo.
On the other hand, if the keys to the hash are not all known at compile
time, but rather are truly variable, then you'll be hard to beat a hash
for performance (as long as it doesn't start swapping). i.e.
{ Dubya => ['CinC',2] , Smith=>['Private',15831354] }
> or anything i would very
> much like to know more on that since i am using a very large hash that
> actually has a massive XML output in it.
That isn't very informative. If the hash had a very large collection
of pornography in it, would that somehow change things?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Sat, 18 Jan 2003 11:35:00 -0500
From: Andrew Lee
Subject: Re: perl installation question
Message-Id: <qdvi2v00pcqgik5ngjnbe6m82ae6d95q05@4ax.com>
On 18 Jan 2003 13:55:40 -0000, phil@ox.compsoc.net (Philip George)
wrote:
>Can anyone help me with this...?
>
>We have a RedHat 7.3 box with Perl 5.6.1 installed in /usr/bin + /usr/lib.
>
>I have an application that requires Perl 5.005_3 so I have downloaded that.
>I wish to keep the existing Perl installation, but install 5.005_3 as well.
>
>I also need to install some modules such as ORBit (amongst many other things).
>
>In the 'sh Configure' stage I am telling it to put perl in /usr/bin/perl5005
>with the libraries in /usr/lib/perl5005lib.
>
>My questions:
>1. it is asking me to specify whichg #! string should automatically start
>Perl. Should I just enter '/usr/bin/perl5005'? Presumably I will then have
>to reaplce all the '#!/usr/bin/perl' text at the top of my scripts with
>'#!/usr/bin/perl5005' too?
Yes.
>2. In order to run my scripts do I need to modify my $PATH or $PERL5LIB
>(or any other environment varialbes) in any way to get perl5005 to work
>properly?
If /usr/bin is in your path, no. If /usr/lib is in PERL5LIB, no -- but
see below.
>3. I want to install external modules such as ORBit, COPE etc into a separate
>directory /usr/lib/perl5005_modules. How can I do this? Also, how do I then
>tell Perl5.005_3 to look in this directory (just add it to PERL5LIB?)
When you install you will have to add extra information to the install
script -- see perldoc -q install and perldoc ExtUtils::MakeMaker (pay
special attention to the make install section)
>4. As an aside we already have ORBit, COPE etc installed for Perl5.6.1, in
>/usr/lib/perl_modules. Will it work if I just copy all of this directory to
>/usr/lib/perl5005_modules? (to save reinstalling all of them).
>
Maybe, maybe not -- depends on the requirements of the modules -- if
they are using features of perl 5.6.1 that are not in 5.005 you will
have some problems.
Personally I have never had to go backwards for an install -- so I
can't anticipate the problems associated to that. I would caution you
against installing the libraries that are bundled with perl5005 into
an existing directory ... you will clobber some libraries that want to
use perl 5.6.1. Also -- you do not want to clobber perldoc, pod2html,
h2xs .. etc. You might want to install perl5005 into
/usr/perl5005/bin or some such.
hth
I'd put all 5005 libraries in a seperate directory and append that
directory to PERL5LIB.
------------------------------
Date: Sat, 18 Jan 2003 11:04:10 -0500
From: Andrew Lee
Subject: Re: Using domain.com/?query+string and domain.com/index.cgi?query+string...
Message-Id: <nbui2v4qa0dairg8q695qq8cu1urmmceor@4ax.com>
On 17 Jan 2003 22:49:15 -0800, krakle@visto.com (krakle) wrote:
>I have an index.cgi script on my site.
>When goin to http://domain.com the script is called.
>When i use http://domain.com/?query+string the query string is chopped
>off as if never existed and in the browser address bar I see
>http://domain.com/index.cgi.
Do you know how to use cgi? THere are more than a few tutorials out
there.
domain.com/?query+string sends the web server some info after the
address -- since you are not explicitly calling index.cgi is the
server supposed to call it for you? With those parameters? That
looks odd to me.
You might want a URL like :
http://domain.com/cgi-bin/index.cgi?query=string
But that is just a guess. I have no idea what your setup is and what
you expect.
------------------------------
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 4426
***************************************