[23074] in Perl-Users-Digest
Perl-Users Digest, Issue: 5295 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 31 00:05:47 2003
Date: Wed, 30 Jul 2003 21:05:05 -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 Wed, 30 Jul 2003 Volume: 10 Number: 5295
Today's topics:
Re: Create electronic newsletters and email to all peop <dbcoordinator@cws.org.nz>
Re: getting complete file listings in perl <noreply@gunnar.cc>
Re: getting complete file listings in perl <xaonon@hotpop.com>
Re: getting complete file listings in perl <jwillmore@cyberia.com>
Re: getting complete file listings in perl <xaonon@hotpop.com>
Re: getting complete file listings in perl <bdonlan@bd-home-comp.no-ip.org>
Re: perl/tk back end questions <mgarrish@rogers.com>
Re: perl/tk back end questions <lusol@cube0.CC.Lehigh.EDU>
Re: Read from SSL IMAP <jwillmore@cyberia.com>
Re: regular expression question <bigj@kamelfreund.de>
Re: split alternative using regexp? <tassilo.parseval@rwth-aachen.de>
Web page with frames... <dhbrown@hobbes.dhbrown.net>
Re: weird "perl -e" behaviour <pkent77tea@yahoo.com.tea>
Re: zero but true? <bdonlan@bd-home-comp.no-ip.org>
Re: zero but true? <bart.lateur@pandora.be>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 31 Jul 2003 10:52:23 +1200
From: "DB Coordinator for CS" <dbcoordinator@cws.org.nz>
Subject: Re: Create electronic newsletters and email to all people in an excel spreadsheet
Message-Id: <5ZXVa.97695$JA5.2178783@news.xtra.co.nz>
Hi Garry
I did with the csv instead of excel file. Working well. Thanks.
Jo
"Garry Short" <g4rry_sh0rt@zw4llet.com> wrote in message
news:bg5ca9$5on$2$8302bc10@news.demon.co.uk...
> DB Coordinator for CS wrote:
>
> > Hi Guys
> >
> > We are using Windows platform and active perl in our organisation. We
want
> > to create electronic newsletters(which embed images as well) and want to
> > mailout all the people whose email addresses are in an excel
spreadsheet.
> > Can you give some advice about what modules/items we should use in
Active
> > perl to create/mailout electronic newsletters?. How can we achieve this
> > task?. Are there any particular way to do this in active perl?. What
> > modules/sections of Active perl we should need?.Can you give some
> > reference or help?
> >
> > Thank you
> > Jo
>
> Jo,
>
> one other thing to consider - don't use Excel format if you can help it -
it
> requires seperate modules, and slows everything down considerably. It's
> much easier to do (and quicker to run) if you save the file as a CSV (i.e.
> text!).
>
> Regards,
>
> Garry
>
>
------------------------------
Date: Thu, 31 Jul 2003 00:11:42 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: getting complete file listings in perl
Message-Id: <bg9g0s$mg8sv$1@ID-184292.news.uni-berlin.de>
c@msn.com wrote:
> I'm stuck in trying to get a list of files through use of a perl
> script running locally on a windows machine.
<snip>
> The problem arises from the fact that windows will not allow many
> kinds of files to be visible in either windows itself or DOS.
Could you expand on that?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 30 Jul 2003 23:35:54 GMT
From: Xaonon <xaonon@hotpop.com>
Subject: Re: getting complete file listings in perl
Message-Id: <slrnbih041.8hk.xaonon@xaonon.local>
Ned i bach <mvagivo75i0cbmlffunuun215lkrv4vv45@4ax.com>, c@msn.com
<c@msn.com> teithant i thiw hin:
> As a test case, I'm trying to get a listing of the tree below
> c:\windows\temporary internet files\ on the assumption that if I can get
> that accurately, I'll have accuracy elsewhere.
>
> Most of the win32 interface stuff like file::glob and suchlike miss some
> of these files and fail to get size & date info in one pass.
>
> Does anyone know how to do this without having to write a standalone pure
> DOS app to be called to get a listing?
Have you tried File::Find? If that doesn't work, you could write a little
recursive function like this (warning, untested code):
sub find_rec( $ )
{
my $path = shift;
process $path; # Whatever you want to do for each file
if( -d $path )
{
opendir CURR, $path or die "$0: $path: $!\n";
my @dir = grep { $_ ne "." and $_ ne ".." } readdir CURR;
closedir CURR;
find_rec "$path\\$_" foreach @dir;
}
}
and pass the root of the directory tree you want as the argument. The
readdir should pull out all the files in that directory, regardless of
whether the OS thinks they're hidden or anything (otherwise, what good would
they be?). If it's just the contents of one single directory you want, a
simple opendir/readdir will do the trick. Either way, though, you're going
to have to pull out the date and size information yourself, but the file
test operators should make that pretty easy.
--
Xaonon, EAC Chief of Mad Scientists and informal BAAWA, aa #1821, Kibo #: 1
Visit The Nexus Of All Coolness (i.e. my site) at http://xaonon.dyndns.org/
"I don't mizzle shizzle if real wizzles are used. What I do mizzle is made
up slizzle, like shizzle dizzle. What the fizzle?" -- not Lots42
------------------------------
Date: Thu, 31 Jul 2003 00:15:17 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: getting complete file listings in perl
Message-Id: <20030730201657.1a85b8b0.jwillmore@cyberia.com>
> Most of the win32 interface stuff like file::glob and suchlike miss
> some of these files and fail to get size & date info in one pass.
>
> Does anyone know how to do this without having to write a standalone
> pure DOS app to be called to get a listing?
I think this may be what you're looking for:
#!c:/perl/bin/perl -w
use strict;
use vars qw/@files/;
opendir DIR, 'c:\windows\temporary internet files';
or die "Can't open directory\n$!\n";
@files = readdir DIR
or die "Can't read directory\n$!\n";
closedir DIR;
for my $f(@files){
my @stats = (stat $f);
#note: modification time is in epoch
print "$f is $stats[7] bytes in size and was last modified
$stats[9].\n";
}
exit;
This gives you the size in bytes and the modification time in epoch
(time, in seconds, since 1/1/1970). I'll leave it up to you to choose
how to convert epoch to "human" time. There's a flury of info on how
to do this. As far as the files that you don't get, you need to be
more specific about what file types you're missing.
This is just one way to do it - there are others around.
HTH
Jim
------------------------------
Date: Thu, 31 Jul 2003 00:51:58 GMT
From: Xaonon <xaonon@hotpop.com>
Subject: Re: getting complete file listings in perl
Message-Id: <slrnbih4iq.916.xaonon@xaonon.local>
Ned i bach <slrnbih041.8hk.xaonon@xaonon.local>, im teithant i thiw hin:
> sub find_rec( $ )
> {
> my $path = shift;
>
> process $path; # Whatever you want to do for each file
>
> if( -d $path )
> {
> opendir CURR, $path or die "$0: $path: $!\n";
Er, make that
opendir CURR, $path or warn( "$0: $path: $!\n" ), return;
That way the function will keep going even if it can't open some directory
for whatever reason.
--
Xaonon, EAC Chief of Mad Scientists and informal BAAWA, aa #1821, Kibo #: 1
Visit The Nexus Of All Coolness (i.e. my site) at http://xaonon.dyndns.org/
"Kona, the perfect tropical paradise for today's Nazgūl. You'll be right at
home among the blasted desolation." -- Kev In, Boyz Out
------------------------------
Date: Wed, 30 Jul 2003 21:37:06 -0400
From: bd <bdonlan@bd-home-comp.no-ip.org>
Subject: Re: getting complete file listings in perl
Message-Id: <pan.2003.07.31.01.37.04.936748@bd-home-comp.no-ip.org>
On Wed, 30 Jul 2003 13:50:13 -0700, wrote:
> I'm stuck in trying to get a list of files through use of a perl script running locally on a windows
> machine.
>
> What I'd like to see is something like:
>
> ------------------------
> tutorial <DIR> 07-12-03 11:00p tutorial
> work <DIR> 07-19-03 10:00p work
> activepe msi 8,852,456 03-30-03 7:22p ActivePerl-5.6.1.635-MSWin32-x86.msi
> dirtest pl 201 07-28-03 7:30p dirtest.pl
> output txt 0 07-28-03 7:24p output.txt
> perldata htm 34,203 07-12-03 11:09p Perl Data Structures Cookbook.html
> ---------------------
>
> which I can get by backticking this way:
>
> @dirlist= `dir /a /s`;
>
> The problem arises from the fact that windows will not allow many kinds of files to be visible in
> either windows itself or DOS.
>
> As a test case, I'm trying to get a listing of the tree below c:\windows\temporary internet files\
> on the assumption that if I can get that accurately, I'll have accuracy elsewhere.
>
> Most of the win32 interface stuff like file::glob and suchlike miss some of these files and fail to
> get size & date info in one pass.
>
> Does anyone know how to do this without having to write a standalone pure DOS app to be called to
> get a listing?
Does opendir/readdir/closedir show them? If so, use them to get the list
of files, and call stat on them. It won't give you both the long and short
filenames, though - there may be a module for it, but I don't do win32
programming.
--
Freenet distribution not available
------------------------------
Date: Wed, 30 Jul 2003 22:43:02 GMT
From: "mgarrish" <mgarrish@rogers.com>
Subject: Re: perl/tk back end questions
Message-Id: <WRXVa.39258$rsJ.27810@news04.bloor.is.net.cable.rogers.com>
"Go Perl" <puissant00@yahoo.com> wrote in message
news:d3825316.0307301326.3195a7c5@posting.google.com...
> I have a program which takes some inputs like number of inputs, and
> some names of the files and then runs the simulation. Now i have
> created a front end for this program using Tk. I want to connect the
> front end to my program..and since i am new to GUI interfacing with my
> perl program. I need help as to how i can use the text boxes, radio
> buttons and list boxes to send information into my program so that i
> could run from my run command on GUI.
As I mentioned in my last email, you should post these sorts of questions to
comp.lang.perl.tk. It's good that you're trying to learn, but there seems to
be a lot that you don't know both about Tk and Perl. For one, GUIs aren't
generally stand-alone programs that run other programs. It's not terribly
efficient to be making system calls every time you want to process some data
or do anything with your script. You should take the time to read up on
object-oriented programming, because it becomes essential when you start
wandering into the world of GUI (and will help you get where you're slowly
heading right now).
That you are struggling with the basics of Tk programming in Perl suggests,
however, that you've gotten yourself in over your head. I know the
documentation is generally poor for the Tk modules (at least when getting
started), but there are other resources at your disposal. For one, you
should read over the Perl Tk faq:
http://www.lns.cornell.edu/~pvhp/ptk/ptkFAQ.html After that, I would start
using groups.google.com to search for the answers to your problems (there is
a whole newsgroup devoted to this kind of programming after all!). Then, if
you're still stuck, try posting to *comp.lang.perl.tk*. Sorry to keep
stressing that last point, but you really are in the wrong place.
Matt
------------------------------
Date: 30 Jul 2003 22:35:48 GMT
From: Steve Lidie <lusol@cube0.CC.Lehigh.EDU>
Subject: Re: perl/tk back end questions
Message-Id: <bg9h84$gm4@fidoii.CC.Lehigh.EDU>
Go Perl <puissant00@yahoo.com> wrote:
> I have a program which takes some inputs like number of inputs, and
> some names of the files and then runs the simulation. Now i have
> created a front end for this program using Tk. I want to connect the
> front end to my program..and since i am new to GUI interfacing with my
> perl program. I need help as to how i can use the text boxes, radio
> buttons and list boxes to send information into my program so that i
> could run from my run command on GUI.
> Thanks very much for the help.
> ~GP~
Consider asking your Perl/Tk questions in comp.lang.perl.tk - lots of
Tk-centric help there.
------------------------------
Date: Wed, 30 Jul 2003 23:56:01 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: Read from SSL IMAP
Message-Id: <20030730195741.62d93eb5.jwillmore@cyberia.com>
> James Willmore <jwillmore@cyberia.com> writes:
> > try:
> >
> > BEGIN{
> > push @INC,'/home/hasting/scripts/HELP/PERL/mod';
> > }
>
> This is equivalent to
>
> use lib '/home/hasting/scripts/HELP/PERL/mod';
>
> which is more idiomatic Perl.
>
> -=Eric
True. Thanks. Jim
------------------------------
Date: Thu, 31 Jul 2003 00:41:18 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: regular expression question
Message-Id: <pan.2003.07.30.22.41.16.567742@kamelfreund.de>
Bart Van Loon wrote at Wed, 30 Jul 2003 10:35:32 +0000:
> is it possible to make a regular expression match for the following
> situation:
>
> I have a string, looking like 'foobarbarbar'. I don't know what foo is,
> nor what bar is, the only thing I know is that I have a string X,
> concatenated an undefined number of times with a string Y. My goal is to
> find out how many times this string Y (bar) is repeted, without knowing
> what it exactly is.
>
> Something like ^.*(.*)*$ maybe?
perl -e '$_ = "foobarbarbar"; /((.*)\2+)$/; print length($1)/length($2)'
Greetings,
Janek
------------------------------
Date: 30 Jul 2003 23:28:00 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: split alternative using regexp?
Message-Id: <bg9ka0$gvj$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Paul Boardman:
> Tassilo v. Parseval wrote:
>> Emulating split() with regexes sounds easier than it is. There is no
>> generic way to turn a split statement into an equivalent match (at least
>> none I know of). For instance, in a case like
>>
>> @p = split /a/, $string;
>>
>> split() wont care whether $string begins, ends or even contains an 'a'.
>> It'll just do the right thing. If you use a match instead, you have to
>> take these different cases into account yourself. Take this:
>>
>> # the easy case
>> my $string = "bbabba";
>> my @parts = $string =~ /(.*?)a/g;
>> print join "*", @parts;
>> __END__
>> bb*bb
>>
>> This works as expected. But now prepend an 'a':
>>
>> my $string = "abbabba";
>> my @parts = $string =~ /(.*?)a/g;
>> print join "*", @parts;
>> __END__
>> *bb*bb
>>
>> So suddenly you end up having the empty string in $parts[0]. This could
>> be fixed by adding a grep():
>
><snip>
>
> Isn't this how split behaves as well? i.e. split would put 'undef' in
> $parts[0].
>
> perl -le '$_ = "abbabba"; print join(":", split "a")'
>:bb:bb
Arguably, yes, split() would produce an undef in this case. That would
mean there is at least one edgecase less to worry about.
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: Thu, 31 Jul 2003 03:24:34 GMT
From: Dave Brown <dhbrown@hobbes.dhbrown.net>
Subject: Web page with frames...
Message-Id: <slrnbih2u1.dcn.dhbrown@hobbes.dhbrown.net>
I'm trying to create a web page which has 2 frames, left and right.
In the left frame is a form to enter a number of data elements. In
the right frame, to start with, is some text with instructions. The
user is to enter data into the left frame and submit, in which case
calculations take place, and the results are then displayed in the
right frame. (The data is to be retained in the left frame in case
the user wants to make some changes to it, and resubmit.)
I've got the code written for the left frame. I've got code written to
do the calculations. Here's the question: when I submit the form, which
kicks off the CGI script to do the calculations, what do I do (I presume)
in the CGI script to get it to send the result to the frame on the right?
I've thought that I could probably have the CGI script create an html
page, and then put a "Display" button in the left frame to have it
"target" its output to the right frame. But I was wondering if I could
do something so that it would send it automatically without the Display
button.
Any hints to get me started in the right direction would be appreciated.
--
Dave Brown Austin, TX
------------------------------
Date: Thu, 31 Jul 2003 01:01:25 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: weird "perl -e" behaviour
Message-Id: <pkent77tea-B83515.01012531072003@usenet.force9.net>
In article <slrnbifcnu.n5.zebuwin@pingou.bluewin.ch>,
Francois Wisard <zebuwin@yahoo.fr> wrote:
> I encounter a strange "perl -e" behaviour since I'm running FreeBSD 5.1
> (Perl 5.6.1). My one-liners are refused with strange error messages.
Someone's already pointed out that this is just bash interpolating
variables, e.g:
> bash-2.05b$ perl -e "@a=('a'..'z');print $a[5]"
> ARRAY(0x810115c)bash-2.05b$
I get the same. If we do this, to see what the argument really is:
$ echo "@a=('a'..'z');print $a[5]"
@a=('a'..'z');print [5]
And now it's obvious why we get the array ref.
> bash-2.05b$ perl -e "$_="abc";s/b/c/g;print $_"
> Undefined subroutine &main::ls called at -e line 1.
I get:
$ echo "$_="abc";s/b/c/g;print $_"
@a=('a'..'z');print [5]=abc;s/b/c/g;print @a=('a'..'z');print [5]
but then if I run ls -lab:
$ echo "$_="abc";s/b/c/g;print $_"
-lab=abc;s/b/c/g;print -lab
And so on... this is why I generally use single quotes for perl -e :-/
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Wed, 30 Jul 2003 19:02:17 -0400
From: bd <bdonlan@bd-home-comp.no-ip.org>
Subject: Re: zero but true?
Message-Id: <pan.2003.07.30.23.02.16.189070@bd-home-comp.no-ip.org>
On Wed, 30 Jul 2003 12:51:57 +0000, Villy Kruse wrote:
> On Wed, 30 Jul 2003 13:07:42 +0000,
> Rich <scriptyrich@yahoo.co.uk> wrote:
>
>
>>Gregory Toomey wrote:
>>
>>> "bill" <bill_knight2@yahoo.com> wrote in message
>>> news:bg6i4s$p8m$1@reader1.panix.com...
>>>>
>>>>
>>>> $ perl -e 'print "$]: ", 0E0 ? "OK\n" : "not OK\n"'
>>>> 5.008: not OK
>>>>
>>>> Isn't 0E0 supposed to evaluate to true?
>>>>
>>>
>>> When does 0 evaluate to true in Boolean logic?
>>>
>>> If you expect 0 to evaluate to true, do you expect 1 to evaluate to false?
>>>
>>> gtoomey
>>
>>Well I dunno why you're being so sarcastic about this:
>>
>>perldoc DBI, for example:
>>
>> "For a non-"SELECT" statement, "execute" returns the number of rows
>> affected, if known. If no rows were affected, then "execute"
>> returns "0E0", which Perl will treat as 0 but will regard as true."
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>>So, as another poster mentioned, it should be "0E0":
>>
>> perl -e 'print "$]: ", "0E0" ? "OK\n" : "not OK\n"'
>> 5.008: OK
>>
>>An easy mistake to make, as I know from experience, and one that at least
>>deserves a sensible reply IMHO.
>>
>
>
> Wheter 0e0 or 0E0 is a zero may depend on the perl version. My old version
> complains that 0E0 is a bareword, and thus not a zero. 0.E0 is zero though.
Not 0E0, '0E0':
perl -e 'print "False\n" unless "0E0"'
--
Freenet distribution not available
Today is the tomorrow you worried about yesterday.
------------------------------
Date: Thu, 31 Jul 2003 02:08:54 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: zero but true?
Message-Id: <ogugiv4bf2r8in44skdcs8phbp75gga946@4ax.com>
Villy Kruse wrote:
>Wheter 0e0 or 0E0 is a zero may depend on the perl version. My old version
>complains that 0E0 is a bareword, and thus not a zero. 0.E0 is zero though.
A bareword starting wth a digit?!? *boggle*
What perl version would that be?
--
Bart.
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5295
***************************************