[29018] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 262 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 24 14:09:51 2007

Date: Sat, 24 Mar 2007 11:09:06 -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           Sat, 24 Mar 2007     Volume: 11 Number: 262

Today's topics:
        Executing awk from perl script <morty3e@gmail.com>
    Re: Executing awk from perl script <bik.mido@tiscalinet.it>
    Re: First line in body of Mail::POP3Client eng.john84@gmail.com
    Re: How can I make my prime number generator better? <bik.mido@tiscalinet.it>
    Re: I dotn understand this error <bik.mido@tiscalinet.it>
    Re: I dotn understand this error <tadmc@augustmail.com>
    Re: my $session = new CGI::Session() <kmhuntly@gmail.com>
    Re: my $session = new CGI::Session() <spamtrap@dot-app.org>
    Re: Need help with a Regex substitution <rvtol+news@isolution.nl>
    Re: parsing a tab delimited or CSV, but keep the delimi <lew@nospam.lewscanon.com>
    Re: parsing a tab delimited or CSV, but keep the delimi <lew@nospam.lewscanon.com>
    Re: parsing a tab delimited or CSV, but keep the delimi <spamtrap@dot-app.org>
    Re: Reading from fixed-length text file <junk@yahoo.com>
    Re: Replacing characters in file <klaus03@gmail.com>
    Re: Server/Clients system <hjp-usenet2@hjp.at>
    Re: Truncating text from a string with beginning text f <bik.mido@tiscalinet.it>
    Re: Why can't we just change the signal disposition on  (Randal L. Schwartz)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 24 Mar 2007 09:55:17 -0700
From: "AyOut" <morty3e@gmail.com>
Subject: Executing awk from perl script
Message-Id: <1174755317.701337.79540@b75g2000hsg.googlegroups.com>

I'm new to perl and have the following line that I try to execute:

 ...
my $hm = `date +%H:%M --date "1 minute ago"`;
my $fname = `date +AppName_stats.log.%Y-%m-%d --date "1 days ago"`;

my $hits = `find /logs/server_name0?/dir/. -name "$fname*" -exec
gunzip -c {} ;\ | /grep SearchStr | /bin/awk -F","
'{if(substr($1,12,5)~hmpoint)print $3}' hmpoint=$hm | /bin/awk '{tot+=
$1}END{print tot}'`;

When I run this I get all kinds of complaints on the $hits line.  I've
tried various modifications, but can't seem to get it to work.  Any
idea of what's wrong here?

Thanks.



------------------------------

Date: Sat, 24 Mar 2007 18:52:49 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Executing awk from perl script
Message-Id: <88pa03hrsu5eh2of15lkubh7astb0v2ono@4ax.com>

On 24 Mar 2007 09:55:17 -0700, "AyOut" <morty3e@gmail.com> wrote:

>my $hm = `date +%H:%M --date "1 minute ago"`;
>my $fname = `date +AppName_stats.log.%Y-%m-%d --date "1 days ago"`;
>
>my $hits = `find /logs/server_name0?/dir/. -name "$fname*" -exec
>gunzip -c {} ;\ | /grep SearchStr | /bin/awk -F","
>'{if(substr($1,12,5)~hmpoint)print $3}' hmpoint=$hm | /bin/awk '{tot+=
>$1}END{print tot}'`;
>
>When I run this I get all kinds of complaints on the $hits line.  I've
>tried various modifications, but can't seem to get it to work.  Any
>idea of what's wrong here?

Probably, trying to use Perl as a shell scripting language. In which
case you'd better write a shell script in the first place. There's
"almost" nothing awk can do that Perl can't. So please describe your
task instead. Someone will come up with an example Perl version.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: 24 Mar 2007 05:07:53 -0700
From: eng.john84@gmail.com
Subject: Re: First line in body of Mail::POP3Client
Message-Id: <1174738073.225987.299100@y66g2000hsf.googlegroups.com>

