[12042] in Perl-Users-Digest
Perl-Users Digest, Issue: 5642 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 12 15:07:23 1999
Date: Wed, 12 May 99 12:00:22 -0700
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, 12 May 1999 Volume: 8 Number: 5642
Today's topics:
"mkdir" make unaccessible directory.... (Ryan Ngi)
Better solution ? tvn007@my-dejanews.com
Re: Better solution ? <lanny.gilbert@bellsouth.net>
Re: cgi submitting a form to another server (Charles R. Thompson)
Re: change system time to mm/dd/yy format (Charles R. Thompson)
Conditional Search and replace solution (Hawkwynd)
Re: CPAN-POD & pulling my hair OUT! HELP! do the doc's <nospam@atanytimeonthe.net>
Re: dos ^M to unix \n <jtjuslin@spam.cc.hut.fi>
Re: Finding Total Directory Size in Perl. <gary@rdss.com>
Re: Getting Access to Perl - how? <camerond@mail.uca.edu>
Re: Getting file date <cassell@mail.cor.epa.gov>
Re: Getting file date <jtjuslin@spam.cc.hut.fi>
Re: How do I get a hash slice as a hash in a Perlish wa <a794636757612661@mailcity.com>
Re: How do I get a hash slice as a hash in a Perlish wa <a794636757612661@mailcity.com>
How do I make a sytem() exit on control-C <anybody@ml.com>
Re: How to CHMOD to 755 using check boxes? <jtjuslin@spam.cc.hut.fi>
Re: Need help to modify this form mailer cgi. (Charles R. Thompson)
Re: Need help to modify this form mailer cgi. <jtjuslin@spam.cc.hut.fi>
password checking pontz@channel1.com
Re: password checking (Charles R. Thompson)
Problem with Push <eslater@frinc.com>
Re: Problem with Push (Charles R. Thompson)
Re: reading a text file backwards (Charles R. Thompson)
Re: THE GD PACKAGE !!! <cassell@mail.cor.epa.gov>
Re: un esprit lisp dans un corps C <tchrist@mox.perl.com>
What am I doing wrong? (Jared Hecker)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 06 May 1999 17:54:45 GMT
From: ryanngi@hotmail.com (Ryan Ngi)
Subject: "mkdir" make unaccessible directory....
Message-Id: <3550a08c.43057400@news.inet.co.th>
i use "mkdir" in a CGI, when i try it on BROWSER, the CGI make some
unaccessible directory ,and also "chmod" is not work for it....
i think the directory's UID isn't mine,... and i try "chown"... but
not work.... do you know How to fix it???
----------
------------------------------
Date: Wed, 12 May 1999 18:24:57 GMT
From: tvn007@my-dejanews.com
Subject: Better solution ?
Message-Id: <7hch1l$hhs$1@nnrp1.deja.com>
Hi,
Here is the problem:
To pad 2000 "X" to thousand of lines
Here is my solution
for ($number =0; $number < 2000; $number++) {
$first_line = X.$first_line;
$second_line = X.$second_line;
...
$thousand_line = X.$thousand_line;
}
Does anyone has better solution without goes through
the for loop.
Thanks in advance,
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 12 May 1999 14:55:15 -0400
From: Lanny Gilbert <lanny.gilbert@bellsouth.net>
Subject: Re: Better solution ?
Message-Id: <3739CE93.95501403@bellsouth.net>
Try the "x" operator
As in:
$first_line = 'X' x 2000; # puts 2000 X's in $first_line
.
.
.
$thousand_line = 'X' x 2000; # puts 2000 X's in $thousand_line
Lanny Gilbert Perl Hacker Wanna-be
lanny.gilbert@bellsouth.net
tvn007@my-dejanews.com wrote:
> Hi,
>
> Here is the problem:
>
> To pad 2000 "X" to thousand of lines
>
> Here is my solution
>
> for ($number =0; $number < 2000; $number++) {
>
> $first_line = X.$first_line;
> $second_line = X.$second_line;
>
> ...
>
> $thousand_line = X.$thousand_line;
> }
>
> Does anyone has better solution without goes through
> the for loop.
>
> Thanks in advance,
>
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 12 May 1999 18:24:41 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: cgi submitting a form to another server
Message-Id: <MPG.11a392caa4fbbfe99896a6@news>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <7hce4a$f8u$1@nnrp1.deja.com>, michael_555@my-dejanews.com
says...
> My concern is that anyone can read my LOGIN value by
> doing a 'view source' on my page.
So don't put it in the page. Make them type it... and remove it from the
input tags after processing.
> I don't want anyone to get my LOGIN
> id.
So don't put it in the page. Make them type it... and remove it from the
input tags after processing.
> (or this was all pointless...)?
If it goes over the wire, it's accessible.
maybe I just missed the point here, then again it doesn't really have
anything to do with the NG
--
Charles R. Thompson
RainCloud Studios
"Perl. There, I said it."
------------------------------
Date: Wed, 12 May 1999 18:27:57 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: change system time to mm/dd/yy format
Message-Id: <MPG.11a3938b8a245ea79896a7@news>
In article <MPG.11a38a01f89ab4f69896a2@news>, Charles R. Thompson says...
Sorry guys... I don't know how this one got here. I thought I closed it,
somehow it got sent down the pipe. Follow up was already posted making it
useless to cancel thread.
Apologies
------------------------------
Date: Wed, 12 May 1999 17:58:23 GMT
From: hawkwynd@adelphia.net (Hawkwynd)
Subject: Conditional Search and replace solution
Message-Id: <3739c13d.178501872@news.internext.fr>
A word of thanks to all who replied to my request for assistance with
the following script. This segment does *exactly* what I need it to
do, and without the assistance of the great replies I've received on
this ng, I wouldnt have found the solution as quickly as I did.
Script psuedo:
Open each file in a directory
rename the file for output to a new directory
within each text file
find and remove octals 14 and 15
find NOTES: and delete that line if no other text on that line
find ASSMD MTG: L: P: and remove if matched exactly.
write the new file
-- My gratitue goes to those who assisted me.
script:
foreach(@myarray) {
next unless /^\d{2}_(\d{4})\.txt$/i;
open(INF,"$file_dir/$_");
open(OUTF,">$outdir/$1");
while(<INF>) {
tr/\014\015/ /d;
if ($_ =~m/NOTES: /s){
$_ =~s/NOTES:/ /s;
}
if ($_=~m/ASSMD MTG: L: P: /s){
$_ =~s/ASSMD MTG: L: P: / /s;
}
print OUTF;
}
-------------------------------------------------
Talk about it at Hawkwynd's keep Discussion Forum
http://hawkwynd.tzo.com/discus/index.html
------------------------------
Date: Wed, 12 May 1999 11:10:39 -0700
From: N <nospam@atanytimeonthe.net>
Subject: Re: CPAN-POD & pulling my hair OUT! HELP! do the doc's really suck this bad?
Message-Id: <3739C41F.3E7C@atanytimeonthe.net>
Eric Bohlman wrote:
>
> N <nospam@atanytimeonthe.net> wrote:
> : I can't beleive how much time I have spent looking through CPAN stuff
> : trying to find what I would call "struct" - where you would find all the
> : little variables / calls that you can make to a MODULE.
>
> : I thought the whole idea of creating a module is you want other people
> : to use it's features, so first thing you should show is how to call your
> : module and then what all the variables / calls names you can make.
>
> : Instead I get a big huge half a page on my screen showing NAME,
> : SYNOPSIS (with like two little lines in it), DESCRIPTION (says a little
> : story about how the guy made it and such. They should put this crap at
> : the END, where's the beef???
>
> Are you sure you're reading all the documentation for those modules?
> Most Perl modules have the documentation embedded inside in the form of
> POD, and you can read it either by using perldoc (e.g. 'perldoc
> Text::Query::Advanced') or by using one of the pod2* programs to extract
> the documentation and turn it into HTML, TeX, a manpage, or what have
> you. Only the biggest modules have documentation in external files.
> I've generally found the internal documentation for most modules on CPAN
> to be quite comprehensive, though I admit that a few seemed to be written
> by authors with a pathological fear of documentation.
>
> In order for me to figure out where you're coming from, I'd like you to
> evaluate the documentation for either or both of Text::Query::Advanced or
> Text::Query::Simple (both modules that I wrote). I'd like to think I
> documented them well, but I'm hardly in a position to be objective about it.
Thanks for the response, I am using
http://theory.uwinnipeg.ca/search/cpan-search.html
http://linux.fh-heilbronn.de/doku/PERL/modules/
ftp://ftp.iguide.com/pub/mirrors/packages/perl/CPAN//index.html
To find what I need when I get stuck, I don't have any "system" perl doc
calls, meaning there's no man pages on my PC here or whatever. I must
access html pages to find what docs I need.
I really don't want to go to each module's ".tar.gz" file and extract
the docs, that's a real big waste of time and doesn't allow for
searching within docs very well.
Maybe the new way of doing docs is some automatic program that opens the
files and reads a file I don't know, but if it is CPAN needs to make a
web interface to it.
Go to the pages above and pretend like you want to know the variable
names and calls you can make to a module, then tell me that a idiot like
myself can make heads or tails of what you find.
The "Struct" I mentioned was from "C", meaning something like a "C"
struct, but documented so I know what the module expects.
Thanks, please just post to the group.
------------------------------
Date: Wed, 12 May 1999 21:50:03 +0300
From: Jukka Juslin <jtjuslin@spam.cc.hut.fi>
Subject: Re: dos ^M to unix \n
Message-Id: <3739CD5A.A462D09F@spam.cc.hut.fi>
Chris Costello wrote:
>
> In article <3739969F.102C9281@ireland.sun.com>, Peter Doyle wrote:
> > Hi,
> > I'm trying to substitute the ^M added to each line from a text box in a
> > CGI form.
> >
> > What I have (which isn't working...)
> >
> > sub dos2unix
> > { }
Well, if you are on SunOS 2.x dos2unix is implemented in the system.
++Jukka
------------------------------
Date: Wed, 12 May 1999 14:07:14 -0400
From: Gary Ebert <gary@rdss.com>
Subject: Re: Finding Total Directory Size in Perl.
Message-Id: <3739C34E.D1F0878F@rdss.com>
"Charles R. Thompson" wrote:
>
> [This followup was posted to comp.lang.perl.misc and a copy was sent to
> the cited author.]
>
> In article <37388967.BB5B4BD5@auger.net>, nick says...
> > How do you go about finding the total size of a directory (including all
> > subdirectories), I have tried the "du" command with the backticks, but
> > it always times out on my server... Is there another way to do it?
>
> egads. Yes. :) Using File::Find will make this a snap for you. It's
> included with the standard distribution, so it should be on your machine.
> If this script balks at you about it, you'll have to get it and install
> it from CPAN. File find can work wonders on directory trees. I've only
> been using it for about a week now and can't figure out how I ever did it
> before. :)
>
> dirfind.pl follows....
[snip]
You could also do it without using File::Find (not that there is anything
wrong with that :-) like this:
#!/usr/bin/perl
use strict;
my $size = 0;
my $dir = $main::ARGV[0];
# note that the directory is passed in on the command line
# instead of hard coded into the script
opendir (FILE, $dir) or die "could not open $_\n";
while ($_ = readdir FILE) {$size += -s unless (/^\.{1,2}?$/)}
# the unless statement insures that you do not count the . and .. files
print "Total file size for $dir = $size bytes\n";
# END
And I am sure that this could be trimmed down even more.
> Have Fun.
> --
> Charles R. Thompson
> RainCloud Studios
> "quote"
--
Gary Ebert Operations Administrator
Voice: (301) 428-2115 Comtech Mobile Datacom Corporation
Fax: (301) 428-1004 19540 Amaranth Drive
Pager: (800) 777-4681 PIN: 3981842 Germantown, MD 20875-2126
------------------------------
Date: Wed, 12 May 1999 13:52:47 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
To: Terry Mealy <spike1965@worldnet.att.net>
Subject: Re: Getting Access to Perl - how?
Message-Id: <3739CDFF.22C45FA4@mail.uca.edu>
Terry Mealy wrote:
>
> You can practice perl on a machine that isn't even connected to the net.
> But if you want to see the CGI's in action, you have to have a website and a
> server.
BRAAAK!! Wrong (1): Website. You can install a server on your machine
(even a Window$ machine) and run as http://localhost (http://127.0.0.1).
There is a myriad of free (not shareware) servers out there for
download, and the most popular one (even for the commercial folks) is
Apache (http://www.apache.org).
Wrong (2): Server. Actually, if you use CGI.pm (finally got some Perl
content into this thread), then you can simulate CGI at the command
line, although it's not nearly as much fun as running your own server
and getting the formatted output on your browser.
> > I'm very curious to learn from the people here how you are able to use
> > perl for your cgi scripts. Many ISPs that I'm trying to look at don't
> > support CGI scripting, or don't allow to do your own. Actually, there's
> > one I know that lets you customize their existing scripts (changing a
> > NAME variable or so). But I was really hoping for a good internet
> > resource at a modest/free price so that I can start learning and
> > practicing using perl to make my own simple scripts.
Using either Solution 1 or Solution 2 above for learning the ropes is
absolutely free (can't get much more modest than that).
Cameron
--
Cameron Dorey
camerond@mail.uca.edu
------------------------------
Date: Wed, 12 May 1999 11:28:48 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Getting file date
Message-Id: <3739C860.9A7A5B00@mail.cor.epa.gov>
Howie wrote:
>
> How do I get the date on a file to see when it was last modified? thanks for
> any help.
Perl has more than one operator which can help here.. of course. :-)
Try these commands at a commnad prompt to get help:
perldoc -f -X
perldoc -f stat
The complete info is in the perlfunc manpage, which you can read via
man, or perldoc, or a web browser if you have the HTML version of the
docs, or a grep of the pod version. If you haven't learned all the
ways to access the Perl docs that came with your install, then try this
URL:
http://www.perlmonth.com/articles//rtfm.html
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Wed, 12 May 1999 21:30:52 +0300
From: Jukka Juslin <jtjuslin@spam.cc.hut.fi>
Subject: Re: Getting file date
Message-Id: <3739C8DC.BDB49DE@spam.cc.hut.fi>
Greg Bacon wrote:
>
> In article <RXh_2.11556$tm6.5540@news.rdc1.sdca.home.com>,
> noone@home.com (Howie) writes:
> : How do I get the date on a file to see when it was last modified?
> : thanks for any help.
>
> Perl's stat() operator (and, consequently, the underlying system call)
> is usually very helpful in uncovering all sorts of information about
> files.
Well, it's easy if you just want days since changed (by touch or
edited). I case you want to find out the change time in one day you can
use this example from Jarkko Hietaniemi:
You dont't have to use mtime returned by stat.
Problem is to find changes within one day...* You can do it like this:
use Time::Local;
timelocal(0,0,0,(localtime())[3..5])
*) -M "file" = (time(time_script_started)-mtime("file"))/86400
++Jukka
------------------------------
Date: Wed, 12 May 1999 11:13:32 -0700 (PDT)
From: Dwayne Retsky <a794636757612661@mailcity.com>
Subject: Re: How do I get a hash slice as a hash in a Perlish way?
Message-Id: <0926532812e9f02311ea459dd976a74403c90d2e4a@mailcity.com>
In article <MPG.11a2786a1d74b73c989a35@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) wrote:
>A hash slice makes an array makes another hash via a hash slice.
>
> my @vowels = qw( a e i o u );
> my %nerfherder;
> @nerfherder{@vowels} = @gundark{@vowels};
> print map "$_: $nerfherder{$_}\n" => sort keys %nerfherder;
I like this better than iterating over the keys, because writing out
loops should be avoided. It will make 'u' into a key of %nerfherder
all the time, though, even when it isn't a key of %gundark, doesn't
it? That's OK for my purposes, though, since all the vowels should be
there. But it's not quite right.
I was hoping that it'd be possible to do it anonymously, without having
to name %nerfherder. (I should not have named it in my original post.
My bad.) That way, I could pass it into a subroutine all on one
possibly long line. Is it possible?
>What's with the variable names? What other foreign culture haven't I
>tapped into?
They're mentioned in THE EMPIRE STRIKES BACK.
10 PRINT "Not another Perl hacker!"
20 END
--
Dwayne Retsky
Mail sent to the address on this posting is rarely, if ever, read.
Please respond to the proper newsgroup.
------------------------------
Date: Wed, 12 May 1999 11:29:45 -0700 (PDT)
From: Dwayne Retsky <a794636757612661@mailcity.com>
Subject: Re: How do I get a hash slice as a hash in a Perlish way?
Message-Id: <0926533784e9f02311ea459dd976a74403c90d2e4a@mailcity.com>
In article <x3yyaiunxii.fsf@tigre.matrox.com>,
Ala Qumsieh <aqumsieh@matrox.com> wrote:
>How about something like:
>
> my @vowels = qw/a e i o u/;
>
> @nerfherder{@vowels} = @gundark{@vowels};
That is what I asked for, but it's not what I wanted. Sorry!
Is it possible to do it without naming the other hash?
#include <iostream>
int main() {std::cout << "Not another Perl hacker!\n";}
--
Dwayne Retsky
Mail sent to the address on this posting is rarely, if ever, read.
Please respond to the proper newsgroup.
------------------------------
Date: 12 May 1999 18:23:00 GMT
From: "Merrill Lynch" <anybody@ml.com>
Subject: How do I make a sytem() exit on control-C
Message-Id: <01be9ca0$49692300$a7bff3a9@zuriw14956>
Hi
Does anyone have a solution on how to make a system() exit on control-C?
I am on using perl5.00503 activestate perl for NT4 service pack 3.
Any help would be much appreciated.
Thank you
Dominic Tootell
tootedom@exchange.ch.ml.com
------------------------------
Date: Wed, 12 May 1999 21:02:06 +0300
From: Jukka Juslin <jtjuslin@spam.cc.hut.fi>
Subject: Re: How to CHMOD to 755 using check boxes?
Message-Id: <3739C21D.BFE390BA@spam.cc.hut.fi>
Blue wrote:
>
> I do not know how to CHMOD my cgi to 755. My FTP only give me 9 check boxes
> to click (can't key in numbers):
>
> Owner: 1) Read 2) Write 3) Execute
> Group: 1) Read 2) Write 3) Execute
> Others: 1) Read 2) Write 3) Execute
>
> I am currently have all the nine boxes selected. Although it works, I don't think it is correct. Is it?
You can figure out these chmod's easily, if you think as a remembering
rule that 4 is for read, 2 is for write and 1 is for execute.
Thus, 755 means that owner has rwx, group rx and others rx.
Actually the whole rights thing means that binary numbers are changed to
octal numbers - for example 111 101 010 is changed to octal numbers(0-7)
-> 752. This feels hard at the first hand but is easy while you get used
to it.
755 is typically good for cgi-scripts.
There is also -s and -t options, which can be changed to octal numbers
also...
...Anyway this whole thread is in a wrong news group...
++Jukka
------------------------------
Date: Wed, 12 May 1999 18:19:33 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: Need help to modify this form mailer cgi.
Message-Id: <MPG.11a391924bad9f089896a5@news>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <7hcdcf$jen$1@news5.jaring.my>, Blue says...
First...
> #!/usr/bin/perl
#!/usr/bin/perl -w
use strict;
# followed by a nice big fat stream of errors
> I would like to know how to modify this script so that it would also send
> the sender a copy of the result (that they have submitted).
I can't believe this is gone right by you. It's so freekin obvious. Just
open another mail with the senders address and send it to him!
Sorry... but geez... c'mon.
--
Charles R. Thompson
RainCloud Studios
"That? That's no script. That's your attempt at a rather complex README
file."
------------------------------
Date: Wed, 12 May 1999 21:41:15 +0300
From: Jukka Juslin <jtjuslin@spam.cc.hut.fi>
Subject: Re: Need help to modify this form mailer cgi.
Message-Id: <3739CB4B.8B9AA7C9@spam.cc.hut.fi>
Blue wrote:
> foreach $check(@required) {
> unless ($FORM{$check}) {
> print "Content-type: text/html\n\n";
> print "<html><head><title>Missing
> Information</title></head>\n";
> print "<body><h1>Missing Information</h1><br>\n";
> print "I'm sorry, but it would appear that you've
I don't understand why CGI.pm is not used in this (amongst other
things). It would be much better to be on a bit higher level than
printing pure HTML from a script:
- It's easier and more generic
- You dont have to change everything while XML might
change the representation syntax
Well, this was off-topic (again)...?
++Jukka
------------------------------
Date: Wed, 12 May 1999 18:17:40 GMT
From: pontz@channel1.com
Subject: password checking
Message-Id: <3739c50f.19246010@news1.channel1.com>
Hello
Anyone see what is wron with this sub. What it is suppose to do is
check the password the user enters with the password in .htpassword
file.
sub check_login {
# clean up name first
$in{'name'} =~ y/a-zA-Z0-9/ /c;
$in{'name'} =~ s/\s//g;
my $lname=$in{'name'}; $lname =~ y/A-Z/a-z/;
if (! defined($in{'pass'})) { &print_password }
$pwdFile = new Apache::Htpasswd('.htpasswd');
-e ".htpasswd" || &print_error(".htpasswd file doesnt exist");
if ($pwdFile->htCheckPassord($lname, $in{'pass'})) {
next;
}
}
Please respond by email
Thanks
Brian P
pontz@channel1.com
------------------------------
Date: Wed, 12 May 1999 18:33:37 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: password checking
Message-Id: <MPG.11a394d9cd1e68aa9896a8@news>
In article <3739c50f.19246010@news1.channel1.com>, pontz@channel1.com
says...
Are you using the -w flags or strict here?
What errors are you getting?
What is the script chugging out at you?
> sub check_login {
> # clean up name first
> $in{'name'} =~ y/a-zA-Z0-9/ /c;
> $in{'name'} =~ s/\s//g;
> my $lname=$in{'name'}; $lname =~ y/A-Z/a-z/;
> if (! defined($in{'pass'})) { &print_password }
> $pwdFile = new Apache::Htpasswd('.htpasswd');
> -e ".htpasswd" || &print_error(".htpasswd file doesnt exist");
> if ($pwdFile->htCheckPassord($lname, $in{'pass'})) {
> next;
> }
> }
> Please respond by email
Only when I'm not asked to, that way it's a pleasant suprise.
--
Charles R. Thompson
RainCloud Studios
"That? That's no script. That's your attempt at a rather complex README
file."
------------------------------
Date: Wed, 12 May 1999 14:21:48 -0400
From: "Elliot Slater" <eslater@frinc.com>
Subject: Problem with Push
Message-Id: <7hcgs3$70j$1@goblin.uunet.ca>
I am having a problem getting a push to work correctly. Here is the code
snippet:
#!/usr/local/bin/perl
# Check Perl version
#
require 5.003;
($AuthLoc) = @ARGV;
#This stuff converts [ back to space because the path may contain spaces and
#replaces \ with \\ for the push
$_ = "$AuthLoc";
s/\[/ /g;
s/\\/\\\\/g;
$AuthLoc = $_;
BEGIN {
push(@INC, $AuthLoc);
}
AuthLoc is getting passed as a path. eg: c:\test\temp\
It works fine if I replace the push with: push(@INC, 'c:\\test\\temp\\');
Any help you can provide is appreciated,
Elliot Slater
------------------------------
Date: Wed, 12 May 1999 18:35:57 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: Problem with Push
Message-Id: <MPG.11a3956d8f6400259896a9@news>
In article <7hcgs3$70j$1@goblin.uunet.ca>, Elliot Slater says...
> I am having a problem getting a push to work correctly.
> #!/usr/local/bin/perl
#!/usr/local/bin/perl -w
use strict;
That will get you in shape, then you can focus on the real problem.
--
CT
------------------------------
Date: Wed, 12 May 1999 18:10:14 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: reading a text file backwards
Message-Id: <MPG.11a38f5f326900629896a4@news>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <7hca27$bs4$1@nnrp1.deja.com>, vinh.bui@medstat.com says...
> I am using the following to read a text file from the top line down:
> open (x, $file);
> while ($line=<x>) {
> print $line; }
> close (x);
> Can I read the text file from the last line up?
You could do it, but reading a file line by line is rather inefficient.
You can quickly learn two new things by trying it this way...\
In your situation, reading the file into an array then reversing the
array is the way to go.
#!/usr/bin/perl -w
#rev_array_file.pl
use strict;
# if browser oriented uncomment
# print "Content-type: text/html\n\n";
# you'll need to change this to your file name
open (MYFILE, "/drv1/web/sites/web6517e/index.shtml") || die;
# this line pulls each line from the file into
# your array. ALOT faster. :)
my @filelines = <MYFILE>;
close (MYFILE) || die;
# now we reverse the array and print the
# result
foreach (reverse(@filelines)){
print $_;
}
Further, pulling the file into an array gives you much more flexibility
to process it further.
Hehe... Tom? Wanna run the result through your proxy? It looks pretty
interesting. :)
--
Charles R. Thompson
RainCloud Studios
"blah"
------------------------------
Date: Wed, 12 May 1999 11:10:24 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: THE GD PACKAGE !!!
Message-Id: <3739C410.CD4F8E70@mail.cor.epa.gov>
Miri Bar wrote:
>
> hello, i'm miri from israel.
Hi. I'm David. In future, please don't shout out your subject line.
Some people will even ignore your post when you do it.
> i tried to submit my question at the developer.com site but
> there was an error....
That may not be the right place to go.
> my question: i need to use the gd package in perl, i downloaded
> the files and installed it according to instructions and still i get:
>
> "Can't locate loadable object for module GD in @INC (@INC contains:
> c:\perl\lib c:\perl\site\lib .) at test.pl line 2
> BEGIN failed--compilation aborted at test.pl line 2."
Okay, you're using Perl on a win32 box. Are you using the latest
version of ActiveState Perl? If so, you should be doing your
module installation using PPM whenever possible.
Go to a command prompt and type:
ppm install GD
and let Perl install the package for you. It's much easier
this way. Try it. You'll like it!
> [snip]
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: 12 May 1999 12:04:25 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: un esprit lisp dans un corps C
Message-Id: <3739c2a9@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, mriedel@neuearbeit.de (Marko R. Riedel) writes:
:Tout a fait. Il y a quelques heures seulement que je me demandais
:quelle serait la methode la plus efficace de realiser un 'apply' en
:Perl. Pour que ce soit utile, ca devrait donner des bons resultats
:avec des vrais operateurs comme avec des subs.
Since you asked, here's something that should inspire you. Voici the
reduce() function from Mark-Jason Dominus, published avec permission.
He believes that Graham Barr's `builtin' module also has a (plus vite)
version of the meme chose. This is from one of the classes that he
teaches.
--tom
--------------------------------
Build Your Own map()
**********************
o map() and grep() are great.
o Wouldn't it be nice to make some new, similar operators?
o Example:
$n = reduce { $a + $b } 0, (1, 4, 2, 8, 5, 7)
(Yields the sum, 27)
$n = reduce { $a * $b } 1, (1, 4, 2, 8, 5, 7)
(Yields the product, 2240)
$n = reduce { $a > $b ? $a : $b } 0, (1, 4, 2, 8, 5, 7)
(Yields the max, 8)
$n = reduce { [@$a, $b] } [], (1, 4, 2, 8, 5, 7)
(Yields a list, [1,4,2,8,5,7])
----------------------------------------------------------------
reduce()
**********
sub reduce (&$@) {
my $code = shift;
local $a = shift;
for (@_) {
local $b = $_;
$a = &$code;
}
$a;
}
o (&$@)?!
o local?!
o Why $a() and $b?
----------------------------------------------------------------
reduce()
**********
o Here's a fine, fine trick.
o Let's write a reduce() call to ask if a list contains all positive numbers.
reduce { $a && $b > 0 } "yes", @list;
o If you apply this to the list (0 .. 1000000), it goes all way to the end
o Solution:
reduce { $a && $b > 0 || ($a=undef, last) } "yes", @list;
o last?!
o Yes! last() is dynamically scoped!
--------------------------------
--
Whenever people agree with me I always feel I must be wrong.
--Oscar Wilde
------------------------------
Date: 12 May 1999 18:01:17 GMT
From: jared@pandora.planet.net (Jared Hecker)
Subject: What am I doing wrong?
Message-Id: <7hcfld$895@jupiter.planet.net>
Hi, all -
I am writing a script that must, in part, get the date of a file's last
'touch'. I wrote the following:
#!/usr/bin/perl
@filelist=<>;
$counter == 0;
while(@filelist) {
chop($filelist[$counter]);
print STDOUT ($filelist[$counter],"\n");
open(LIOGFILE,$filelist[$counter]) || die("aarrgghh!");
while($input=<LIOGFILE>) {
$position =index($input,"PS");
chop($position);
$output = substr($input,$position-13,12);
print STDOUT ($output,"\n");
}
}
close(LIOGFILE);
Running, it chokes on the "open(LIOGFILE)" line:
[HDV01]: ls -l PSPPY*.log |testdate.pl
-rw-r--r-- 1 oracle dba 1502 May 11 09:03 PSPPYBLD_.log
aarrgghh! at testdate.pl line 9, <> chunk 94.
Can anyone tell me why?
TIA -
Regards,
jh
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5642
**************************************