[18835] in Perl-Users-Digest
Perl-Users Digest, Issue: 1003 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 28 14:05:37 2001
Date: Mon, 28 May 2001 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)
Message-Id: <991073114-v10-i1003@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 28 May 2001 Volume: 10 Number: 1003
Today's topics:
<> operator problem <risto.vaarandi@eyp.ee>
Re: ? The best Perl book ? (Miko O'Sullivan)
An array of sockpairs...? <wardude88@nospam.usa.net>
Re: An array of sockpairs...? <buggs@geekmail.de>
Re: An array of sockpairs...? <wardude88@nospam.usa.net>
Re: Clarification and question about FAQ (Abigail)
Re: Clarification and question about FAQ <bart.lateur@skynet.be>
Re: comparing two HoHoL's <bkennedy99@Home.com>
Re: comparing two HoHoL's <webmaster@webdragon.unmunge.net>
Re: convert letters to numbers <bart.lateur@skynet.be>
Re: convert letters to numbers <jcook@strobedata.com>
Re: convert letters to numbers (Abigail)
Re: convert letters to numbers <bart.lateur@skynet.be>
Re: convert letters to numbers (Anno Siegel)
Re: convert letters to numbers <bart.lateur@skynet.be>
Re: convert letters to numbers (Anno Siegel)
Re: Curses and Macperl <bkennedy99@Home.com>
Re: Curses and Macperl <webmaster@webdragon.unmunge.net>
Re: Fcntl usage? (Martien Verbruggen)
filenames containing spaces <paulus86@ascat.de>
Re: filenames containing spaces (Michel Dalle)
Re: Generating WML content? (Martien Verbruggen)
Re: Generating WML content? <steffi@shell8.ba.best.com>
Re: GetOptions is too verbose ! (how can I redirec (Clinton A. Pierce)
GetOptions is too verbose ! (how can I redirect ST <pmonsch@saint-etienne.tt.slb.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 28 May 2001 19:54:08 +0200
From: Risto Vaarandi <risto.vaarandi@eyp.ee>
Subject: <> operator problem
Message-Id: <3B1290C0.BEF57E9B@eyp.ee>
hello,
I am trying to tail a file with a perl program. The program just opens
the file without any specific options (ordinary blocking open), and the
uses <> operator to get new bytes. If <> returns undef, then the program
uses select for sleeping, and the tries again.
The program works fine on Linux, but on Solaris <> occasionally starts
to loop strangely, going back to lines it has already seen in the past
and returning them, then going back again and returning the same lines
all over again, etc.
Here is the code fragment - what could be wrong here?
for (;;) {
$line = <INPUT>;
if (!defined($line)) { select(undef, undef, undef,
$poll_timeout); }
else { print $line; }
}
I haven't seen this problem on Linux and HPUX, but on Solaris8 and
Solaris2.6.
Perl version is 5.6.0.
Does anyone have any clue - is this happening because of a bug in
Solaris?
best regards,
risto
------------------------------
Date: 28 May 2001 07:08:29 -0700
From: miko@idocs.com (Miko O'Sullivan)
Subject: Re: ? The best Perl book ?
Message-Id: <db27ea77.0105280608.11d85762@posting.google.com>
merlyn@stonehenge.com (Randal L. Schwartz) wrote in message
>
> Philip> (whatever "with", as opposed to "and", means)
>
> It means I did darn little
... then how about "with Special Guest Star Randal L. Schwartz"?
-miko
---------------------------------
Miko O'Sullivan
Author of The Idocs Guide to HTML
http://www.idocs.com/tags/
------------------------------
Date: Mon, 28 May 2001 09:24:34 -0500
From: "falling" <wardude88@nospam.usa.net>
Subject: An array of sockpairs...?
Message-Id: <th4ke8mp9edp94@corp.supernews.com>
Hi! I have hit the first big roadblock in a little project I have
under-taken in my attempt to get a little more comfy with Perl. The
current design of one particular area of the project is that I will have a
multiple number of child processes (anywhere from 2 to 10 or more, all
depending on the user's demands) fork()'ed off and these processes need to
have a bi-directional communication path with the parent process.
So I tried this with one process, and used the socketpair() function to
create that communication medium and the processes got along fine. Then I
decided to spice it up a bit, and create 2 arrays to hold the socketpairs,
one for holding the parents copy of the socketpair and the other for
holding the childs copy. I read in the Perl FAQ how to store file handles
in arrays and did my best to copy the code. With one socketpair and one
child process this all worked fine and dandy and I thought I was on my
way.
The trouble started when I tried to put this in loops and make 2 socket
pairs, store them in their respective arrays, and test the communication
between them. The socketpairs were created and stored in the arrays, but
as soon as I attempted to access either one, I got a SIGPIPE (with a
message "Broken Pipe). I wanted to see what was internally going on, so I
set "SIG{PIPE} = "IGNORE";" so the program would not die as soon as it got
a sigpipe. I saw that one of the pipes, (the first one) worked fine and
transferred the message, but the other was invalid and I got a warning
for trying to write to it and a warning for trying to read from it.
Anyways... enough with my complaining, since you've read this far, take a
look at th actual code:
#!/usr/bin/perl -w
use strict;
use IO::Handle;
use Socket;
$SIG{CHLD} = "IGNORE";
$SIG{PIPE} = "IGNORE";
my $i = 0;
my (@clones, @master);
for($i = 0; $i < 2; $i++) {
local *CLONE, *MASTER;
socketpair(CLONE, MASTER, AF_UNIX, SOCK_STREAM, PF_UNSPEC)
or die "Failure to create socket pair #$i!\nHorrors!\n";
CLONE->autoflush(1);
MASTER->autoflush(1);
$clones[$i] = *CLONE;
$master[$i] = *MASTER;
print "created socket pair #$i ok!\n";
}
for($i = 0; $i < 2; $i++) {
my $pid = fork();
if($pid) {
my $CLONE = $clones[$i];
my $MASTER = $master[$i];
close($MASTER);
print $CLONE "Testing 1-2-3\n";
close($CLONE);
if($i == 1) { wait; }
}
else {
my $CLONE = $clones[$i];
my $MASTER = $master[$i];
close($CLONE);
my $line = <$MASTER>;
print "Clone #$i: ", '$line == ', "$line\n";
close($MASTER);
exit(0);
}
}
# Any suggestions? am i doing something wrong,
# or is this impossible and I need to redisgn my
# script? BTW, sorry if I am trying to code my
# Perl how I code my C.... I'm still learning =)
------------------------------
Date: Mon, 28 May 2001 16:36:06 +0200
From: buggs <buggs@geekmail.de>
Subject: Re: An array of sockpairs...?
Message-Id: <9etnne$jko$02$1@news.t-online.com>
falling wrote:
> # Any suggestions? am i doing something wrong,
> # or is this impossible and I need to redisgn my
> # script? BTW, sorry if I am trying to code my
> # Perl how I code my C.... I'm still learning =)
>
Learn
perl -w.
Do
- local *CLONE, *MASTER;
+ local (*CLONE, *MASTER);
Notice
IO::Socket.
Buggs
------------------------------
Date: Mon, 28 May 2001 10:47:20 -0500
From: "falling" <wardude88@nospam.usa.net>
Subject: Re: An array of sockpairs...?
Message-Id: <th4p9frid0s9c0@corp.supernews.com>
what a foolish mistake I made! thank you, kind wizard =)
In article <9etnne$jko$02$1@news.t-online.com>, buggs <buggs@geekmail.de>
wrote:
> Do
> - local *CLONE, *MASTER;
> + local (*CLONE, *MASTER);
>
> Notice IO::Socket.
>
> Buggs
------------------------------
Date: Mon, 28 May 2001 15:19:21 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Clarification and question about FAQ
Message-Id: <slrn9h4r3p.5vk.abigail@tsathoggua.rlyeh.net>
db (dxb@DONOTSPAM.com) wrote on MMDCCCXXVI September MCMXCIII in
<URL:news:jun2htsdda9i7am3ekmj6mi37ijp28bhv4@4ax.com>:
--
-- Thanks you for your comments, David.
--
-- Very few newsgroups seem to have as strict a policy as this one about
-- posting. I really wish they would get the FAQ updated and spread around the
-- net so that people don't think it's the friendly community sort of place
-- that the old FAQ describes.
--
-- It's obviously NOT a group I'm comfortable with, and I rarely use perl so I
-- probably won't post here again, but I would like to see some sort of
-- warning posted regularly so others who are new to the group will realize
-- what kind of policy is in place. I've been on usenet since the early 90's
-- and, in all the groups I've visited, I've never encountered such a strict
-- group. It's not what most people will be expecting when they first visit
-- here.
I've been on Usenet for longer than you, and all the groups I've frequented
are one of:
- Far less traffic than comp.lang.perl.misc
- Far more "strict" than comp.lang.perl.misc
- Turned to a stinking swamp due to large amounts of off-topic
and/or FAQ postings, glorified by hoards of cluefree masses
and abonded by those who know.
Abigail
--
sub A::TIESCALAR{bless\my$x=>A};package B;@q[0..3]=qw/Hacker Perl
Another Just/;use overload'""'=>sub{pop @q};sub A::FETCH{bless\my
$y=>B}; tie my $shoe => qq 'A';print "$shoe $shoe $shoe $shoe\n";
------------------------------
Date: Mon, 28 May 2001 16:29:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Clarification and question about FAQ
Message-Id: <l8v4ht8te5b6plfmotbfeo8cjiujt9e62c@4ax.com>
Abigail wrote:
>I've been on Usenet for longer than you, and all the groups I've frequented
>are one of:
>
> - Far less traffic than comp.lang.perl.misc
> - Far more "strict" than comp.lang.perl.misc
> - Turned to a stinking swamp due to large amounts of off-topic
> and/or FAQ postings, glorified by hoards of cluefree masses
> and abonded by those who know.
Since the first two cannot possibly apply to comp.lang.perl.misc, what
remains is...
--
Bart.
------------------------------
Date: Mon, 28 May 2001 15:20:04 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: comparing two HoHoL's
Message-Id: <E0uQ6.10456$lP5.5287539@news1.rdc2.pa.home.com>
"Scott R. Godin" <webmaster@webdragon.unmunge.net> wrote in message
news:9epmnb$peg$0@216.155.32.196...
> However, I'm curious to know whether you folks know of any more
> efficient methods for comparing the two, this being a bit more complex
> than a simple array or hash comparison typically found in the pod...
It still boils down to simple hash comparison - you could easily express the
same problem by munging the multi-dimensional hash keys into one hash key,
and having a hash for each array element. If you don't really care about
the sorting of the keys in the second hash, you could get a minor efficiency
boost by doing something like
while(my($gametype,$h_ref) = each %hash1) {
while(my($coercename,$a_ref) = each %$h_ref) {
my($filename, $title, $size, $review, $rating) = @$a_ref;
# tests here
}
}
This avoids creating a termporary list with keys() - though for small to
medium sized hashes it may not be an issue - hope this helps
--Ben Kennedy
------------------------------
Date: 28 May 2001 16:49:48 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: comparing two HoHoL's
Message-Id: <9etvjc$f6h$0@216.155.33.93>
In article <E0uQ6.10456$lP5.5287539@news1.rdc2.pa.home.com>,
"Ben Kennedy" <bkennedy99@Home.com> wrote:
| "Scott R. Godin" <webmaster@webdragon.unmunge.net> wrote in message
| news:9epmnb$peg$0@216.155.32.196...
|
| > However, I'm curious to know whether you folks know of any more
| > efficient methods for comparing the two, this being a bit more complex
| > than a simple array or hash comparison typically found in the pod...
|
| It still boils down to simple hash comparison - you could easily express the
| same problem by munging the multi-dimensional hash keys into one hash key,
| and having a hash for each array element. If you don't really care about
| the sorting of the keys in the second hash, you could get a minor efficiency
| boost by doing something like
|
| while(my($gametype,$h_ref) = each %hash1) {
| while(my($coercename,$a_ref) = each %$h_ref) {
| my($filename, $title, $size, $review, $rating) = @$a_ref;
| # tests here
| }
| }
|
| This avoids creating a termporary list with keys() - though for small to
| medium sized hashes it may not be an issue - hope this helps
mmm.. that is a good point and might speed things up a bit what with
each hash containing roughly 4000 entries... thanks for the tip.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Mon, 28 May 2001 13:10:44 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: convert letters to numbers
Message-Id: <ifj4ht86q1oqfd0jp19l0fdbjsvfagjhlm@4ax.com>
Eric wrote:
>i want to convert a text string into a number
>like convert "Eric" into a number "4573454353"
>each time i convert "Eric" it will always give me the same number
>if i convert a different string like "Eric Marques" it will give me a
>different number like "9567436434" and will always give me the same number
>for the same string
>
>its a little like the crypt() function except it will return only numbers
Perhaps a CRC? The module String::CRC32 can return a 32 bit integer. If
that's not enough, I think that Digest::MD5 can do something similar
with up to 128 bits.
--
Bart.
------------------------------
Date: 28 May 2001 13:37:53 GMT
From: Jim Cook <jcook@strobedata.com>
Subject: Re: convert letters to numbers
Message-Id: <3B1254B1.1F180645@strobedata.com>
> i want to convert a text string into a number
> like convert "Eric" into a number "4573454353"
> each time i convert "Eric" it will always give me the same number
> if i convert a different string like "Eric Marques" it will give me a
> different number like "9567436434" and will always give me the same number
> for the same string
I won't actually answer your question -- it's been done several times in
this thread. However, this is exactly the type of situation where I know
enough to think that you are trying to solve a problem the wrong way. In
my job in tech support, i I were asked this type of question, I would
get suspicious that you had a different problem, and were using this to
try and solve it. I bet there's a better way, unless this was just a
though experiment / homework problem.
So, what situation arose such that you felt converting names into
numbers was a tool that you would need? If you don't mind my asking.
--
jcook@strobedata.com Live Honourably 4/1 - 4/3 + 4/5 - 4/7 + . . .
2001 Wed: Feb/last 4/4 6/6 8/8/ 10/10 12/12 9/5 5/9 7/11 11/7 3/14
Strobe Data Inc. home page http://www.strobedata.com
My home page O- http://jcook.net
------------------------------
Date: Mon, 28 May 2001 15:11:57 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: convert letters to numbers
Message-Id: <slrn9h4qlt.5vk.abigail@tsathoggua.rlyeh.net>
Clinton A. Pierce (clintp@geeksalad.org) wrote on MMDCCCXXVI September
MCMXCIII in <URL:news:4kfQ6.91029$V5.15991194@news1.rdc1.mi.home.com>:
__ [Posted and mailed]
__
__ In article <Z6fQ6.35019$PF4.70465@news.iol.ie>,
__ "Eric" <mail@NOSPAMericmarques.net> writes:
__ > OK to be more specific
__ > i want to convert a text string into a number
__ > like convert "Eric" into a number "4573454353"
__ > each time i convert "Eric" it will always give me the same number
__ > if i convert a different string like "Eric Marques" it will give me a
__ > different number like "9567436434" and will always give me the same number
__ > for the same string
__ >
__ > its a little like the crypt() function except it will return only numbers
__
__ Ah, you want to hash the string as a number. Look into the MD5 module,
__ or use pack to do a simple CRC checksum on the string.
But that doesn't garantee unique numbers.
{ my $counter = "1"; # Keep the quotes.
my $cache;
sub str2number {
my $str = shift;
$cache {$str} = ++ $counter unless $cache {$str};
$cache {$str}
}
}
Abigail
--
print v74.117.115.116.32;
print v97.110.111.116.104.101.114.32;
print v80.101.114.108.32;
print v72.97.99.107.101.114.10;
------------------------------
Date: Mon, 28 May 2001 15:17:43 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: convert letters to numbers
Message-Id: <p1r4ht0nb36drvje00l2lr66753r6kblqc@4ax.com>
Abigail wrote:
> sub str2number {
> my $str = shift;
> $cache {$str} = ++ $counter unless $cache {$str};
> $cache {$str}
> }
sub str2number {
my $str = shift;
$cache{$str} ||= ++$counter;
}
or
sub str2number {
my $str = shift;
$cache{$str} ||= keys %cache;
}
--
Bart.
------------------------------
Date: 28 May 2001 16:04:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: convert letters to numbers
Message-Id: <9etsv1$q3k$1@mamenchi.zrz.TU-Berlin.DE>
According to Bart Lateur <bart.lateur@skynet.be>:
> Abigail wrote:
>
> > sub str2number {
> > my $str = shift;
> > $cache {$str} = ++ $counter unless $cache {$str};
> > $cache {$str}
> > }
>
> sub str2number {
> my $str = shift;
> $cache{$str} ||= ++$counter;
> }
>
> or
>
> sub str2number {
> my $str = shift;
> $cache{$str} ||= keys %cache;
> }
That's not entirely equivalent. Abigail's
my $counter = "1"; # Keep the quotes.
initializes a counter of unbounded capacity, while "keys %cache" is a
native integer. Now for the reason this matters in practice... :)
Anno
------------------------------
Date: Mon, 28 May 2001 16:11:45 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: convert letters to numbers
Message-Id: <r7u4ht8l0punop502i1qd0poa374aq4oap@4ax.com>
Anno Siegel wrote:
>That's not entirely equivalent. Abigail's
>
> my $counter = "1"; # Keep the quotes.
>
>initializes a counter of unbounded capacity, while "keys %cache" is a
>native integer. Now for the reason this matters in practice... :)
You'll run out of memory before you run out of integers. I would guess.
--
Bart.
------------------------------
Date: 28 May 2001 16:22:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: convert letters to numbers
Message-Id: <9etu0l$q3k$2@mamenchi.zrz.TU-Berlin.DE>
According to Bart Lateur <bart.lateur@skynet.be>:
> Anno Siegel wrote:
>
> >That's not entirely equivalent. Abigail's
> >
> > my $counter = "1"; # Keep the quotes.
> >
> >initializes a counter of unbounded capacity, while "keys %cache" is a
> >native integer. Now for the reason this matters in practice... :)
>
> You'll run out of memory before you run out of integers. I would guess.
So would I, but isn't it neat that you can confidently count towards
infinity in a string? Never mind you'll hardly want to use it.
Anno
------------------------------
Date: Mon, 28 May 2001 15:06:45 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: Curses and Macperl
Message-Id: <9QtQ6.10444$lP5.5275423@news1.rdc2.pa.home.com>
"Eric Inazaki" <penfold@deadbeat.edu> wrote in message
news:270520011536525474%penfold@deadbeat.edu...
> Hi,
>
> Is there a curses package for macperl? I'm using various versions of
> perl5 on macs, suns and an old and decrepit sgi (oh, and windows too)
> and I'm looking to do text based UI things that can run on all these
> platforms. (I think the only hangup is with the mac).
You may want to look at Mac06, a POSIX layer for the MacOS 7.5+
http://www.dsitri.de/projects/mac06/index.html
Mac OS X may also do what you need as well - hope this helps
--Ben Kennedy
------------------------------
Date: 28 May 2001 16:54:23 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: Curses and Macperl
Message-Id: <9etvrv$f6h$1@216.155.33.93>
In article <270520011536525474%penfold@deadbeat.edu>,
Eric Inazaki <penfold@deadbeat.edu> wrote:
| Hi,
|
| Is there a curses package for macperl? I'm using various versions of
| perl5 on macs, suns and an old and decrepit sgi (oh, and windows too)
| and I'm looking to do text based UI things that can run on all these
| platforms. (I think the only hangup is with the mac).
I THINK there's some tk widgets that can be used with MacPerl although I
am not certain of this since I haven't explored in this direction much..
you might try asking on the MacPerl mailing list itself.
macperl@perl.org
although you will likely need to subscribe in order to recieve replies.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Mon, 28 May 2001 22:57:12 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Fcntl usage?
Message-Id: <slrn9h4ip8.c3r.mgjv@martien.heliotrope.home>
On Sun, 27 May 2001 14:17:13 +0100,
Mark Grimshaw <m.grimshaw@salford.ac.uk> wrote:
> Hi,
>
> Trying to use Fcntl; with O_RDONLY, OCREAT etc. for tie operations with
> Berkeley DB on 5.005_02 built for IP22-irix.
>
> Everything works fine but when I use strict; I get warnings (still
> works). The warning is:
That seems odd. strict shouldn't start giving you warnings like this.
They come from 'use warnings', or the -w option. strict should make
your program uncompilablei when you have unrecognised barewords.
> Argument "O_RDONLY" isn't numeric in entersub at
> /usr/local/lib/perl5/5.00502/IP22-irix/DB_File.pm line 255 (#1)
Looks like O_RDONLY hasn't been imported. Are you sure that you have
use Fcntl;
somewhere at the top of your program? And if you specify arguments to
Fcntl, are you including the :DEFAULT set? For example, if you import
the :flock set of constants, but you also want the default set, you'll
need something like:
use Fcntl qw(:DEFAULT :flock);
$ man Fcntl
Martien
--
Martien Verbruggen |
Interactive Media Division | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd. | reflects this.
NSW, Australia |
------------------------------
Date: Mon, 28 May 2001 17:50:57 +0200
From: "Florian Paulus" <paulus86@ascat.de>
Subject: filenames containing spaces
Message-Id: <9ets9q$149ar$1@ID-62217.news.dfncis.de>
hi group!
i have the following problem :
i want to create an indexfile of a directory containing .avi files,
including the filesizes. doesnt seem to be a problem, but the filenames
contain spaces, i don't want to remove them, so glob fails by returning an
array containing every part of a filename between the spaces, e.g. The
Watcher.avi glob would return The and Watcher.avi with criteria *.avi
i got around this using ls and a temp file. now i have to determine the
filesize using stat, but stat doesnt deliver a filesize, in shell i have to
use a \ before every space i tried to include but somehow it still doesnt
work.
any hint/help would be great! thank you.
below the code, i wrote so far and an example of some filenames :
#! /usr/bin/perl -w
system('ls > temp.dat');
open IN, "temp.dat";
@movies=<IN>;
close IN;
unlink(temp.dat);
print @movies;
while (@movies) {
$var=pop(@movies);
if ($var=~/\.avi/) {
$var=~s/ /\\ /g;
unshift @mov,$var;
}
}
foreach $movie (@mov) {
@array=stat($movie);
print "$movie has filessize $array[7]\n";
}
temp.dat example :
The Blair Witch Project 2 {[DivX]}.avi
The Cell {[DivX]}.avi
The Emperors New Groove {[DivX]}.avi
The Haunting {[DivX]}.avi
The Mummy {[DivX]}.avi
The Negotiator {[DivX]}.avi
------------------------------
Date: Mon, 28 May 2001 16:31:19 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: filenames containing spaces
Message-Id: <9etup2$3mg$1@dackel.pdb.sbs.de>
In article <9ets9q$149ar$1@ID-62217.news.dfncis.de>, "Florian Paulus" <paulus86@ascat.de> wrote:
>hi group!
>
>i have the following problem :
>i want to create an indexfile of a directory containing .avi files,
>including the filesizes. doesnt seem to be a problem, but the filenames
>contain spaces, i don't want to remove them, so glob fails by returning an
>array containing every part of a filename between the spaces, e.g. The
>Watcher.avi glob would return The and Watcher.avi with criteria *.avi
>i got around this using ls and a temp file. now i have to determine the
>filesize using stat, but stat doesnt deliver a filesize, in shell i have to
>use a \ before every space i tried to include but somehow it still doesnt
>work.
>
>any hint/help would be great! thank you.
>
>below the code, i wrote so far and an example of some filenames :
[snip]
Instead of the ls, temp.dat, @movies, @mov, stat, @array etc.,
you could use something like this :
# open the current directory
opendir(DIR,'.') || die "Can't open current directory : $!\n";
# read all directory entries and keep the .avi ones
my @files = grep(/\.avi$/, readdir(DIR));
# close the directory
closedir(DIR);
# for each .avi file (sorted by standard string comparison)
foreach my $file (sort @files) {
# print the name and size (-s) of the file
print "$file has size ",-s $file,"\n";
}
For more advanced file searches, you could use the File::Find module.
And if you want to do more advanced sorting for a large number of
files, you can replace the 'foreach' loop with a Schwartzian Transform
or packed sort etc.
HTH,
Michel.
------------------------------
Date: Mon, 28 May 2001 23:03:30 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Generating WML content?
Message-Id: <slrn9h4j52.c3r.mgjv@martien.heliotrope.home>
On Mon, 28 May 2001 06:26:24 GMT,
Robert Nicholson <steffi@shell8.ba.best.com> wrote:
> OK, I'm forced to split my cards across multiple decks becuase of the
> phone limitations so since I'm generating dynamic data I'm asking what
What the hell does all that mean?
No, wait, don't explain. It's not important.
> approach do people use when they have to generate .wml files from dynamic
> content to deliver to the browser?
I'd probably have a look at the modules on CPAN if I was forced to look
at this stuff. There are a few modules with WML in their name, although
they don't seem well-advanced.
http://search.cpan.org/
> Specifically how to clean up your generated files and are you just using
> the process ID and including that in the url's to the documents?
It looks like you're getting well into the WML spec stuff, and not
really Perl anymore, although I could be misunderstanding you. I
wouldn't be surprised if many other people had no clue what you were on
about either. Make sure that you limit your questions to Perl content,
and please, try to be clear.
> What's the typical way to handle contention issues for generated content?
What do you mean, contention issues? I know what contention means. I
know what issues are. I have a vague idea of what WML is supposed to be.
I know what generated means, content, and dynamic. And I still don't
grok what you are saying at all.
Martien
--
Martien Verbruggen |
Interactive Media Division | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd. | reflects this.
NSW, Australia |
------------------------------
Date: Mon, 28 May 2001 16:57:43 GMT
From: Robert Nicholson <steffi@shell8.ba.best.com>
Subject: Re: Generating WML content?
Message-Id: <yl38zjhe7i0.fsf@shell8.ba.best.com>
mgjv@tradingpost.com.au (Martien Verbruggen) writes:
> On Mon, 28 May 2001 06:26:24 GMT,
> Robert Nicholson <steffi@shell8.ba.best.com> wrote:
> > OK, I'm forced to split my cards across multiple decks becuase of the
> > phone limitations so since I'm generating dynamic data I'm asking what
>
> What the hell does all that mean?
The subject has WML it. This assumes you are familiar with WML.
>
> No, wait, don't explain. It's not important.
>
> > approach do people use when they have to generate .wml files from dynamic
> > content to deliver to the browser?
>
> I'd probably have a look at the modules on CPAN if I was forced to look
> at this stuff. There are a few modules with WML in their name, although
> they don't seem well-advanced.
>
> http://search.cpan.org/
>
> > Specifically how to clean up your generated files and are you just using
> > the process ID and including that in the url's to the documents?
>
> It looks like you're getting well into the WML spec stuff, and not
> really Perl anymore, although I could be misunderstanding you. I
> wouldn't be surprised if many other people had no clue what you were on
> about either. Make sure that you limit your questions to Perl content,
> and please, try to be clear.
Anybody who's had to generate static content dynamically knows what I'm
talking about here. I have to generate from the dynamic data static
content to form the .wml pages and I'm interested in hearing how folks
handle dealing with multiple requests when writing out files that
don't have unique names. In this case I'm generating movie listings
for the day and there's no point in generating content for each and
every use as the movie only change on a daily basis so I'm gussing I should
check the date stamp on my files with the server time and based on that
decide whether new content needs to be generated or not.
>
> > What's the typical way to handle contention issues for generated content?
>
> What do you mean, contention issues? I know what contention means. I
> know what issues are. I have a vague idea of what WML is supposed to be.
> I know what generated means, content, and dynamic. And I still don't
> grok what you are saying at all.
>
> Martien
> --
> Martien Verbruggen |
> Interactive Media Division | The world is complex; sendmail.cf
> Commercial Dynamics Pty. Ltd. | reflects this.
> NSW, Australia |
------------------------------
Date: Mon, 28 May 2001 14:51:58 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: GetOptions is too verbose ! (how can I redirect STDERR messages from GetOptions)
Message-Id: <iCtQ6.92971$V5.16467477@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <3B125317.45AC6FE4@saint-etienne.tt.slb.com>,
Pascal Monschein <pmonsch@saint-etienne.tt.slb.com> writes:
> it returns in STDERR :
> Option tf requires an argument <=== this message is directly generated
> by Getopt/Long.pm with a print STDERR)
> open(ERR,'>x_err") || die
> local $SIG{__WARN__} = sub { print STDERR "catch warn : $_[0] \n"; };
>
> and now it works !
> But it is a little heavy to program scripts, and I though there was an
> option (a global var) to do this, doesn't it ?
You're right, it's a bit stupid. The subject of whether or not a module
should /ever/ be throwing warnings and errors is a debate that's raged here
before. There's not really much to do about it, except to examine the
source to GetOptions and see what you can do to work around this.
[A quick parusal of the manpage suggests you try using the __WARN__
handler.]
I'd like to suggest combining your approaches to something like:
# untested
my $warnings=0;
{
local $SIG{__WARN__} = sub { $warnings++ };
GetOptions('x, 'a=s');
}
&usage_message if $warnings;
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary -- May 2001
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Mon, 28 May 2001 15:31:03 +0200
From: Pascal Monschein <pmonsch@saint-etienne.tt.slb.com>
Subject: GetOptions is too verbose ! (how can I redirect STDERR messages from GetOptions)
Message-Id: <3B125317.45AC6FE4@saint-etienne.tt.slb.com>
When I am executing this program "toto" with these options ./toto -x
-sksk -tf :
#!/usr/local/bin/perl -w
use GetOptions::Long;
GetOptions('-x','-tf=s');
it returns in STDERR :
Unknown option: sksk <=== this message is generated by a
"warn" function (as I saw in Getopt/Long.pm)
Option tf requires an argument <=== this message is directly generated
by Getopt/Long.pm with a print STDERR)
How could I redirect these outputs in another file ?
I tried this command but it doesn't work with the message generated by
the "warn" func :
{ local (*STDERR);
open(ERR,">x_err") || die;
*STDERR= *ERR;
GetOptions('x','a=s');
close(ERR); # I don't know if it is necessary but it work ...
}
# check options error
if ($Getopt::Long::error) {
open(ERRbis,"x_err") || die;
while (<ERRbis>) { print "STDERR contain this row : $_"; }
close(ERRbis);
}
And then I tried, to add this command just before :
open(ERR,'>x_err") || die
local $SIG{__WARN__} = sub { print STDERR "catch warn : $_[0] \n"; };
and now it works !
But it is a little heavy to program scripts, and I though there was an
option (a global var) to do this, doesn't it ?
Thank you for your help
Pascal
------------------------------
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 1003
***************************************