On Mar 23, 7:03 pm, Jim Gibson <jgib...@mail.arc.nasa.gov> wrote:
> In article <1174657322.370768.134...@o5g2000hsb.googlegroups.com>,
>
> <eng.joh...@gmail.com> wrote:
> >  How to write this code     if ( FIRST LINE IN BODY TRUE FOR EXAMPLE
> > HELLO)
>
> I am not sure what you mean by "FIRST LINE IN BODY TRUE FOR EXAMPLE
> HELLO". A line is not true or false, although what it contains may be
> interpreted as indicating trueness or falseness. Do you mean that the
> line contains the string "HELLO" and nonthing else? See below.
>
> >           {
>
> >            print $_, "\n"; } please help me to wrile this code
>
> > code:
>
> > #!/usr/local/bin/perl
>
> Need here:
>
>   use strict;
>   use warnings;
>
>
>
>
>
>
>
> >   use Mail::POP3Client;
>
> >  $pop = new Mail::POP3Client(   USER     => "xxxxxxxxx",
> >                                PASSWORD => "xxxxxxx",
> >                                HOST     => "xxxxx" );
>
> >   {
> >     foreach ( $pop->Body( 1 ) ) {
>
> >     if ( FIRST LINE IN BODY TRUE FOR EXAMPLE HELLO)
> >           {
>
> >            print $_, "\n";
>
> >            }}}
>
> The following will print any line of message 1 that contains HELLO
> anywhere (untested):
>
>   foreach ( $pop->Body(1) ) {
>     print "$_\n" if /HELLO/;
>   }
>
> If you want the line to contain only HELLO and nothing else, then
> change that to:
>
>   foreach ( $pop->Body(1) ) {
>     print "$_\n" if /^HELLO$/;
>   }
>
> or use a string equality for efficiency:
>
>   foreach ( $pop->Body(1) ) {
>     print "$_\n" if $_ eq 'HELLO';
>   }
>
> although in this case the line may contain a newline at the end and you
> will need to either use chomp to remove or modify the test string to
> "HELLO\n".
>
> In most cases, you are better off using an explicit variable rather
> than the default variable $_:
>
>   foreach my $line ( $pop->Body(1) ) {
>     print "$line\n" if $line eq 'HELLO';
>   }
>
>  Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
>     ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------        
>                http://www.usenet.com- Hide quoted text -
>
> - Show quoted text -

Thanks your cods works great



------------------------------

Date: Sat, 24 Mar 2007 10:24:41 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How can I make my prime number generator better?
Message-Id: <fer903ld6lhn3eu3bh27doo8034a8639lf@4ax.com>

On Fri, 23 Mar 2007 16:24:21 +0000 (UTC), espie@lain.home (Marc Espie)
wrote:

>>sqrt(n) can be precalculated, i*i must be calculated for every loop.
>>
>Perl being interpreted, you can apply known optimizations to it,
>namely, (i+1)*(i+1) = i*i + 2*i + 1...

So what? Do you mean that instead of calculating each time i*i you
would maintain an accumulator and increment that by 2*i+1 each time?
And how is that an "optmization", in *perl*, where a multiplication
and a sum are just as costly?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Sat, 24 Mar 2007 10:26:21 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: I dotn understand this error
Message-Id: <rir9031er7u4thoa3rro1lt4bfdamt2s9l@4ax.com>

On Fri, 23 Mar 2007 16:24:38 +0100, "Peter J. Holzer"
<hjp-usenet2@hjp.at> wrote:

>>>The whole index.pl uses UTF-8 encoding and some special chars yes.
>>>Is there a way to convert it to pure ASCII?
>>
>> recode(1), I guess. Or perl's piconv(1).
>
>If you don't mind losing all the non-ascii chars ...

I wrote "I guess" because I was guessing that (i) the "special chars"
were all in strings anyway and (ii) the available conversions would
include some to quoted forms of text. I may have guessed wrong.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Fri, 23 Mar 2007 18:40:40 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: I dotn understand this error
Message-Id: <slrnf08pbo.6ag.tadmc@tadmc30.august.net>

Νίκος <hackeras@gmail.com> wrote:
> On Mar 22, 2:51 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:
>
>> Feeling sorry for you. I *had* to use GG sporadically and it was a
>> major PITA...
>
> Why, whats is the matter with GG?


It appears that you have never read usenet the way it was meant to
be read, namely with a purpose-built news reader.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 24 Mar 2007 06:54:28 -0700
From: "Kevin" <kmhuntly@gmail.com>
Subject: Re: my $session = new CGI::Session()
Message-Id: <1174744468.622274.180110@y66g2000hsf.googlegroups.com>

