[23882] in Perl-Users-Digest
Perl-Users Digest, Issue: 6085 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 5 18:05:49 2004
Date: Thu, 5 Feb 2004 15:05:07 -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 Thu, 5 Feb 2004 Volume: 10 Number: 6085
Today's topics:
?-xism: <BLOCKSPAMfishfry@your-mailbox.com>
Re: ?-xism: <dwall@fastmail.fm>
Re: Arrays Of Arrays: Is it an Array or Scalar? (Aaron Sherman)
DBI::mysql column names as hash keys? (Tony)
Re: DBI::mysql column names as hash keys? <tadmc@augustmail.com>
Re: DBI::mysql column names as hash keys? <gnari@simnet.is>
Re: Difficulty cleaning oddly encoded whitespace (from (David R. Throop)
Re: Getting STDERR from forked child processes? (Aaron Sherman)
index function problem (shadbo)
Re: index function problem <ittyspam@yahoo.com>
Re: index function problem <syscjm@gwu.edu>
Re: index function problem <tadmc@augustmail.com>
Re: Looking for a FAQ article on autoposting in PERL <cob@hotmail.com>
Re: Looking for a FAQ article on autoposting in PERL <graham.drabble@lineone.net>
Re: newbie help <spam@spammer.com>
Re: newbie help <gnari@simnet.is>
NNTP Subject Parsing $_@_.%_
Re: NNTP Subject Parsing (Walter Roberson)
Re: NNTP Subject Parsing <syscjm@gwu.edu>
Re: NNTP Subject Parsing $_@_.%_
Re: Optimization request (Aaron Sherman)
Re: Optimization request <spamtrap@dot-app.org>
Re: Perl data types <tassilo.parseval@rwth-aachen.de>
Re: problem with "our" (Aaron Sherman)
Re: RDBMS to hold Perl objects? (Aaron Sherman)
Re: <gnari@simnet.is>
top posting: response to gnari <spam@spammer.com>
Re: top posting: response to gnari <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 05 Feb 2004 22:05:39 GMT
From: fishfry <BLOCKSPAMfishfry@your-mailbox.com>
Subject: ?-xism:
Message-Id: <BLOCKSPAMfishfry-9450FD.14053905022004@netnews.comcast.net>
The statement
print qr/abc/;
produces the output
(?-xism:abc)
I looked in man perlop and didn't find a clear description of what this
means. Where's this documented? What's it mean?
------------------------------
Date: Thu, 05 Feb 2004 22:13:56 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: ?-xism:
Message-Id: <Xns9486AF4BAE6D6dkwwashere@216.168.3.30>
fishfry <BLOCKSPAMfishfry@your-mailbox.com> wrote:
> The statement
>
> print qr/abc/;
>
> produces the output
>
> (?-xism:abc)
>
> I looked in man perlop and didn't find a clear description of what this
> means. Where's this documented? What's it mean?
Try perlre instead.
"(?imsx-imsx)"
One or more embedded pattern-match modifiers, to be turned on
(or turned off, if preceded by "-") for the remainder of the
pattern or the remainder of the enclosing pattern group (if
any). This is particularly useful for dynamic patterns, such
...
--
David Wall
------------------------------
Date: 5 Feb 2004 11:33:45 -0800
From: ajs@ajs.com (Aaron Sherman)
Subject: Re: Arrays Of Arrays: Is it an Array or Scalar?
Message-Id: <eaa2c627.0402051133.797a9d21@posting.google.com>
Hal Vaughan <hal@thresholddigital.com> wrote in message news:<AKtUb.185396$nt4.786330@attbi_s51>...
> Is there a simple way to tell if the value of an element in an
> array is a scalar, or is, instead, a reference to another array?
You're confusing your terms a bit. Let's start from the basics:
Arrays are collections of scalars (not anything else... ever).
Scalars can be simple values, references, or other (less common)
things I won't go into here.
So, to re-phase what I think you meant:
"Is there a simple way to tell if an element in an array is a
reference?"
And the answer there would be "ref". You can use "perldoc -f ref" or
"perldoc perlrref" for far, far more information on the topic, but a
reference to an array would return "ARRAY" when you use ref on it.
Thus, you might say:
if (ref($myarray[$i])) {
if (ref($myarray[$i]) eq 'ARRAY') {
# It's a reference to a sub-array, do the right thing....
} else {
warn "I don't know how to cope with refs to
".ref($myarray[$i])." in my array":
}
} else {
# It's a simple scalar value, do the right thing.....
}
Good luck!
------------------------------
Date: 5 Feb 2004 13:17:17 -0800
From: hawkmoon1972@hotmail.com (Tony)
Subject: DBI::mysql column names as hash keys?
Message-Id: <c90e5468.0402051317.54ef6dd1@posting.google.com>
Hello,
Given a DBI::mysql database with 2 tables and 5 columns like so:
human --> name
--> age
--> sex
dog --> breed
--> colour
How can I get variables, named like those below... without knowing the
column names beforehand???
$vars{human.name}
$vars{human.age}
$vars{human.sex}
$vars{dog.breed}
$vars{dog.colour}
I need to do this so the template toolkit can process a template,
regardless of what database columns the template refers to.
Help? :)
------------------------------
Date: Thu, 5 Feb 2004 15:54:19 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: DBI::mysql column names as hash keys?
Message-Id: <slrnc25esb.27u.tadmc@magna.augustmail.com>
Tony <hawkmoon1972@hotmail.com> wrote:
> How can I get variables, named like those below... without knowing the
> column names beforehand???
You are asking how to know the names without knowing the names.
Can't be done, obviously, because it is a contradiction...
> $vars{human.name}
You must quote hash keys that do not match /^\w+$/.
> $vars{human.age}
> $vars{human.sex}
> $vars{dog.breed}
> $vars{dog.colour}
>
> I need to do this so the template toolkit can process a template,
> regardless of what database columns the template refers to.
But is should be possible to discover what the names are:
SHOW TABLES
will give you the names of all of the tables.
SHOW COLUMNS FROM ?
will give you all of the column names from a particular table when
you provide the table name for the placeholder.
That answers your MySQL question.
The answer to your Perl question is:
$key = $table . '.' . $column;
or
$key = "$table.$column";
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 5 Feb 2004 22:09:35 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: DBI::mysql column names as hash keys?
Message-Id: <bvuetb$m3a$1@news.simnet.is>
"Tony" <hawkmoon1972@hotmail.com> wrote in message
news:c90e5468.0402051317.54ef6dd1@posting.google.com...
> Hello,
> ...
> How can I get variables, named like those below... without knowing the
> column names beforehand???
>
> $vars{human.name}
> ...
by reading the DBI docs?
gnari
------------------------------
Date: 5 Feb 2004 16:21:14 -0600
From: throop@cs.utexas.edu (David R. Throop)
Subject: Re: Difficulty cleaning oddly encoded whitespace (from MS HTML)
Message-Id: <bvufkq$ah$1@yojo.cs.utexas.edu>
In article <bvs0se$cm0$1@wisteria.csv.warwick.ac.uk>,
Ben Morrow <usenet@morrow.me.uk> wrote:
> Which perl are you using? If you're using 5.8, try pushing :utf8 or
> (better) :encoding(utf8) onto your input filehandle.
Thanks. I took your suggestion and upgraded to 5.8; needed to, anyways.
Let me beg one more question (cuz my PERL 5 Camel Book won't tell me.)
What's the syntax for opening with :encoding(utf8) ? I've tried
open($FILEname, :encoding(utf8))
open("$FILEname :encoding(utf8)")
and a few other variations and I keep losing.
David Throop
------
------------------------------
Date: 5 Feb 2004 12:04:54 -0800
From: ajs@ajs.com (Aaron Sherman)
Subject: Re: Getting STDERR from forked child processes?
Message-Id: <eaa2c627.0402051204.23c51579@posting.google.com>
Zbigniew Fiedorowicz <fiedorow@hotmail.com> wrote in message news:<bvto7c$9k$1@charm.magnus.acs.ohio-state.edu>...
> How can I catch error messages from external programs forked
> from a Perl cgi process? I can of course read from the web
> server error log, but I am worried that I might be getting
> the wrong error messages from some other web server process
> which is running concurrently.
Do you mean fork()ed or do you mean a truely external program (e.g.
using system, qx{} or fork()/exec)?
Let's use qx{} (aka ``) as a simple example:
method a:
$result_plus_err = qx{/usr/bin/do_stuff 2>&1};
method b:
use IPC::Open3 qw(open3);
use IO::Select;
open3(\*WTRFH, \*RDRFH, \*ERRFH, "/usr/bin/do_stuff");
close WTRFH;
my $r = IO::Select->new(\*RDRFH,\*ERRFH);
and from there you can call the "can_read" method on $r and continue
along your happy way.
------------------------------
Date: 5 Feb 2004 13:49:42 -0800
From: j_schaedel@hotmail.com (shadbo)
Subject: index function problem
Message-Id: <b9e1d65b.0402051349.3af5c7bb@posting.google.com>
I am a perl newbie and I seem to be getting incorrect results from the
index function.
I have a var $string_to_find, which has a value of 'paris'. The string
I am searching has a 'paris' in there and 'pari' I want to extract the
position of 'paris' and not 'pari'. The code below seems to be finding
the position of the first one (pari), which i don't need.
Is it possible to combine regex with the index funtion so it only
searches for 'paris'?
$string_position = index($line,$string_to_find)
Any suggestions would be greatly appreciated.
Thanks
------------------------------
Date: Thu, 5 Feb 2004 16:53:41 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: index function problem
Message-Id: <20040205165305.X483@dishwasher.cs.rpi.edu>
On Thu, 5 Feb 2004, shadbo wrote:
> I am a perl newbie and I seem to be getting incorrect results from the
> index function.
>
> I have a var $string_to_find, which has a value of 'paris'. The string
> I am searching has a 'paris' in there and 'pari' I want to extract the
> position of 'paris' and not 'pari'. The code below seems to be finding
> the position of the first one (pari), which i don't need.
> Is it possible to combine regex with the index funtion so it only
> searches for 'paris'?
>
> $string_position = index($line,$string_to_find)
>
> Any suggestions would be greatly appreciated.
First suggestion would be to post your code so we can figure out what
you're doing wrong. . . .
Paul Lalli
------------------------------
Date: Thu, 05 Feb 2004 17:31:23 -0500
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: index function problem
Message-Id: <4022C43B.3050409@gwu.edu>
Paul Lalli wrote:
> On Thu, 5 Feb 2004, shadbo wrote:
>
>
>>I am a perl newbie and I seem to be getting incorrect results from the
>>index function.
>>
>>I have a var $string_to_find, which has a value of 'paris'. The string
>>I am searching has a 'paris' in there and 'pari' I want to extract the
>>position of 'paris' and not 'pari'. The code below seems to be finding
>>the position of the first one (pari), which i don't need.
>>Is it possible to combine regex with the index funtion so it only
>>searches for 'paris'?
>>
>>$string_position = index($line,$string_to_find)
>>
>>Any suggestions would be greatly appreciated.
>
>
>
> First suggestion would be to post your code so we can figure out what
> you're doing wrong. . . .
Five will get you ten he's using chop() instead of chomp()
on $string_to_find--and $string_to_find didn't have a \n
at the end.
Chris Mattern
------------------------------
Date: Thu, 5 Feb 2004 16:56:55 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: index function problem
Message-Id: <slrnc25ihn.2cn.tadmc@magna.augustmail.com>
shadbo <j_schaedel@hotmail.com> wrote:
> The code below seems to be finding
> the position of the first one (pari), which i don't need.
> $string_position = index($line,$string_to_find)
index() will find the first one.
rindex() will find the last one.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 5 Feb 2004 14:22:07 -0600
From: "cob" <cob@hotmail.com>
Subject: Re: Looking for a FAQ article on autoposting in PERL
Message-Id: <4022a563$0$3734$45beb828@newscene.com>
"cob" <cob@hotmail.com> wrote in message
news:40214ef9$0$70230$45beb828@newscene.com...
> I maintain a FAQ for the misc.immigration.misc newsgroup. I have been
> looking for a short perl snippet to automate FAQ announcements that would
be
>
> There's scripts out there, mail2news, for example. But they are WAY over
my
> head. Something dirt simple is needed...
>
> Is it possible? I appreciate any pointers in the right direction!
>
To David & Tad,
Thanks for these great replies! Your speedy responses have enabled me to
muddle forward, and to (given a fair wind) have something for the weekend...
Kind regards,
cob
------------------------------
Date: Thu, 05 Feb 2004 20:45:00 GMT
From: Graham Drabble <graham.drabble@lineone.net>
Subject: Re: Looking for a FAQ article on autoposting in PERL
Message-Id: <Xns9486D31514C96grahamdrabblelineone@ID-77355.user.dfncis.de>
On 04 Feb 2004 "cob" <cob@hotmail.com> wrote in
news:40214ef9$0$70230$45beb828@newscene.com:
> I maintain a FAQ for the misc.immigration.misc newsgroup. I have
> been looking for a short perl snippet to automate FAQ
> announcements that would be posted to the misc.immigration.misc
> newsgroup.
>
> Also a perl snippet that could be run once a week to post an
> article showing where the FAQ is.
I do something like this. It's based on 3 scripts. The first allows
you to add new postings to the autoposter and change frequencies and
the like, the second (run from cron) does the posting the third
displays which postings are due when.
Note that the option to have a post posted on a specific day doesn't
work over a new year (it starts in February). I must get round to
sorting that out.
The things to be posted need to be stored in text fles with all
headers except Message-ID, Supercedes and Date.
For clarity the following is not wrapped:
changes.pl - for adding new poststo and removing old posts from to
the autoposter
==BEGIN==
use strict;
use warnings;
use diagnostics;
use Storable;
my $hashref = retrieve('schedule.info');
while(1){
print 'Do you want to Add a new file, Change an existing one or Remove it? (A|C|R) ';
my $response;
until (($response = <STDIN>) =~ /[ACR]/i){
print "$response is not allowed\n";
print 'Do you want to Add a new file, Change an existing one or Remove it? (A|C|R) ';
}
if ($response =~ /a/i){
print 'Enter filename: ';
chomp(my $filename = <STDIN>);
print 'Enter schedule type (interval or day): ';
my $type = <STDIN>;
until ($type =~ /interval|day/i){
print "$type is not allowed\n";
print 'Enter schedule type (interval or day): ';
$type = <STDIN>;
}
chomp $type;
$type = lc $type;
my $postfreq;
my @days;
my $date = time();
if ($type eq 'interval'){
print 'Enter posting frequency in days: ';
chomp($postfreq = <STDIN>);
$$hashref{$filename} = {'date', $date, 'type', $type, 'interval', $postfreq};
}elsif ($type eq 'day'){
print 'Enter days to be posted on (seperated by spaces) ';
chomp($postfreq = <STDIN>);
@days = split / /, $postfreq;
$$hashref{$filename} = {'date', $date, 'type', $type, 'days', [@days]};
}
}
elsif ($response =~ /r/i){
print 'Enter filename: ';
chomp(my $filename = <STDIN>);
until (exists($$hashref{$filename})){
print "$filename is not known\n";
print 'Enter filename: ';
chomp($filename = <STDIN>);
}
delete $$hashref{$filename};
unlink ("C:/Usenet/autoposter/files/$filename") || warn "Could not delete $filename. $!";
}
elsif ($response =~ /c/i){
print 'Enter filename: ';
chomp(my $filename = <STDIN>);
until (exists($$hashref{$filename})){
print "$filename is not known\n";
print 'Enter filename: ';
chomp($filename = <STDIN>);
}
print 'Current type is ' . $$hashref{$filename}->{'type'} . ' do you want to change this? [y/n]';
if (<STDIN> =~ /y/i){
print 'Enter schedule type (interval or day): ';
my $type;
until (($type = <STDIN>) =~ /interval|day/i){
print "$type is not allowed\n";
print 'Enter schedule type (interval or day): ';
}
chomp $type;
$type = lc $type;
$$hashref{$filename}->{'type'} = $type;
newfreq($hashref,$filename);
}
else{
print 'Do you want to change the posting frequency? ';
newfreq($hashref,$filename) if (<STDIN> =~ /y/i);
}
}
print 'Do you want to change another file?? ';
last unless (<STDIN> =~ /y/i);
}
store $hashref, 'schedule.info';
##Sub routines follow
sub newfreq{
my ($hashref,$filename) = @_;
if ($$hashref{$filename}->{'type'} eq 'interval'){
print 'Enter posting frequency in days: ';
chomp(my $postfreq = <STDIN>);
$$hashref{$filename}->{'interval'} = $postfreq;
}
elsif ($$hashref{$filename}->{'type'} eq 'day'){
print 'Enter days to be posted on (seperated by spaces) ';
chomp(my $postfreq = <STDIN>);
my @days = split / /, $postfreq;
$$hashref{$filename}->{'days'} = \@days;
}
}
==END==
poster.pl - does the posting and works out when it next gets posted
==BEGIN==
use strict;
use warnings;
use diagnostics;
use Net::NNTP;
use Storable;
use Time::Local;
my $domain = 'A.DOMAIN.YOU.CAN.USE';
chdir ('C:/Usenet/autoposter');
my $hashref = retrieve('schedule.info');
# Data structure that is stored in schedule.info
#
# $hashref is a reference to a hash with the following keys
# 'type' = the way it is schedules (interval / specified days)
# 'date' = the date of next posting in time() format
# 'mid' = message-id used last time this was posted
# 'interval' = the interval (in days) that the post is repeated at (does not exist unless type = interval)
# 'days' = reference to an array containing the days they are to be posted on (does not exist unless type = day)
while (my ($filename,$info) = each %$hashref){
if ($$info{'type'} eq 'day'){
day($filename,$info);
}elsif ($$info{'type'} eq 'interval'){
interval($filename,$info)
}else{
warn "$filename has a type, $$info{'type'}, that is unknown"
}
}
store $hashref, 'schedule.info';
sub interval{
my $filename = shift;
my $info = shift;
if ($$info{'date'} < time){
if (post($filename, $info)){
$$info{'date'} += ($$info{'interval'} * 24 * 60 * 60);
}
}
}
sub day{
my $filename = shift;
my $info = shift;
if ($$info{'date'} < time){
if (post($filename, $info)){
my $next_day;
foreach (@{$$info{'days'}}){
if ($_ > (localtime($$info{'date'}))[3]){
$next_day = $_;
$$info{'date'} = timelocal(0,0,1,$next_day,[localtime()]->[4],[localtime()]->[5]);
last;
}
}
if ($$info{'date'} < time){
print "INSIDE SECOND IF";
$next_day = $$info{days}->[0];
my ($month,$year);
if([localtime()]->[4] +1 < 12){
$month = [localtime()]->[4] +1;
$year = [localtime()]->[5];
}else{
$month = 1;
$year = [localtime()]->[5] +1;
}
$$info{'date'} = timelocal(0,0,1,$next_day,$month,$year);
}
}
}
}
sub post{
my $filename = shift;
my $info = shift;
my $message_id = "Message-ID: <$filename".time().'@'."$domain>\n";
my $supercedes = '';
if(exists $$info{'mid'}){
$supercedes = $$info{'mid'};
$supercedes =~ s/^Message\-ID\://i;
$supercedes = 'Supercedes:'.$supercedes;
}
my $nntp = Net::NNTP->new('NNTPSERVER');
die 'Could not connect to server' unless ($nntp);
$nntp->authinfo('USER','PASS'); #comment out if IP based
open(POSTING, "files/$filename") or die "can't open files";
$nntp->post();
$nntp->datasend($message_id);
$nntp->datasend($supercedes) if ($supercedes);
$nntp->datasend(<POSTING>);
$nntp->dataend;
my $post_ok = $nntp->ok();
logit ($filename,$nntp->code);
$nntp->quit;
if ($post_ok){
$$info{'mid'} = $message_id;
return 1;
}else{
return 0;
}
}
sub logit{
my ($file,$code) = @_;
open (LOG, '>>C:/Usenet/autoposter/post.log') or warn "Not logged, $!";
my @date = localtime(time);
my $year = $date[5]+1900;
my $month = sprintf("%02d",$date[4]);
my $day = sprintf("%02d",$date[3]);
my $hour = sprintf("%02d",$date[2]);
my $minute = sprintf("%02d",$date[1]);
my $sec = sprintf("%02d",$date[0]);
print LOG "$day/$month/$year $hour:$minute:$sec $file $code\n";
close LOG;
}
==END==
files.pl - for seeing what files are being posted when
==BEGIN==
use strict;
use warnings;
use diagnostics;
use Storable;
my $hashref = retrieve('schedule.info');
my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my @nextpost;
$^L = '';
$~ = 'INTERVAL';
$^ = 'INTERVAL_TOP';
foreach (sort keys %$hashref){
if ($$hashref{$_}->{'type'} eq 'interval'){
@nextpost = localtime($$hashref{$_}->{'date'});
write;
}
}
print "\n\n\n";
$~ = 'DAY';
$^ = 'DAY_TOP';
$- =0;
my $postlist;
foreach (sort keys %$hashref){
if ($$hashref{$_}->{'type'} eq 'day'){
@nextpost = localtime($$hashref{$_}->{'date'});
$postlist = join (' ',@{$$hashref{$_}->{'days'}});
write;
}
}
format INTERVAL=
@<<<<<<<<<<<<<< @# @<< @<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$_, $nextpost[3], $months[$nextpost[4]], $$hashref{$_}->{'interval'}, mid()
.
format INTERVAL_TOP=
Files posted at a given interval
================================
Filename Next Post Frequency Last Message-ID
.
format DAY=
@<<<<<<<<<<<<<< @# @<< @<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<
$_, $nextpost[3], $months[$nextpost[4]],mid(), $postlist;
~~ ^<<<<<<<<<<<<<
$postlist
.
format DAY_TOP=
Files posted on a given day
===========================
Filename Next Post Last Message-ID Days Posted
.
sub mid{
$$hashref{$_}->{'mid'} ? substr($$hashref{$_}->{'mid'},13) : 'none'
}
==END==
Comments on these from experts would be taken on board with thanks.
--
Graham Drabble
If you're interested in what goes on in other groups or want to find
an interesting group to read then check news.groups.reviews for what
others have to say or contribute a review for others to read.
------------------------------
Date: Thu, 5 Feb 2004 13:12:49 -0600
From: "Ram" <spam@spammer.com>
Subject: Re: newbie help
Message-Id: <bvu4h9$b9g$1@grandcanyon.binc.net>
Excellent, a lot to learn!!
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:bvs00f$109jb0$1@ID-184292.news.uni-berlin.de...
> Ram wrote:
> > Script I used:
> >
> > #!/usr/bin/perl
> > use strict;
> > my $el;
> > open(ONE, "ordsts.txt" ) or die "Can't open file $! \n";
> > while (<ONE>) {
> > #print "$_ \n";
> > my @lastmatch = /.*(<ordsts>.*<\/ordsts>)/s;
> > print "@lastmatch \n";
> > $el= my @lastmatch;
> > }
> > print "$el \n";
>
> It proves that gnari guessed right: You are applying the regex to one
> line at a time, which obviously can't work.
>
> Try this instead:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> open ONE, "ordsts.txt" or die "Can't open file $!";
> $_ = do { local $/; <ONE> }; # slurp file into $_
> close ONE;
> my ($el) = /.*(<ordsts>.*<\/ordsts>).*/s;
> print "$el\n";
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>
------------------------------
Date: Thu, 5 Feb 2004 20:34:02 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: newbie help
Message-Id: <bvu9a7$l73$1@news.simnet.is>
"Ram" <spam@spammer.com> wrote in message
news:bvu4h9$b9g$1@grandcanyon.binc.net...
> Excellent, a lot to learn!!
specially about top-posting.
[snipped top-posted quoted whole article]
gnari
------------------------------
Date: Thu, 05 Feb 2004 19:13:44 GMT
From: $_@_.%_
Subject: NNTP Subject Parsing
Message-Id: <IBwUb.13166$IF1.3217@nwrdny03.gnilink.net>
Does anyone know where i could find some information
about parsing NNTP subject fields?
Psuedo Code and/or RegExp advise would be ideal.
Im looking to parse out multipart messages.
ie: Test Subject (1/1) - file.bin [01/10]
Another test.bin (1/2)
Then store them untill all the parts have been gathered.
Thanks any advice is appreciated.
------------------------------
Date: 5 Feb 2004 19:46:18 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: NNTP Subject Parsing
Message-Id: <bvu6ia$qp8$1@canopus.cc.umanitoba.ca>
In article <IBwUb.13166$IF1.3217@nwrdny03.gnilink.net>, <$_@_.%_> wrote:
:Does anyone know where i could find some information
:about parsing NNTP subject fields?
:Psuedo Code and/or RegExp advise would be ideal.
:Im looking to parse out multipart messages.
:ie: Test Subject (1/1) - file.bin [01/10]
: Another test.bin (1/2)
:Then store them untill all the parts have been gathered.
There is no standard formatting for multipart messages.
When I did this a couple of years ago, I had to just look to see what
was coming down and tweak it from time to time. As I recall, there were
some complications involving pasting the binaries back together again
automatically, due to the different ways that posters had of storing
the binaries. And there are complications around detecting duplicates
because people tend to use similar subjects for different binaries.
I probably still have the code around. I haven't looked at it in
years. It's probably not my best code, but it worked.
--
Ceci, ce n'est pas une idée.
------------------------------
Date: Thu, 05 Feb 2004 16:07:24 -0500
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: NNTP Subject Parsing
Message-Id: <4022B08C.4000303@gwu.edu>
$_@_.%_ wrote:
> Does anyone know where i could find some information
> about parsing NNTP subject fields?
How do you parse something that's freeform text?
Chris Mattern
------------------------------
Date: Thu, 05 Feb 2004 22:45:39 GMT
From: $_@_.%_
Subject: Re: NNTP Subject Parsing
Message-Id: <nIzUb.13875$IF1.9889@nwrdny03.gnilink.net>
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) Wrote:
> In article <IBwUb.13166$IF1.3217@nwrdny03.gnilink.net>, <$_@_.%_> wrote:
> :Does anyone know where i could find some information
> :about parsing NNTP subject fields?
>
> :Psuedo Code and/or RegExp advise would be ideal.
>
> :Im looking to parse out multipart messages.
> :ie: Test Subject (1/1) - file.bin [01/10]
> : Another test.bin (1/2)
>
> :Then store them untill all the parts have been gathered.
>
> There is no standard formatting for multipart messages.
Nod the standard gives alot of freedom to the poster.
>
> When I did this a couple of years ago, I had to just look to see what
> was coming down and tweak it from time to time. As I recall, there were
> some complications involving pasting the binaries back together again
> automatically, due to the different ways that posters had of storing
> the binaries. And there are complications around detecting duplicates
> because people tend to use similar subjects for different binaries.
>
> I probably still have the code around. I haven't looked at it in
> years. It's probably not my best code, but it worked.
I am very happy to hear from someone who has experience with
this sort of function, you help is really helpfull.. thank you.
>
Here is the regex im thinking about using:
m/(.+)([(\[\{]+?\d+[/-]+?(\d+)[)\]\}]+?)/
Dose this regex look ok?
There are three memory groups
1) the main subject text
2) the proof that this is part of a multi-part message
3) the number of parts for this message
Im planning on creating a hash which has the message-ids for keys
and an array ref as a value, the actual array may contain the total number
of parts expected, and which part that this message id is.
if this regex is ok, I will still need to find a way to know when all parts have
been gathered, then pass the message id's in the correct order to the hash
which populates the Tk::HList, which displays the messages.
Then if the message is selected for download i will pass the message-ids to..
Convert-BulkDecoder
Im still trying to get my head around this.. more to follow (hopefully)
Help would be greatly appreciated.
Thanks in advance for any tips/suggestions/psudo code/regex advice.
------------------------------
Date: 5 Feb 2004 11:45:44 -0800
From: ajs@ajs.com (Aaron Sherman)
Subject: Re: Optimization request
Message-Id: <eaa2c627.0402051145.3c958e2a@posting.google.com>
"David K. Wall" <dwall@fastmail.fm> wrote in message news:<Xns94866A4E9C8B1dkwwashere@216.168.3.30>...
> Guru03 <Guru03@despammed.com> wrote:
>
> > For you, it's faster this:
[...]
> Use the first one, no need to search the string twice.
Something to keep in mind is that a) Perl doesn't always work that way
and b) when you answer someone's question, you might consider
answering the one they asked.
He didn't ask "which of these would you use", he asked (in admittedly
broken english, but still quite comprehensibly) which of them was
faster.
You can't answer that qualitatively.
Of course, others have demonstrated the flaw in the example, but this
is an important thing to keep your eye on with Perl. You could have a
case where the obvious simply isn't because perl has hundreds of
special cases that it optimizes for. If you happen to trigger such an
optimization with a complex, seemingly slow expression and not with a
simpler one... well, your results will be surprising, and you might
find yourself coming here and asking "For you, it's faster .... Why?"
------------------------------
Date: Thu, 05 Feb 2004 15:04:47 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Optimization request
Message-Id: <S-udnX_5I6hCPL_dRVn-hQ@adelphia.com>
Aaron Sherman wrote:
> and b) when you answer someone's question, you might consider
> answering the one they asked.
You must be new here. ;-)
sherm--
------------------------------
Date: 5 Feb 2004 19:20:37 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Perl data types
Message-Id: <bvu525$1hl$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Malcolm Dew-Jones:
> Tassilo v. Parseval (tassilo.parseval@rwth-aachen.de) wrote:
>: Also sprach Eric Schwartz:
>
>: > "David Holmes" <no@spam.uk> writes:
>
>: >> As for sum types, they are subtly different. Values of a sum type are
>: >> tagged. This can take several forms but again in the example of a java.
>: >> Incase you cant tell this is the language I use most. If you have a base
>: >> class that extends a superclass1 and a superclass2. You can initialise a
>: >> variable as the base class, and then say:
>: >>
>: >> if (instanceOf(superclass1)) { do something }
>: >> else if (instanceOf(superclass2)) { do something else }
>: >
>: > But that's crappy OO programming. You should do
>: >
>: > object.method()
>: >
>: > instead, and let inheritance take care of what gets done, no?
>
>: No, not in Java. Due to broken-by-design method dispatch, you will
>: constantly be checking the type and then do a typecast. If you have a
>: class "Foo" with a method "bar" and you stuff 10 Foo objects into
>
>: Object array[10];
>
> If they are Foo objects, then why pretend they are just generic Objects?
> Why not stuff them into
>
> Foo array[10];
>
> Then you can write
>
> array[0].bar();
>
> just like you wish.
Too bad that you sometimes have no choice. Just look at some of the
classes in the Java API (like 'Collection' or so). They all cast their
objects down to the most generic class 'Object'.
Java simply is lacking things like C++ templates. Note that C++ would
become pretty unprogrammable if you didn't have them for the sake of
genericity and polymorphism.
>: you can't just say 'array[0].bar'. Instead you have to write
>
>: ((Foo)array[0]).bar();
>
>: This gets worse if 'array' contains Foo and Bar objects and both have a
>: "bar" method. Then this becomes:
>
>: if (array[0] instanceof Foo) {
>: ((Foo)array[0]).bar();
>: } else {
>: ((Bar)array[0]).bar();
>: }
>
> If Foo and Bar are derived from the same class which provides "bar()", or
> if they both implement an interface that has bar, then, as above, you can
> select a type for the array that is more specific than Object (and more
> appropriate), and then the above is not needed.
Take this hierarchy:
Class1;
Class2 extends Class1;
Class3 extends Class2; // and possibly overrides Class1.method()
Say, that each of these classes is instantiatable. So I'd naturally
choose
Class1 array[10];
How exactly would that avoid typecasts? Sure, I can probably have each
of these three implement an interface and change the type of the array
to that of the common interface. However, do I want that? Certainly not.
It means I, the programmer, have to accept such a red-herring in order
to make polymorphism work as expected and convenient.
>: Thus, it is often required in Java to do the type checking by hand.
>
> I wonder why UNIVERSAL.pm provides isa() and can()? Perhaps it's because
> you have to do these same kind of checks in perl on occasion?
Yes, occasionally. But this happens at runtime. In Java the thing wont
even compile. Also, please count the occurances of can() and isa() in
Perl code and compare the number to 'instanceof' and typecasts in Java
programs.
Often enough I had to program in Java and each time I got sick of these
(deliberate, I may add) limitations of this language. This will turn any
medium-sized program into something bloated with many auxiliary
interfaces and classes that wouldn't be there if Java chose a more
reasonable approach.
>: Therefore I never quite understood how SUN can claim that Java has
>: polymorphism at all.
>
> Perhaps because it does?
Hardly to a visible extent.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 5 Feb 2004 11:25:53 -0800
From: ajs@ajs.com (Aaron Sherman)
Subject: Re: problem with "our"
Message-Id: <eaa2c627.0402051125.6bcf51f9@posting.google.com>
JaSeong Ju <j_kkachi@yahoo.com> wrote in message news:<402269A9.9030801@yahoo.com>...
> I'm new to perl.
And your perl is old to me ;-)
> How come this piece of code does not work in SunOs5.8, with perl v.
> 5.005_03 ?
The our keyword was introduced in 5.6.0, and is not available in your
version of Perl.
Thus, you have essentially written:
foo $bar = xxx
which Perl sees as:
$bar->foo() = xxx
which is why you're getting an error about modifying a subroutine.
Bottom line: use a newer Perl. 5.005_03 (released in 1999) is outdated
by 2 major and many more minor revisions. We're up to 5.8.3. I believe
at this point.
Staying within 2 years of current is probably wise with any language,
as storebought documentation and web or print articles about the
language will tend to be woefully out-of-date otherwise (try using STL
implementations from 1999 with modern C++ documentation, for example
;-)
That said, your Perl installation should have plenty of documentation
on how to establish global (package-scoped, of course) variables
without causing "strict" problems. See the documentation for the
"strict" and "vars" modules using the "perldoc" program for more
information.
------------------------------
Date: 5 Feb 2004 12:07:48 -0800
From: ajs@ajs.com (Aaron Sherman)
Subject: Re: RDBMS to hold Perl objects?
Message-Id: <eaa2c627.0402051207.7a49f4d4@posting.google.com>
J Krugman <jill_krugman@yahoo.com> wrote in message news:<bvtlq0$cku$1@reader2.panix.com>...
> Is there a free RDBMS that can handle Perl objects?
Anything that can hold strings can hold the results of the Storable
module (which ships with Perl now). I don't know of any slick
implementations that allow you to transparently access the values
without going back through Storable for full RDBMSes, but you can do
quite a lot using MLDBM and MLDBM::Sync.
Enjoy!
------------------------------
Date: Thu, 5 Feb 2004 22:24:31 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re:
Message-Id: <bvufpa$m60$1@news.simnet.is>
"fishfry" <BLOCKSPAMfishfry@your-mailbox.com> wrote in message
news:BLOCKSPAMfishfry-9450FD.14053905022004@netnews.comcast.net...
> The statement
>
> print qr/abc/;
>
> produces the output
>
> (?-xism:abc)
>
> I looked in man perlop and didn't find a clear description of what this
> means. Where's this documented? What's it mean?
try perlre
gnari
------------------------------
Date: Thu, 5 Feb 2004 16:51:22 -0600
From: "Ram" <spam@spammer.com>
Subject: top posting: response to gnari
Message-Id: <bvuhav$ek3$1@grandcanyon.binc.net>
Is this the correct way to post (not top-posting), while responding to
gnari!!
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnc230js.20g.tadmc@magna.augustmail.com...
> Ram <spam@spammer.com> wrote:
>
> > Subject: newbie help
>
>
> 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: Thu, 5 Feb 2004 16:55:16 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: top posting: response to gnari
Message-Id: <slrnc25iek.2cn.tadmc@magna.augustmail.com>
Ram <spam@spammer.com> wrote:
> Is this the correct way to post (not top-posting),
No it isn't.
*plonk*
[ snip TOFU ]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6085
***************************************