[21771] in Perl-Users-Digest
Perl-Users Digest, Issue: 3975 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 15 14:06:22 2002
Date: Tue, 15 Oct 2002 11:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 15 Oct 2002 Volume: 10 Number: 3975
Today's topics:
$variable as value in %hash <No_Mail_Address@cox.net>
Re: $variable as value in %hash (Tad McClellan)
ANNOUNCE: AFS module bundle version 2.03 released (Norbert Gruener)
ANNOUNCE: Printer 0.97 on cpan <s.patterson@freeuk.com>
ANNOUNCE: Term::Interact 0.44 <prlawrence@lehigh.edu>
Re: array of array? <goldbb2@earthlink.net>
can perl do this? (NNTP)
Re: can perl do this? (Zachary Beane)
Re: can perl do this? (tî'pô)
Re: can perl do this? <goldbb2@earthlink.net>
Converting undefined strings to null strings (Tim Behrendsen)
Re: Converting undefined strings to null strings <goldbb2@earthlink.net>
Re: Converting undefined strings to null strings <krahnj@acm.org>
Re: Converting undefined strings to null strings <uri@stemsystems.com>
grepmail 4.80 released <david@coppit.org>
Re: http://lists.perl.org (slightly OT) <goldbb2@earthlink.net>
Re: http://lists.perl.org (slightly OT) <troc@netrus.net>
Re: http://lists.perl.org (slightly OT) <Tassilo.Parseval@post.rwth-aachen.de>
Re: newbie question (Tad McClellan)
Re: newbie question <krahnj@acm.org>
Re: newbie question (Tad McClellan)
Re: Novice seeks help (Tad McClellan)
Re: OS interface <frank.winkler@sun.com>
Re: OS interface (tî'pô)
Re: OS interface <goldbb2@earthlink.net>
Re: Perl Memory Management <vilmos@vilmos.org>
Re: Perl Memory Management <goldbb2@earthlink.net>
Re: Perl Memory Management <goldbb2@earthlink.net>
Random Character Picker <spam@stinks.com>
Re: Regular Expression Hell (RealServer Log) (Tad McClellan)
Re: tee <dover@nortelnetworks.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 15 Oct 2002 15:41:12 GMT
From: Fred <No_Mail_Address@cox.net>
Subject: $variable as value in %hash
Message-Id: <3DAC374D.F72DDA@cox.net>
I want to use today's date in a hash.
I tried multiple variations of typeglob but did not find a solution.
I tried multiple variations for the value of title => ...
my $today = time() ;
my $today1 = localtime($today) ;
my $date = $today1 ;
*date = *today1 ;
my %vars = (
title => 'friends_01',
date => 'date',
);
---
Fred
------------------------------
Date: Tue, 15 Oct 2002 10:52:56 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: $variable as value in %hash
Message-Id: <slrnaqoeeo.3pf.tadmc@magna.augustmail.com>
Fred <No_Mail_Address@cox.net> wrote:
> I want to use today's date in a hash.
> my %vars = (
> title => 'friends_01',
> date => 'date',
date => scalar localtime,
> );
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 15 Oct 2002 11:33:46 -0500
From: nog@Mpa-Garching.MPG.DE (Norbert Gruener)
Subject: ANNOUNCE: AFS module bundle version 2.03 released
Message-Id: <3dac436a$1_2@news.teranews.com>
=head1 AFS Module Bundle Version 2.03
I am pleased to announce the AFS module bundle version 2.03
The AFS module bundle is a dynamically loadable extension to Perl. It
gives the AFS user and administrator access to many of the AFS
programming APIs, allowing you to make these calls directly from Perl,
rather then processing the output of a command. The AFS module bundle is
a thin layer above the low-level AFS APIs.
=head1 Where To Get It
The version 2.03 is now available on CPAN and on the project site
http://www.cpan.org/authors/id/N/NO/NOG/AFS-2.03.tar.gz
http://www.MPA-Garching.MPG.de/~nog/perl/AFS-2.03.tar.gz
=head1 New In Version 2.03
=over 4
=item * Memory leaks in several modules fixed
Memory leaks in the following subroutines have been fixed:
'AFS::KAS::KAM_GetStats', 'AFS::KAS::KAM_Debug',
'AFS::KAS::KAM_GetEntry', 'AFS::PTS::listentry',
'AFS::PTS::PR_ListEntry', 'AFS::PTS::dumpentry',
'AFS::PTS::PR_DumpEntry', and 'AFS::ACL::retrieve'.
=back
=head1 AUTHORS
The current release was written by
Norbert E. Gruener S< E<lt>nog@MPA>S<-Garching.MPG.deE<gt>. >
The original module was written by
Roland Schemers S< E<lt>schemers@slapshot.stanford.eduE<gt>. >
=cut
Norbert
--
Ceterum censeo | PGP encrypted mail preferred.
Redmond esse delendam. | PGP Key at www.MPA-Garching.MPG.de/~nog/
------------------------------
Date: 10 Oct 2002 12:04:51 GMT
From: Stephen Patterson <s.patterson@freeuk.com>
Subject: ANNOUNCE: Printer 0.97 on cpan
Message-Id: <3dac4331_7@news.teranews.com>
Printer.pm - a low-level, platform independent printing interface
(curently Linux and MS Win32. other UNIXES should also work.)
This version includes working support for Windows 95 and some changes to
make it work with windows 2000 and XP.
I've fixed known bugs from the previous release, and modified some wof the
window printing to accommodate windows 2000 and XP. I'll add a windows
package to http://perlprint.sf.net/ soon.
--
Stephen Patterson http://www.lexx.uklinux.net/ /"\
steve@SPAM.lexx.uklinux.net remove SPAM to reply \ /
Linux Counter No: 142831 GPG Public key: 252B8B37 X
ASCII Ribbon Campaign against HTML mail & news / \
------------------------------
Date: Fri, 11 Oct 2002 09:14:41 -0400
From: Phil R Lawrence <prlawrence@lehigh.edu>
Subject: ANNOUNCE: Term::Interact 0.44
Message-Id: <3dac4342$2_2@news.teranews.com>
Term::Interact 0.44 -- On CPAN now!
__OVERVIEW__
Couldn't your scripting life use some simplicity? Who could resist this...
my $ti = Term::Interact->new;
my $num = $ti->get(
msg => 'Enter a single digit number.',
prompt => 'Go ahead, make my day: ',
re_prompt => 'Try Again Here: ',
check => [
qr/^\d$/,
'%s is not a single digit number!'
]
);
or this...
my $ti = Term::Interact->new(succinct=>1);
my $group = $ti->get(
name => 'groupname',
default => 'staff',
check => [
sub{getgrnam shift},
'%s is not a valid group'
]
);
The get method will prompt the user, validate input, reprompt,
timeout, limit tries... all the stuff you currently do by hand.
Whether its users who need detailed handholding or sysadmins who can
take a more succinct prompting, Term::Interact is *the* way to
interactively get validated data.
__CHANGES__
- custom check functionality was broken; now fixed.
- added 'succinct' parameter to allow less wordy
interaction.
- added 'echo' parameter to tell get() method to echo
validated input to FH_OUT before it returns.
- added 'check_default' parameter to force validation
of default value if it is chosen.
__README__
Term/Interact version 0.44
==========================
NAME
Term::Interact - Interactively Get Validated Data
SYNOPSIS
use Term::Interact;
my $ti = Term::Interact->new( @args );
# get validated data interactively
$validated_data = $ti->get( @args );
# check existing data non-interactively
die "Invalid!" unless $ti->validate( $data, @args );
DESCRIPTION
Term::Interact enables you to interactively get validated
data from a user. This is accomplished via a *simple*
API, wherein you specify various parameters for prompting
the user, as well as "checks" with which gotten data will
be validated.
VARIETIES OF CHECKS:
Term::Interact comes with support for six varieties of check
expressions:
sql_check
*str*: A SQL statement (i.e. 'SELECT field FROM table'). Will be
used to generate a list of validation values from a database.
Valid data is that which appears in the list.
regex_check
*qr//*: A compliled regular expression used to validate data.
Valid data is that which matches the regular expression.
list_check
*aref*: An aref of values used to validate data. Valid data is
that which appears in the list.
compare_check
*str*: A comparison test in string form. Valid data is that
which satisfies the comparison test.
filetest_check
*str*: A filetest operator in string form. Valid data is that
which satisfies the filetest operator.
custom_check
*coderef*: For special occasions (or to make use of Perl's built
in functions), you can write your own custom check. This must be
a reference to a function that accepts one value and returns
true if that value is valid. Example:
check => [ sub{getgrnam shift}, '%s is not a valid group' ]
NOTE ON AVAILABLE CHECK TYPES:
This module steers clear of offering explicit checks like
'phone_number_check' or 'email_address_check'. In the author's
opinion one may generally obtain all the convenience and code
readability one needs via the built in varieties of checks.
However, if you have regular need for complex additional checks,
you'll likely want to steer clear of the built in custom_check
option (see above), which is most appropriate for small anonymous
subroutines, especially those which make use of Perl's built in
functions. You can permanently add complex custom checks by
subclassing Term::Interact and providing the desired checks as
subroutines (all the check subs follow a simple API, just follow
the pattern from the source code). Additionally you will need to
modify the private _classify_check_type function.
ONE EXAMPLE
my $num1 = $ti->get(
msg => 'Enter a single digit number.',
prompt => 'Go ahead, make my day: ',
re_prompt => 'Try Again Here: ',
check => [
qr/^\d$/,
'%s is not a single digit number!'
]
);
#
# Resulting Interaction looks like:
#
# Enter a single digit number.
# Go ahead, make my day: w
# 'w' is not a single digit number!
# Try Again Here: 23
# '23' is not a single digit number!
# Try Again Here: 2
DOCUMENTATION
For more examples and full documentation, see
perldoc Term::Interact
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
DEPENDENCIES
This module requires these other modules:
Text::Autoformat
Term::ReadKey
Date::Manip
File::Spec
COPYRIGHT AND LICENCE
Copyright (C) 2002 Phil R Lawrence. All rights reserved.
This module is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
------------------------------
Date: Tue, 15 Oct 2002 13:14:45 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: array of array?
Message-Id: <3DAC4D05.61AC210C@earthlink.net>
jackkon wrote:
>
> hi, all
> How to the convert a text file below to the array of array?
> Thanks a lot.
>
> ========text file
> 01 AAAA-F.
> 03 AA-ERR PIC S9(05).
> 03 AA-FNAME PIC X(10).
> 03 AA-COUNT-K PIC 9(10).
> 01 AAAA-R.
> 03 AA-REC-KEY.
> 05 AA-DEPT-NO PIC X(02).
> 05 AA-DEPT-MAX PIC X(02).
> 03 AA-DEPT-NAME PIC X(12).
> 03 AA-BED-NO PIC 9(05).
> 03 AA-TOT-BED-NO PIC 9(05).
>
> ========array of array
> [
> 01 AAAA-F.
> [
> 03 AA-ERR PIC S9(05).
> 03 AA-FNAME PIC X(10).
> 03 AA-COUNT-K PIC 9(10).
> ]
> 01 AAAA-R.
> [
> 03 AA-REC-KEY.
> [
> 05 AA-DEPT-NO PIC X(02).
> 05 AA-DEPT-MAX PIC X(02).
> ]
> 03 AA-DEPT-NAME PIC X(12).
> 03 AA-BED-NO PIC 9(05).
> 03 AA-TOT-BED-NO PIC 9(05).
> ]
> ]
This solution was inspired by both tassilo's and david's solutions, but
I believe it to be simpler and more elegant.
my @data;
while( <DATA> ) {
chomp;
my ($depth, $hasinfo) = /(\d+) \S+(\s?)/;
my $dref = \@data;
$dref = $dref->[-1] for 1 .. ($depth - 1) / 2;
push @$dref, $_;
push @$dref, [] if !$hasinfo;
}
[untested]
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 15 Oct 2002 08:37:44 -0700
From: news8080@yahoo.com (NNTP)
Subject: can perl do this?
Message-Id: <110fc16.0210150737.6b1965f@posting.google.com>
I'd like to have perl watch a directory for me to see if a specific
file gets created, and if it does, save a copy. (another program
creates and deletes the file).
I can write a shell script that does this but that seems to take cpu
to 100% all the time. I am sure perl has a way to write a low-cpu
intensive deamon that would do this for me.
any ideas? the file I'd like to watch is /etc/maillog.txt
it gets created and deleted automatically by a program and I'd like a
copy eveytime it was created.
Thanks.
------------------------------
Date: Tue, 15 Oct 2002 16:04:52 GMT
From: xach@xach.com (Zachary Beane)
Subject: Re: can perl do this?
Message-Id: <slrnaqof8a.b8v.xach@localhost.localdomain>
In article <110fc16.0210150737.6b1965f@posting.google.com>, NNTP wrote:
> I'd like to have perl watch a directory for me to see if a specific
> file gets created, and if it does, save a copy. (another program
> creates and deletes the file).
>
> I can write a shell script that does this but that seems to take cpu
> to 100% all the time. I am sure perl has a way to write a low-cpu
> intensive deamon that would do this for me.
>
> any ideas? the file I'd like to watch is /etc/maillog.txt
>
> it gets created and deleted automatically by a program and I'd like a
> copy eveytime it was created.
Whether you do it in Perl or in shell, the key to using less than 100%
CPU is to only check periodically and sleep in between checks. For
example, to check for the file once per second in (ba)sh:
while true; do
if [ -e /etc/maillog.txt ]; then
cp /etc/maillog.txt somewhere-else.txt
fi
sleep 1
done
In perl, it would be similar:
use File::Copy;
while (1) {
if (-e "/etc/maillog.txt") {
copy("/etc/maillog.txt", "somewhere-else.txt");
}
sleep(1);
}
The longer your check interval can be, the less CPU your program will
use overall.
Zach
------------------------------
Date: Tue, 15 Oct 2002 18:25:23 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: can perl do this?
Message-Id: <79goquktvq3sm93j5elcvm03q66cbvtrlk@4ax.com>
Zachary Beane bravely attempted to attach 42 electrodes of knowledge
to the nipples of comp.lang.perl.misc by saying:
>Whether you do it in Perl or in shell, the key to using less than 100%
>CPU is to only check periodically and sleep in between checks.
>
<snip>
>The longer your check interval can be, the less CPU your program will
>use overall.
And the more likely you are to miss a file that was created and
deleted while you were sleeping...
------------------------------
Date: Tue, 15 Oct 2002 13:30:14 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: can perl do this?
Message-Id: <3DAC50A6.8CA030B7@earthlink.net>
Teh (tî'pô) wrote:
>
> Zachary Beane bravely attempted to attach 42 electrodes of knowledge
> to the nipples of comp.lang.perl.misc by saying:
> >Whether you do it in Perl or in shell, the key to using less than
> >100% CPU is to only check periodically and sleep in between checks.
> >
> <snip>
> >The longer your check interval can be, the less CPU your program will
> >use overall.
>
> And the more likely you are to miss a file that was created and
> deleted while you were sleeping...
To decrease that possibility to a minimum, you would need to have an OS
and filesystem which will inform your program of filesystem events upon
request. Eg, on windows, you can use Win32::ChangeNotify to watch the
directory in which the file is to appear. I'm not sure what other OSs
offer this functionality -- probably plan9 does :)
Better yet, have the program which creates the file inform your program
that it's made the file, and then wait for your program to process/copy
it/whatever before deleting it.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 15 Oct 2002 10:24:43 -0700
From: nospam@behrendsen.com (Tim Behrendsen)
Subject: Converting undefined strings to null strings
Message-Id: <6d726a77.0210150924.1a93523c@posting.google.com>
I looked through the FAQ and Google, but I can't find a good answer to
this, which I assume would be a pretty common situation.
Often I get data from a database that may be a null string or an
undefined value. I want to compare it to '' without getting warning
messages, so I usually resort to having a subroutine like:
sub CvtNull
{
return defined($_[0]) ? $_[0] : '';
}
[...]
if (CvtNull($var) eq '') {
...
}
Is there a better/stronger/faster way to do this? Hopefully a built-in
Perl function that might have the side effect of converting undefined
values to nulls.
Thanks in advance,
Tim Behrendsen
------------------------------
Date: Tue, 15 Oct 2002 13:50:27 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Converting undefined strings to null strings
Message-Id: <3DAC5563.43D5E213@earthlink.net>
Tim Behrendsen wrote:
>
> I looked through the FAQ and Google, but I can't find a good answer to
> this, which I assume would be a pretty common situation.
>
> Often I get data from a database that may be a null string or an
> undefined value. I want to compare it to '' without getting warning
> messages,
Then you should use the lexical pragma, "no warnings qw(undefined);" in
the scope of the place where you're doing that comparison.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Tue, 15 Oct 2002 17:49:14 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Converting undefined strings to null strings
Message-Id: <3DAC54EE.C639B41F@acm.org>
Tim Behrendsen wrote:
>
> I looked through the FAQ and Google, but I can't find a good answer to
> this, which I assume would be a pretty common situation.
>
> Often I get data from a database that may be a null string or an
> undefined value. I want to compare it to '' without getting warning
> messages, so I usually resort to having a subroutine like:
>
> sub CvtNull
> {
> return defined($_[0]) ? $_[0] : '';
> }
>
> [...]
>
> if (CvtNull($var) eq '') {
> ...
> }
>
> Is there a better/stronger/faster way to do this? Hopefully a built-in
> Perl function that might have the side effect of converting undefined
> values to nulls.
$var ||= '';
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 15 Oct 2002 18:03:05 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Converting undefined strings to null strings
Message-Id: <x7y98zbmw6.fsf@mail.sysarch.com>
>>>>> "JWK" == John W Krahn <krahnj@acm.org> writes:
JWK> Tim Behrendsen wrote:
>> Often I get data from a database that may be a null string or an
>> undefined value. I want to compare it to '' without getting warning
>> messages, so I usually resort to having a subroutine like:
>>
>> sub CvtNull
>> {
>> return defined($_[0]) ? $_[0] : '';
>> }
>>
>> Is there a better/stronger/faster way to do this? Hopefully a built-in
>> Perl function that might have the side effect of converting undefined
>> values to nulls.
JWK> $var ||= '';
classic conversion bug. what happens if $var is '0'?
larry has okayed the // operator in perl and maybe even in later
versions of perl5. it is like || but tests for defined and not truth.
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
------------------------------
Date: Sun, 13 Oct 2002 18:31:36 GMT
From: David Coppit <david@coppit.org>
Subject: grepmail 4.80 released
Message-Id: <3dac4356$1_2@news.teranews.com>
Description:
- grepmail is a Perl program that searches a normal or compressed mailbox
(gzip, bzip2, or tzip) for a given regular expression and returns those
emails that match the query. It also supports searches constrained by date
and size, and searches using logical operators.
Download:
- You can download grepmail 4.72 from CPAN:
http://www.cpan.org/authors/id/D/DC/DCOPPIT/grepmail-4.72.tar.gz
- Until the file propagates to the mirrors, you can use the following URL:
http://prdownloads.sourceforge.net/grepmail/grepmail-4.72.tar.gz
Changes:
- Added prototype -E flag to support complex searches. (Thanks to Nelson Minar
for the original suggestion in Sep 2000, And terry jones for seconding the
idea.)
- Added -F flag to force processing of files which grepmail determines are not
mailboxes. (feature suggested by terry jones)
- Documentation updated to reflect that -B no longer exists. (By terry jones)
- The test to determine if a file is a mailbox was improved to adhere better
to RFC 822, while still providing some flexibility. (Initial suggestion and
patch by terry jones)
- Improved date extraction to also look at the 'From ' line when both the
Received and Date headers fail. (patch by terry jones)
- Fixed a long-standing bug in which filenames of compressed mailboxes which
contained special shell characters would cause problems. (Thanks to Jost
Krieger for giving me the kick in the pants to finally fix this.)
- Fixed a long-standing bug in which grepmail would incorrectly report the
filename of compressed mailboxes in error messages. (Thanks to Jost Krieger
for giving me the kick in the pants to finally fix this.)
NOTES
As with last release, this release benefits greatly from the feedback and
insight of Terry Jones. His desire for complex pattern matches, along with
Nelson Minar's original request, is the reason for the new -E flag. This
flag allows you to perform complex searches involving logical operators.
For example,
$email_header =~ /^From: .*\@coppit.org/ && $email =~ /grepmail/i
will find all emails which originate from coppit.org (you must escape the
"@" sign with a backslash), and which contain the keyword "grepmail"
anywhere in the message, in any capitalization.
NOTE: -E support is experimental right now. I'm looking for feedback on the
following:
- Do you like the feature?
- Do you like the Perl-based syntax? Is there an alternative which is
easier?
- How should date and size constraints be integrated? Should they be
"variables", a la:
"$email =~ /grepmail/ && $date <= 'sep 20 1998' || $size > 50000"?
- Should -i, -h, and -b be supported in conjunction with -E? (Where
"-h pattern" would mean augmenting the -E pattern with
"$email_header =~ /pattern/ && ")
- -S ignores signatures. If/when this feature is implemented for -E, should
it be "global" for all $email_body matches, or should it be possible to
specify this for each $email_body match? For example, one can append an
"i" modifier to an individual pattern match to make it case-insensitive.
Should there be a standard way of dealing with such "global" pattern
matching options on an individual pattern match basis?
A complete change log is at:
- http://grepmail.sourceforge.net/CHANGES
Other notes:
- Users wishing to install Mail::Folder::FastReader will need to
install Inline 0.41, available at
http://search.cpan.org/search?dist=Inline
Thanks,
David
_____________________________________________________________________
David Coppit david@coppit.org
The College of William and Mary http://coppit.org/
One thing the blues ain't... is funny. Stephen Stills, "Black Queen"
------------------------------
Date: Tue, 15 Oct 2002 13:21:56 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: http://lists.perl.org (slightly OT)
Message-Id: <3DAC4EB4.C00349EE@earthlink.net>
Tassilo v. Parseval wrote:
>
> Hi,
>
> anyone has an idea what happened to lists.perl.org? It doesn't appear to
> be accessible (at least not since yesterday). This is a little bit
> unfortunate since I intended to subscribe to the perl-xs mailing list and
> now can't find the necessary data (subscription address and so on).
According to http://www.perl.org/support/mailing_lists.html, you should
send an email to majordomo@perl.org with "subscribe perl-xs" in it (it
doesn't say whether that should be in the subject or the body, tho).
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Tue, 15 Oct 2002 17:42:54 -0000
From: Rocco Caputo <troc@netrus.net>
Subject: Re: http://lists.perl.org (slightly OT)
Message-Id: <slrnaqoksn.8ma.troc@eyrie.homenet>
On 15 Oct 2002 14:46:16 GMT, Tassilo v. Parseval wrote:
>
> anyone has an idea what happened to lists.perl.org? It doesn't appear to
> be accessible (at least not since yesterday). This is a little bit
> unfortunate since I intended to subscribe to the perl-xs mailing list and
> now can't find the necessary data (subscription address and so on).
Nearly all of the mailing lists at perl.org respond to a blank message
to <listname-help@perl.org>.
Also check if your newsfeed has a perl.xs newsgroup.
-- Rocco Caputo / troc@pobox.com / poe.perl.org / poe.sf.net
------------------------------
Date: 15 Oct 2002 17:55:27 GMT
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: http://lists.perl.org (slightly OT)
Message-Id: <aohkqf$5d$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Benjamin Goldberg:
> Tassilo v. Parseval wrote:
>> anyone has an idea what happened to lists.perl.org? It doesn't appear to
>> be accessible (at least not since yesterday). This is a little bit
>> unfortunate since I intended to subscribe to the perl-xs mailing list and
>> now can't find the necessary data (subscription address and so on).
>
> According to http://www.perl.org/support/mailing_lists.html, you should
> send an email to majordomo@perl.org with "subscribe perl-xs" in it (it
> doesn't say whether that should be in the subject or the body, tho).
Thanks. :-) I did not know about the site you quoted. I just hope I will
ever receive a reply. Before my post here, I sent two mails to two
different addresses that looked promising to me
(perl-xs-subscribe@perl.org was one). Odd that I received no reply at
all...not even a failure-message. Well. *knocking on wood*
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Tue, 15 Oct 2002 10:04:02 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie question
Message-Id: <slrnaqobj2.3iq.tadmc@magna.augustmail.com>
Patrick <patrick@-/abazar\-.nl> wrote:
> read file
> var1 = firstpart of the line between the <>
> var2 = secondpart of the line
> var3 = thirdpart of line between the <>
> replace all <> with nothing ...
--------------------------------------
#!/usr/bin/perl
use warnings;
use strict;
while ( <DATA> ) {
if ( s/^ <([^>]*)> (.*) <([^>]*)> $/$2/x ) {
my($var1, $var2, $var3) = ($1, $2, $3);
print;
print " $var1\n $var2 \n $var3\n";
}
}
__DATA__
<123455>786898988989829892<plokij>
<000455>788989829892<qawsedrf>
<000455>plokiju788989829892<plok909090>
--------------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 15 Oct 2002 16:01:11 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: newbie question
Message-Id: <3DAC3B9A.EE77F782@acm.org>
Patrick wrote:
>
> I have a ascii file with some sort of info:
>
> <123455>786898988989829892<plokij>
> <000455>788989829892<qawsedrf>
> <000455>plokiju788989829892<plok909090>
>
> Is it possible to read this file and create some vars, something like
> this:
>
> read file
> var1 = firstpart of the line between the <>
> var2 = secondpart of the line
> var3 = thirdpart of line between the <>
> replace all <> with nothing ...
>
> print var1,var3,var4
$ perl -e'
foreach ( q[<123455>786898988989829892<plokij>],
q[<000455>788989829892<qawsedrf>],
q[<000455>plokiju788989829892<plok909090>] ) {
( $var1, $var2, $var3 ) = /([^<>]+)/g;
print "$var1 $var2 $var3";
}
'
123455 786898988989829892 plokij
000455 788989829892 qawsedrf
000455 plokiju788989829892 plok909090
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 15 Oct 2002 11:37:51 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie question
Message-Id: <slrnaqoh2v.3s7.tadmc@magna.augustmail.com>
Patrick <patrick@-/abazar\-.nl> wrote:
> Subject: newbie question
Please put the subject of your article in the Subject of your article.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 15 Oct 2002 09:57:29 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Novice seeks help
Message-Id: <slrnaqob6p.3iq.tadmc@magna.augustmail.com>
Trevor Johnson <bpfsa@yahoo.com> wrote:
> I am a total novice in any form of programming
Then you should experiment with getting programs to work from
the command line first.
That avoids all of the CGI issues, leaving only Perl issues.
After it works well from the command line, _then_ move it
to the CGI environment.
> I have spent the last four days scouring websites, reading manuals,
> experimenting with modifying free scripts, and so forth to create for myself
> a very, very simple PERL CGI program..... Alas, novicehood reigns, and I am
> stuck. Embarrassingly stuck.
Did you try this one?
perldoc -q CGI
> What I am attempting to do is so basic, it seems no-one online has thought
> about making such a basic script available (or at least I cannot find one).
All you need to do is print() the correct headers and the HTML.
> I have no doubt that a competent PERL programmer
There _are no_ competent PERL programmers. :-)
There are competent Perl programmers, and competent perl programmers though.
perldoc -q "perl.*Perl"
What's the difference between "perl" and "Perl"?
> I am trying to write a PERL script which simply creates a CGI generated HTML
> page.
>
> I will show below my best (embarrassing) effort so far.... It does *not*
> work,
How do you know that it is not working?
That is, what do you observe when you try it?
Sharing the symptoms and messages that you get will help
us to help you...
> Could someone please put me out of my misery by pointing out the error of my
> way and showing me how to actually do this properly?
> #!/usr/bin/perl
>
> use CGI
^^
^^
syntax error.
You could have caught this at the command line.
Get your Perl programs working on the command line before
moving them to the CGI environment.
> print "<body>If this appears in the browser when this script is executed,
> then this script works.</body></html>;
^^
Yet another syntax error that you could have found at the command line...
----------------------------
#!/usr/bin/perl
use warnings;
use strict;
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/html\n\n";
print "<html><head><title>Testing</title></head>\n";
print "<body>If this appears in the browser when this script is executed, then this script works.</body></html>";
----------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 15 Oct 2002 17:31:11 +0200
From: Frank Winkler - Sun Germany - Enterprise Services <frank.winkler@sun.com>
Subject: Re: OS interface
Message-Id: <1034695871.623848@intranet.consol.de>
Koos Pol wrote:
> Not that I know of, but then again... the goal is commendable but my guess
> is you will be overtaken by reality pretty quick: The output for these
> commands will probably be not the same. That means you need to interpretate
Surely it won't. But that's exactly the purpose of this intermediate layer
which shall abstract from the actual OS being used. What I want to get is a
function which tells me for example if a process named 'foo' is running
with some certain options - independent from a special command or output
syntax.
If there's no usable solution yet, what would be the best way to achieve
this? A pm file which issues commands, depending on the OS or a binary
layer? Or something else?
Regards
--
---------------------------------------------------------------------------
Frank Winkler frank.winkler@germany.sun.com
Sun Microsystems - Remote Admin Center
Sonnenallee 1 Voice +49 89 46008.2755
85551 Heimstetten - Germany Fax +49 89 46008.2740
------------------------------
Date: Tue, 15 Oct 2002 18:22:54 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: OS interface
Message-Id: <ohfoqusii1hs98gqcm63japu85gl463t47@4ax.com>
Frank Winkler - Sun Germany - Enterprise Services bravely attempted to
attach 25 electrodes of knowledge to the nipples of
comp.lang.perl.misc by saying:
>If there's no usable solution yet, what would be the best way to achieve
>this? A pm file which issues commands, depending on the OS or a binary
>layer? Or something else?
>
>Regards
I would like to use this group as a sounding board for an idea...
How about creating a class which supplies an interface for these
functionalities. e.g.
package ProcessStatus;
# input process id, output true if such a process exist
sub alive {
}
# input user id or name
# output a list of all the processes the user is running
sub users_processes {
}
# etc.
and then derive a class for each OS we're working on.
Now here's the point, have the base class's constructor decide which
derived class to create on runtime.
sub new {
my $os = `uname`;
return SunPS->new if $os =~ /sunos/i;
return AIXPS->new if $os =~ /aix/i;
# etc...
}
Then the correct object is created transparently when a new object is
created.
To a C++ user letting the class decide what it is at runtime seems
weird but is it considered good practice in perl?
------------------------------
Date: Tue, 15 Oct 2002 14:05:42 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: OS interface
Message-Id: <3DAC58F6.36B4B4E3@earthlink.net>
Frank Winkler - Sun Germany - Enterprise Services wrote:
>
> Hi there !
>
> Does anybody know a module which provides an interface to OS specific
> information like "ps" or "df"? I want to prevent explicitly opening a
> command pipe to keep it portable ...
>
> If such a module already existed I wouldn't have to invent the wheel
> myself :) ...
For ps, there's Proc::ProcessTable
I don't know about df, though.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 15 Oct 2002 10:15:08 -0700
From: Vilmos Soti <vilmos@vilmos.org>
Subject: Re: Perl Memory Management
Message-Id: <87d6qbpqsj.fsf@my.vilmos.lan>
michalowski@interred.de (MMichalow) writes:
> I have a question concerning perl's memory management. The Topic is
> about clearing up arrays, so that the memory is given back to the
> operating system.
I have a related question. Suppose I have the following code:
$password = <>;
&authenticate ($password);
$password = "";
At this point, what happens to $password? Is the value still in
memory just is inaccessible? (so it would show up in a coredump?)
If I do a "$password = 'xxx'" then will it overwrite the actual
password so it won't be in memory anymore?
Thanks, Vilmos
------------------------------
Date: Tue, 15 Oct 2002 14:02:44 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl Memory Management
Message-Id: <3DAC5844.9EA31869@earthlink.net>
Michael Carman wrote:
[snip]
> > Is it sufficient to restart single thread?
>
> Hmm... dunno. I've never really played with threads.
Each thread has it's own malloc arena, created with mmap.
When the thread finishes, the entire arena is freed.
So yes, letting the thread die and starting a new one in it's place
*should* be sufficient. *However*, when you start a new thread, it gets
a copy of it's *entire* parent thread's perl interpreter. So, you
should have your 'main' thread (the original one which starts with perl
in it) really minimal, and load as few modules as it can, and only have
the threads it starts load modules, so that if you want to have a thread
get restarted, it can tell the main thread to do that (rather than doing
it itself, which copies too much info, defeating the purpose).
PS: Shared arrays leak memory -- I'm not sure whether restarting a
thread will decrease this leak. Re-execing perl will clean up leaked
data, though :)
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Tue, 15 Oct 2002 14:03:52 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl Memory Management
Message-Id: <3DAC5888.A780F272@earthlink.net>
Vilmos Soti wrote:
>
> michalowski@interred.de (MMichalow) writes:
>
> > I have a question concerning perl's memory management. The Topic is
> > about clearing up arrays, so that the memory is given back to the
> > operating system.
>
> I have a related question. Suppose I have the following code:
>
> $password = <>;
> &authenticate ($password);
> $password = "";
>
> At this point, what happens to $password? Is the value still in
> memory just is inaccessible? (so it would show up in a coredump?)
It's implementation dependent, and subject to change. It might make it
inaccessible, or might not. Don't depend on either behavior.
> If I do a "$password = 'xxx'" then will it overwrite the actual
> password so it won't be in memory anymore?
Maybe, maybe not.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Tue, 15 Oct 2002 17:51:10 GMT
From: "PinkPuppy" <spam@stinks.com>
Subject: Random Character Picker
Message-Id: <hAYq9.526$XsJ4.14286941@news2.randori.com>
I'd like to write a script that generated a specified number of random
characters. I want to be able to specify which characters to choose from.
Can someone show me some simple sample code that does something like this?
------------------------------
Date: Tue, 15 Oct 2002 11:45:45 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regular Expression Hell (RealServer Log)
Message-Id: <slrnaqohhp.3sb.tadmc@magna.augustmail.com>
[ text rearranged to follow the actual chronology. ]
Joe Follansbee <jfollansbee@speakeasy.net> wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnaqmfrg.1vv.tadmc@magna.augustmail.com>...
>> Joe Follansbee <jfollansbee@speakeasy.net> wrote:
>>
>> > I'm tearing me hair out to
>> > build a regex that will match the "client info" entry. The regex has
>> > to be able to find these two typical entries:
>> What is it that distinguishes the "good" lines from the "bad" lines?
>> m/^ [[] [^]]+ ] $/x
> Friends,
Please use a friendly quoting style:
http://www.geocities.com/nnqweb/nquote.html
> I should've included the entire lines when I wrote the post. Here's
> the two lines
There are 9 lines, not 2...
You should figure out how to supress word-wrapping in your
News client when you want to post long lines.
> You can see it's somewhat
> similar to Common Log Format,
What is the Common Log Format?
> but I need to extract the particular
> RealPlayer client info. In the first line, the field starts with the
> string "[Moz..." In the second line, the string I want starts with
> "[WinNT..."
------------------------------
#!/usr/bin/perl
use warnings;
use strict;
while ( <DATA> ) {
print "$1\n" if m/ [[]((Moz|WinNT) [^]]+) ] /x;
}
__DATA__
192.168.1.3 - - [13/Oct/2002:09:03:38 -0700] "GET ramgen/compelinteractive/compel_message.smil HTTP/1.0" 200 383 [Mozilla/4.0 (compatible;MSIE 5.01;Windows NT 5.0;AT&T CSM6.0)] [] [] 186 0 0 0 0 7899
192.168.1.3 - - [13/Oct/2002:09:03:58 -0700] "GET compelinteractive/compel_message.smil?cloakport=8080,554,7 070 RTSP/1.0" 200 1775 [WinNT_5.0_6.0.10.505_play32_RN9GPD_en-US_686_axembed] [54ce7c91-034a-11d6-e54a-c5d718818907] [] 1822 0 19 0 0 7900
------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 15 Oct 2002 10:21:49 -0500
From: "Bob Dover" <dover@nortelnetworks.com>
Subject: Re: tee
Message-Id: <aohbo2$jq0$1@bcarh8ab.ca.nortel.com>
"Olivier Boël" wrote...
>
> Example :
> #!/usr/bin/perl
> print "Starting\n";
> print "Type anything then hit <enter> : ";
> $input = <STDIN>;
> print "You typed $input";
> print "End\n";
Insert the line: "$| = 1;" (without the quotes, of course) prior to your
first print and all will be fine.
------------------------------
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 3975
***************************************