On Mar 22, 3:39 pm, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
wrote:
> Kevin wrote:
> > When I try to initialize a CGI session with my $session = new
> > CGI::Session(), my script hangs and eventually throws a CGI timeout.
> > This actually occurs when trying to create a new anything, be it
> > session, or CGI, or anything. Any thoughts?
>
> What's a "CGI timeout"?  The error message it provides, should be a bit
> more descriptive.

The exact error shown in the browser is:

CGI Timeout
The specified CGI application exceeded the allowed time for
processing. The server has deleted the process.

HTTP Headers return a 502.

I did some playing with the code, and this only happens when i POST to
it from a form, if I hardcode the variables sent by the form and go to
the script directly it works fine..



------------------------------

Date: Sat, 24 Mar 2007 13:43:37 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: my $session = new CGI::Session()
Message-Id: <m2zm628rli.fsf@local.wv-www.com>

"Kevin" <kmhuntly@gmail.com> writes:

> On Mar 22, 3:39 pm, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
> wrote:
>> Kevin wrote:
>> > When I try to initialize a CGI session with my $session = new
>> > CGI::Session(), my script hangs and eventually throws a CGI timeout.
>> > This actually occurs when trying to create a new anything, be it
>> > session, or CGI, or anything. Any thoughts?
>>
>> What's a "CGI timeout"?  The error message it provides, should be a bit
>> more descriptive.
>
> The exact error shown in the browser is:
>
> CGI Timeout
> The specified CGI application exceeded the allowed time for
> processing. The server has deleted the process.

How much more descriptive can that be??? Your server has been configured
with a maximum time allowed for CGI apps. Yours runs for longer than that,
so the server killed it and returned an error.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


------------------------------

Date: Sat, 24 Mar 2007 14:41:50 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Need help with a Regex substitution
Message-Id: <eu3ded.1ms.1@news.isolution.nl>

Mirco Wahab schreef:
> Paul:

>> 1: time_line = "$1\/$2\/$3\"\t\"$4:$5 $6";
>> 2: time_line =~ s/^0//;
>> 3: time_line =~ s/(^\d+\/)0/\1/;

   ($time_line = qq{$1/$2/$3"\t"$4:$5 $6}) =~
       s#^0*(\d+/)0*#$1#x;

Test:

$ perl -wle'

  $_ = "01 02 03 04 05 pm";

  /(\S+) (\S+) (\S+) (\S+) (\S+) (\S+)/;

  ($time_line = qq{$1/$2/$3"\t"$4:$5 $6}) =~
       s#^0*(\d+/)0*#$1#x;

  print $time_line;
'
1/2/03" "04:05 pm

-- 
Affijn, Ruud

"Gewoon is een tijger."


------------------------------

Date: Sat, 24 Mar 2007 11:33:15 -0400
From: Lew <lew@nospam.lewscanon.com>
Subject: Re: parsing a tab delimited or CSV, but keep the delimiter
Message-Id: <aOednWnjpZUm2ZjbnZ2dnUVZ_t3inZ2d@comcast.com>

Jürgen Exner wrote:
> Lew wrote:
>> Jürgen Exner wrote:
>>> Well, sorry, but when you are talking Perl, then CPAN is the one and
>>> only repository for modules. There may be others, there may even be
>>> commercial ones. But CPAN is just plain the default and nobody would
>>> assume otherwise unless you mention a different source explicitely.
>> Well, sorry, but you're the one talking Perl. I'm talking Java.
> 
> The OP posted to comp.lang.PERL.misc. So of course he gets a Perl answer...

The OP cross-posted to a Perl group and a Java group, so /of course/ we have 
an obligation to speak to both audiences.

-- Lew


------------------------------

Date: Sat, 24 Mar 2007 11:40:26 -0400
From: Lew <lew@nospam.lewscanon.com>
Subject: Re: parsing a tab delimited or CSV, but keep the delimiter
Message-Id: <aOednWvjpZX325jbnZ2dnUVZ_t3inZ2d@comcast.com>

Jürgen Exner wrote:
> Lew wrote:
>> Jürgen Exner wrote:
>>> Well, sorry, but when you are talking Perl, then CPAN is the one and
>>> only repository for modules. There may be others, there may even be
>>> commercial ones. But CPAN is just plain the default and nobody would
>>> assume otherwise unless you mention a different source explicitely.
>> Well, sorry, but you're the one talking Perl. I'm talking Java.
> 
> The OP posted to comp.lang.PERL.misc. So of course he gets a Perl answer...
> 
> jue 

The OP cross-posted to a Perl group and a Java group, so /of course/ we have 
an obligation to speak to both audiences.

Furthermore, the OP stated that his implementation was in Java, so /of course/ 
a Perl answer was irrelevant.

/Of course/ based on that I expected answers to focus on Java solutions and 
/of course/ went looking in that space for references.

-- Lew


------------------------------

Date: Sat, 24 Mar 2007 13:45:28 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: parsing a tab delimited or CSV, but keep the delimiter
Message-Id: <m2vegq8rif.fsf@local.wv-www.com>

Lew <lew@nospam.lewscanon.com> writes:

> Furthermore, the OP stated that his implementation was in Java, so /of
> course/ a Perl answer was irrelevant.

If he didn't want a Perl answer, he shouldn't have posted to a Perl group.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


------------------------------

Date: Sat, 24 Mar 2007 10:11:08 -0400
From: nun <junk@yahoo.com>
Subject: Re: Reading from fixed-length text file
Message-Id: <XK6dncIhhpvmrJjbnZ2dnUVZ_hzinZ2d@megapath.net>

J. Gleixner wrote:
> DB wrote:
> 
>> Here is what I'm trying, which fails. I'm guessing it is a stupid sytnax
>> problem. Can someone assist?
> 
> First, you should state what, exactly, fails.
> 
>>
>> #################################
>> # reading data in from file
>> my (@AoA);
> my @AoA;
> 
>>  while ( <> ) {
>>      chomp;
>>      my $line_length=length($_);
>>
>> if ($line_length=124) {
> use ==
> 
> '=' does the assignment.
> 

Yes, right after I posted I noticed that and now the script works.

[...]
> You could also ignore the length and if there's data there,
> use it, otherwise have a default value.
> 
>     ...
>     substr($_, 70, 8),
>     substr($_, 103, 20) || ' ' x 20,
>     substr($_, 123, 1)  || ' ',


I tried that but it now gives me a warning such as this for each line in
the input data:

substr outside of string at HM_parse.pl line 47, <> line 17763.

But that's ok, I'm happy to have a working script even if it is not as
elegant as can be. Thanks!

DB


------------------------------

Date: 24 Mar 2007 02:05:38 -0700
From: "Klaus" <klaus03@gmail.com>
Subject: Re: Replacing characters in file
Message-Id: <1174727138.489310.127080@l75g2000hse.googlegroups.com>

On Mar 24, 7:15 am, Anony-mouse <anony-mo...@hole.in.the.wall.com>
wrote:
> Hi,
>
> I'm trying to find a way to replace characters in a file, but have run
> into problems. I'm trying to go through a .DAT file replacing the
> characters 015F (in hex) with 015C.
>
> I tried playing around with versions of SED, but the file also contains
> EOF control characters which cause that to abort part-way through the
> file (although it wasn't doing the replacement anyway).
>
> It also needs to be via the DOS command line or a similar way that can
> be performed by a BAT file and be as small as possible since it needs
> to run from a keyring Flash drive and still leave enough room for the
> data files.
>
> Is Perl going to be able to do this??

C:\>perl -Mbytes -Mopen=IO,:raw -pi.bak -e "s/\x01\x5c/\x01\x5f/g"
test.dat

see also "perldoc perlopentut" and "perldoc perlrun"

"-Mbytes" is needed to disallow character encodings (such as Utf8,
etc...)
"-Mopen=IO,:raw" forces I/O to "binmode" (i.e. disallow transformation
of CR/LF)
"-pi.bak" performs inplace editing (that's the "-i" part)
whereas the "-p" runs automated loop to process the file line by line

I am running ActiveState Perl on Windows XP

C:\>perl -v

This is perl, v5.8.8 built for MSWin32-x86-multi-thread
(with 50 registered patches, see perl -V for more detail)

Copyright 1987-2006, Larry Wall

Binary build 820 [274739] provided by ActiveState http://www.ActiveState.com
Built Jan 23 2007 15:57:46

--
Klaus



------------------------------

Date: Sat, 24 Mar 2007 17:01:07 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Server/Clients system
Message-Id: <slrnf0aiq3.db.hjp-usenet2@yoyo.hjp.at>

On 2007-03-22 20:31, Jamie <nospam@geniegate.com> wrote:
> In <slrnf05noj.v7v.hjp-usenet2@yoyo.hjp.at>,
> "Peter J. Holzer" <hjp-usenet2@hjp.at> mentions:
>>On 2007-03-21 01:21, Jamie <nospam@geniegate.com> wrote:
>>> One thing I would really like to do (alas, have no business model for it)
>>> is to marry NNTP with podcasts and RSS.
>>>
>>> So called "flooding protocol" is something I find quite amusing, and aside from
>>> NNTP (AFAIK) isn't widely used anymore. Seems like it's almost always a central
>>> master -> slave model, (mirrors, etc.. CPAN for example) 
>>>
>>> Having "NPTP" (Net Podcast Transfer Protocol? NRTP Net RSS Transfer Protocol?)
>>[...]
>>> Unlike NNTP, the enclosures and other RSS fields would have to be planned for
>>> (possibly with delayed transfer/referral of enclosures)
>>
>>I think regular NNTP would work just fine for that. Just use appropriate
>>content-types (application/rss+xml, audio/*, video/* or whatever). You
>>may want a subscription mechanism in the protocol (NNTP for normal
>>newsgroup could use one, too, but subscribing whole hierarchies is
>>"traditional" and so far nobody has had enough incentive to push for a
>>more fine-grained approach).
>
> The bit I can't work out is how you'd associate other types of information. 
> The title, description and other elements of the RSS entry, keeping the
> enclosures distinct, supporting multiple enclosures pr. item and ensuring
> that the items are stuck to the correct feed. Unless each feed were
> it's own newsgroup, this doesn't seem viable. (threading, maybe.. but followups
> might be better used as discussion areas and/or corrections)

I'm probably missing something because I know little about podcasts, but
AFAIK they consist basically of 

* individual media files
* RSS (or Atom, or whatever) files which refer to the media files and
  add a bit of information about them.

The RSS file normally is at a fixed URL, and clients poll the URL to see
if the file has changed, and either notify the user or automatically
download the new media files so that the user can listen to them resp.
view them.

So as a first step you can set up a set of newgroups with categories.
Then instead of (or in addition to) posting your RSS file on a web site,
you post it in the apropriate newsgroup(s). Clients subscribed to at
least one of the newsgroups will retrieve the RSS and can continue to
act just the same as if they had retrieved it vie HTTP. (The user might
want to specify additional filters, for example automatically download
only files by author X or with subject Y).

The harder part is to distribute the media files themselves over NNTP:
You can just post them to the same newsgroups, but that means that every
file is flooded to every server subscribed to a newsgroup. Well, let's
just say there's a reason why most newsserver operators don't carry
binary groups :-).

That's where the "more finegrained" subscription model I was talking
about comes in. Traditionally, feeds in NNTP are configured
"out-of-band": If I want a feed for some newsgroup, I send mail to my
neighbour news admins, and tell them I want to get a feed for that
newsgroup. Of course that's quite a bit of work, so it's almost never
done for individual groups, but only for hierarchies (so I'll say "I
want a feed for comp.*, at.* and de.* but without de.alt.dateien.*" or
something like that). If NNTP offered a way to configure feeds, that
could be done automatically, so turning on and off feeds for individual
groups would become feasible. 

So you could have one newsgroup per channel, and each server only
requests a feed for that channel when there are users actually reading
items from it (Incidentally, that gets rid of the problem that neither
news: nor nntp: URIs allow specifying both a message id and a newsgroup)

So, if I wanted to make podcasts, I'd start by creating a new newsgroup
for my channel on my news server (there may need to be some global
naming scheme to avoid collisions, for example by using the reversed
domain name as prefix: "podcasts.channels.at.hjp") and post my first
opus there:

    From: <hjp-usenet2@hjp.at>
    Newsgroups: podcasts.channels.at.hjp
    Subject: Writing a newsserver in perl
    Content-Type: video/mpeg
    Message-Id: <first-video@hjp.at>

Then I'll post an RSS file to the appropriate categories newsgroups:

    From: <hjp-usenet2@hjp.at>
    Newsgroups: podcasts.categories.programming.perl,podcasts.categories.comm.usenet,podcasts.channels.at.hjp
    Subject: Writing an nntp server in perl
    Content-Type: application/rss+xml
    Message-Id: <first-rss@hjp.at>

    <?xml version="1.0"?>
    <rss version="2.0">
	<channel>
	    <title> HJP's rants </title>
	    <link> news://news.hjp.at/podcasts.channels.at.hjp </link>
	    ...
	    <item>
		<title> Writing a newsserver in perl </title>
		<link> news:first-video@hjp.at </link>
		<description>
		    A very boring presentation about the nntp server I
		    wrote in perl.
		</description>
		<guid> first-video@hjp.at </guid>
		<enclosure href="news:first-video@hjp.at"
		    type="video/mpeg" length="12345678" />
	    </item>
	</channel>
    </rss>
    <!-- or something like that - please ignore any errors in the RSS -->

Done.

The RSS will be flooded out to all servers which carry either
podcasts.categories.programming.perl or podcasts.categories.comm.usenet.
The video will currently stay on my own NNTP server, because no other
carries podcasts.channels.at.hjp yet.

A client will get the RSS file, and if the user requests my
presentation, it will first try to enter the group
podcasts.channels.at.hjp and request the article <first-video@hjp.at> at
the local server(s), and if that fails, from news.hjp.at.

The server will notice a request for a non-existing newsgroup
podcasts.channels.at.hjp and request a feed from its peers. If none has
it, it may parse the RSS files to find that this newsgroup is available
from news.hjp.at and request it there (it is a matter of policy if a
server should autonomously establish new peer relationships).


> One may not want to spool all the enclosures, but rather defer them until
> someone requests them. Just flood the metadata, rather the way leafnode/suck
> type news servers work, the .overview should contain as much of the RSS
> data as possible. 

See above for an idea on how to flood metadata and enclosure via
different paths. The .overview could contain the content type and maybe
other data, but I don't think that's necessary - the RSS files are small
enough compared to the media files.

> Would be "nice" if you could go RSS -> NRTP -> RSS, loosing as little data as
> possible AND provide "discussion boards" on NNTP instead of those crummy
> web-based things. 

Regular postings in plain text can be intermixed between RSS and media
postings. (Hey, you can even have a discussion thread consisting of
audio or video postings :-).


> NNTP isn't 8-bit clean and doesn't really provide a way to xfer enclosures.

NNTP has been in practice 8-bit clean (although not binary-clean) since
the early 1990's. Even before, binaries were distributed just fine using
uuencoding. Today base64 and yenc exist as alternatives. Distributing
binaries over NNTP is really not a problem - people have been doing it
since the beginning of Usenet.

	hp

-- 
   _  | Peter J. Holzer    | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR       | to write clearly is like blaming English for
| |   | hjp@hjp.at         | the circumlocutions of bureaucrats.
__/   | http://www.hjp.at/ |	-- Charlton Wilbur in clpm


------------------------------

Date: Sat, 24 Mar 2007 10:39:50 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Truncating text from a string with beginning text from another string
Message-Id: <e9s903dravevqlr8gpihc6vqje1mgo5o80@4ax.com>

On Fri, 23 Mar 2007 20:23:44 +0100, Mirco Wahab <wahab-mail@gmx.de>
wrote:

>    my @end = split //, 'Reference #000000';
>    my $key = '('.(join '|', map join('',,@$_), map[@end[0..$_]], 0..$#end).')';

Isn't that an awkward way to reimplement substr()?
;-)


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Sat, 24 Mar 2007 07:34:10 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Why can't we just change the signal disposition on system()?
Message-Id: <86y7lm7lst.fsf@blue.stonehenge.com>

>>>>> "grocery" == grocery stocker <cdalten@gmail.com> writes:

grocery> Why can't we just trap the signal and have it exit? Ie like
grocery>            sub sig {
grocery>                exit;
grocery>            }

grocery>            $SIG{INT} = \&sig;

system is really just a convenience method for the following steps:

    sub my_system {
      my @args = @_;
      defined (my $kidpid = fork) or die "Cannot fork: $!";
      unless ($kidpid) { # kid does:
        exec @args;
        die "Cannot find $args[0]: $!";
      }
      # parent does:
      {
        local $SIG{INT} = $SIG{QUIT} = 'IGNORE';
        waitpid($kidpid);
      }
      return $?;
    }

If you want slightly different behavior, just copy this, and amend as
necessary.  For example, just before the exec, you can do things like change
directory, close or open filehandles, set the process priority, and so on.  In
your case, you can set up different signal handlers around the waitpid.

print "Just another Perl hacker,"; 

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
Posted via a free Usenet account from http://www.teranews.com



------------------------------

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 V11 Issue 262
**************************************


home help back first fref pref prev next nref lref last post