[13958] in Perl-Users-Digest
Perl-Users Digest, Issue: 1368 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 13 14:10:59 1999
Date: Sat, 13 Nov 1999 11:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942519909-v9-i1368@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 13 Nov 1999 Volume: 9 Number: 1368
Today's topics:
Re: CGI.pm and Netscape 4.x <@mdo.net>
changing to binmode part way, was Re: output a binary f <flavell@mail.cern.ch>
Re: CHMOD for Net::FTP. Help, cool hackers ! <mwiz@mail.ru>
Re: CHMOD for Net::FTP. Help, cool hackers ! <flavell@mail.cern.ch>
Help me 'Think Perl' <hmarq@interaccess.com>
Re: Help me 'Think Perl' <slanning@bu.edu>
Re: Help me 'Think Perl' (Simon Cozens)
Re: Help me 'Think Perl' (Simon Cozens)
Re: Help me 'Think Perl' <lr@hpl.hp.com>
Re: Help me 'Think Perl' <lr@hpl.hp.com>
Re: Help needed please, simple hash slice question! (Tad McClellan)
Re: How can I determine different "use" statements? (M.J.T. Guy)
Re: How can I determine different "use" statements? <hookman@cwnet.com>
Re: How can I vist a number of websites and email addys (Randal L. Schwartz)
Re: How can I vist a number of websites and email addys (Tad McClellan)
Let me look a Win32-script on Perl <microwizard@my-deja.com>
Re: looking for a developer . . . (Kragen Sitaker)
Re: Module File:Find problem (M.J.T. Guy)
Re: Need help understanding directory structure (NEWBIE (Tad McClellan)
Newbee needs some date functions . . . <no@spam.com>
Newbie: Background Sounds (IL)
Re: Newbie: Background Sounds <flavell@mail.cern.ch>
Re: Newbie: Background Sounds <moseley@best.com>
Re: output a binary file to browser from perl script (Kragen Sitaker)
parsing UNIX mail spool files <cadet@bu.edu>
Re: perl as first language? yjmick@my-deja.com
Re: Perl Wizards <uri@sysarch.com>
Re: PostgreSQL help rheoled@my-deja.com
return height and width of jpeg, gif accessed via url (BLUESRIFT)
searching flatfile with a hash <ben@smooth.co.uk>
Re: searching flatfile with a hash (Kragen Sitaker)
sorting a Hash array? <reembar@netvision.net.il>
Re: sorting a Hash array? <moseley@best.com>
Re: sorting a Hash array? <lr@hpl.hp.com>
Re: sorting a Hash array? (Tad McClellan)
Re: Urgent: simple regexp question tigra@sky.deep.ru
Re: Users uploading pics to a website. <moseley@best.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 13 Nov 1999 09:27:58 -0500
From: "CS" <@mdo.net>
Subject: Re: CGI.pm and Netscape 4.x
Message-Id: <NweX3.3997$YI2.240092@typ11.nn.bcandid.com>
>In any case, it sounds like it's a problem on the server's side.
>
Thanks for the info, mike. yes, it does seem to be a server side problem.
On my local server, I have this problem. On my remote webhost, it works
out.
------------------------------
Date: Sat, 13 Nov 1999 17:50:50 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: changing to binmode part way, was Re: output a binary file
Message-Id: <Pine.HPP.3.95a.991113172028.21249B-100000@hpplus01.cern.ch>
Recalling the previous discussion about
> > if (open(FILE,"$file")) {
> > binmode FILE; #
> > print <FILE>; # prints complete file
> > close FILE;
[...]
and the recent discussion about the correct way to code Perl for writing
CGI headers to non-NPH scripts, it occurred to me that the following
scenario could arise.
# suppose STDOUT is in text mode at this point
print "Content-type: application/fubar\n\n";
# Now we want to send binary; assume BINFILE was already successfully
# opened and binmode()ed.
binmode STDOUT;
print <BINFILE>;
[...]
My question is, does binmode() take effect at the appropriate point in
the written data stream, in which case no extra precations seem to be
required; or could the binmode "overtake" still-buffered data, in which
case it would seem necessary to flush the buffers before issuing the
binmode() ?
I tried reading perldoc -f binmode, but instead of what I would consider
to be technical documentation, I'm sorry to have to say that I found
something that read like a party political broadcast on behalf of the
unix advocacy party. Don't get me wrong: I'm a convinced user of unix
systems, and a very unconvinced user of M$ systems; but that kind of
wording is still not what I look for in technical documentation, sorry.
I also looked for perldoc -q on binmode and on flush, but am still no
wiser.
OK, the alternative approach, when we take into account that the CGI
spec told us that in non-NPH scripts the server should accept any of the
popular line-end representations, would be to binmode STDOUT from the
start, and write the CGI headers with whatever newline representation
one considered appropriate (we could take votes on \n, \012 etc).
Perhaps it's pointless pedantry on my part, but non-NPH CGI headers are
supposed to be text, and so it seemed to me to be proper hygiene to
treat them as such, and only go into binary mode for the actual binary
data.
all the best
------------------------------
Date: Sat, 13 Nov 1999 16:02:15 GMT
From: MetaWizard <mwiz@mail.ru>
Subject: Re: CHMOD for Net::FTP. Help, cool hackers !
Message-Id: <80k226$mko$1@nnrp1.deja.com>
In article <80h6s2$n56$1@nnrp1.deja.com>,
MetaWizard <mwiz@mail.ru> wrote:
> I need realization of CHMOD method for Net::FTP.
> Please, help me!
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
The VirtualAvenue(www.virtualave.net) freehosting server enable
entrance to your account only via FTP. To change mode of files in my
directories I am writing "chmod 0666 test.txt"(for examle).
So I need realization of this method to make this procedure from Perl-
script. But Net::FTP doesn't enable it. I ask everybody who may help me!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 13 Nov 1999 18:09:29 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CHMOD for Net::FTP. Help, cool hackers !
Message-Id: <Pine.HPP.3.95a.991113175855.21249C-100000@hpplus01.cern.ch>
On Sat, 13 Nov 1999, MetaWizard wrote:
> entrance to your account only via FTP. To change mode of files in my
> directories I am writing "chmod 0666 test.txt"(for examle).
> So I need realization of this method to make this procedure from Perl-
> script. But Net::FTP doesn't enable it.
I haven't tried it, but I would suggest you probably need to use
Net::FTP's 'quot' to send a 'SITE CHMOD' command to the remote server.
Try it by hand from an FTP client first. When I try it on my host:
ftp> quot help site chmod
214 Syntax: SITE CHMOD <sp> mode <sp> file-name
ftp> quot site chmod 755 foobar
200 CHMOD command successful.
Then you could try the same thing via the module.
good luck (wouldn't this question have been more on-topic on the
c.l.p.modules group? Oh, and I read this posting by accident: if I had
spotted "cool hackers" in the subject line first, I would have plonked
it unread).
------------------------------
Date: Sat, 13 Nov 1999 08:03:41 -0600
From: "Hank Marquardt" <hmarq@interaccess.com>
Subject: Help me 'Think Perl'
Message-Id: <s2qs189jhsq45@corp.supernews.com>
I'm pretty new to perl, but did a fair amount of C code once upon a time;
and that's my problem I keep thinking in C, knowing somewhere somehow it's
what I'm trying to do is real easy if I were thinking perl.
Task: Get the slashdot headline file and format it on my web page. The
output and CGI part I've got nailed, it's the file parsing that's got to be
easier. For those who don't know the file, it's a text file with '&&' as
record delimiters and \n as field delimiters with 3 fields in each record;
Date/Time, Title and URL for the story.
Getting the file isn't the problem, I can ftp it, or I can slurp it into
memory with LWP::Simple - Get. But then what? The 'C' guy in me goes into
'char' mode and wants to look for the delimiters, yet I know something like
'split' or a regex should make something like
($myDate, $myTitle, $myURL) = split .... OR
($myDate, $myTitle, $myURL =~ /\n/\n/\n
should work? I guess I'm confused by the delimiter choices; split seems to
expect \n as a record delimiter, not a field delimiter and similarly if I
use file operations, I'm back to a if/switch statement looking for the '&&'
delimiter.
I just keep thinking "there has to be an easier way". Heck I can code the
brute force look for the delimiter stuff, but that doesn't seem to be "the
spirit of perl".
Someone please shine a light for me.
Hank
------------------------------
Date: 13 Nov 1999 10:33:49 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: Help me 'Think Perl'
Message-Id: <kusr9hul82q.fsf@bottom.bu.edu>
"Hank Marquardt" <hmarq@interaccess.com> writes:
> For those who don't know the file, it's a text file with '&&' as
> record delimiters and \n as field delimiters with 3 fields in each
> record; Date/Time, Title and URL for the story.
#!/usr/local/bin/perl -nw
# usage: slash.pl <slashfiles>
use strict;
chomp(my ($date,$title,$url) = split(/&&/));
#then whatever..
print "$date,$title,$url\n";
__END__
The -n switch causes looping over all lines of the input files,
which are specified as command line arguments. The -w switch
gives warnings and should always be used. The 'use strict'
forces you to use the 'my' on the next line, but in general
helps catch errors, so it should always be used as well.
'my ($date,$title,$url)' declare three so-called "lexical"
variables, which means they're in scope for this program
block. 'split(/&&/)' -- split() can take two arguments, but
if the second is missing, it splits on $_, which in this
case is each line as it's grabbed from the input file.
The pattern '/&&/' matches two ampersands, as you might've
guessed. The result of the split is an array, which is
assigned to the three variables. The chomp() is a bit
sloppy, as when given a list, chomp removes the newline
from the end of each element of the list, but in this case
there is only a newline on the last element ($url); the
way I used it arguably makes the code harder to read as well;
you could just put 'chomp $url' on the next line.
> I just keep thinking "there has to be an easier way". Heck I can
> code the brute force look for the delimiter stuff, but that doesn't
> seem to be "the spirit of perl".
There are many good books, in particular "The Perl Cookbook",
which will show you alot of the Perl idioms and tricks. Then, as you
know, it just takes time to get used to it.
--
qualification: I'm a dimwit according to someone who emailed me
------------------------------
Date: 13 Nov 1999 15:37:35 GMT
From: simon@brecon.co.uk (Simon Cozens)
Subject: Re: Help me 'Think Perl'
Message-Id: <slrn82r1dv.p54.simon@othersideofthe.earth.li>
Hank Marquardt (comp.lang.perl.misc):
>I'm pretty new to perl, but did a fair amount of C code once upon a time;
>and that's my problem I keep thinking in C, knowing somewhere somehow it's
>what I'm trying to do is real easy if I were thinking perl.
Yep; it's very, very refreshing to see a C programmer realise that Perl
is a different language and calls for a different style of thought.
(Note to C programmers everywhere: Don't just `use POSIX' and hack it
until it compiles) It's a pleasure to help you.
>easier. For those who don't know the file, it's a text file with '&&' as
>record delimiters and \n as field delimiters with 3 fields in each record;
>Date/Time, Title and URL for the story.
>
>should work? I guess I'm confused by the delimiter choices; split seems to
>expect \n as a record delimiter, not a field delimiter and similarly if I
>use file operations, I'm back to a if/switch statement looking for the '&&'
>delimiter.
Right. How do you, as a human being, see the problem? Here's the
way I approach it:
When I look at the file, I chunk it, in my brain. I look at the bits
between the &&'s. If you like, in my mind, I read a record at a time,
where a record is separated by &&'s. Let's do that in Perl, too.
Remember that $/ sets the input record separator.
-----
$/="&&";
while(<>) {
-----
Then, when I'm reading it, I split the record up into lines, and
read from each line the time, the title and the url.
-----
($time, $title, $url) = split /\n/;
}
-----
And that's it. Really, really easy, eh?
Moral: The way you program Perl should reflect the way you naturally
think about accomplishing a task as a human being.
2nd Moral: It's probably easier than you think.
--
Unix is the worst operating system; except for all others.
-- Berry Kercheval
------------------------------
Date: 13 Nov 1999 15:46:42 GMT
From: simon@brecon.co.uk (Simon Cozens)
Subject: Re: Help me 'Think Perl'
Message-Id: <slrn82r1v2.p54.simon@othersideofthe.earth.li>
Scott Lanning (comp.lang.perl.misc):
>"Hank Marquardt" <hmarq@interaccess.com> writes:
>> For those who don't know the file, it's a text file with '&&' as
>> record delimiters and \n as field delimiters with 3 fields in each
>> record; Date/Time, Title and URL for the story.
>
>#!/usr/local/bin/perl -nw
># usage: slash.pl <slashfiles>
>
>use strict;
>chomp(my ($date,$title,$url) = split(/&&/));
Good thinking, but wrong way around: && is not fields, it is records.
\n is not records, it is fields.
--
You are in a maze of little twisting passages, all alike.
------------------------------
Date: Sat, 13 Nov 1999 07:42:38 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Help me 'Think Perl'
Message-Id: <MPG.129726cae32c9c6f98a1f1@nntp.hpl.hp.com>
In article <s2qs189jhsq45@corp.supernews.com> on Sat, 13 Nov 1999
08:03:41 -0600, Hank Marquardt <hmarq@interaccess.com> says...
> I'm pretty new to perl, but did a fair amount of C code once upon a time;
> and that's my problem I keep thinking in C, knowing somewhere somehow it's
> what I'm trying to do is real easy if I were thinking perl.
Right you are.
> Task: Get the slashdot headline file and format it on my web page. The
> output and CGI part I've got nailed, it's the file parsing that's got to be
> easier. For those who don't know the file, it's a text file with '&&' as
> record delimiters and \n as field delimiters with 3 fields in each record;
> Date/Time, Title and URL for the story.
>
> Getting the file isn't the problem, I can ftp it, or I can slurp it into
> memory with LWP::Simple - Get. But then what? The 'C' guy in me goes into
> 'char' mode and wants to look for the delimiters, yet I know something like
> 'split' or a regex should make something like
>
> ($myDate, $myTitle, $myURL) = split .... OR
> ($myDate, $myTitle, $myURL =~ /\n/\n/\n
>
> should work? I guess I'm confused by the delimiter choices; split seems to
> expect \n as a record delimiter, not a field delimiter and similarly if I
> use file operations, I'm back to a if/switch statement looking for the '&&'
> delimiter.
split() has no such expectations. It does what you ask it too, if you
ask politely enough.
If the content is in a string, you can split first on /&&/ to get an
array of strings, each of which you can then split on /\n/.
> I just keep thinking "there has to be an easier way". Heck I can code the
> brute force look for the delimiter stuff, but that doesn't seem to be "the
> spirit of perl".
The spirit of Perl (the language, not the processor) is that There's
More Than One Way To Do It.
If the content is in a file, you can set the input record separator $/
to '&&', the chomp() each record and split it on /\n/ as above.
> Someone please shine a light for me.
Shone, I hope.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 13 Nov 1999 08:45:25 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Help me 'Think Perl'
Message-Id: <MPG.1297357d2d746f0498a1f2@nntp.hpl.hp.com>
In article <slrn82r1dv.p54.simon@othersideofthe.earth.li> on 13 Nov 1999
15:37:35 GMT, Simon Cozens <simon@brecon.co.uk> says...
...
> $/="&&";
> while(<>) {
...
> ($time, $title, $url) = split /\n/;
> }
> -----
>
> And that's it. Really, really easy, eh?
Yes, but you forgot to chomp the '&&' from the record or from $url.
And it's best to put the whole read loop into a block in which you
localize $/, instead of making a change that affects the rest of the
program also.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 13 Nov 1999 05:22:43 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help needed please, simple hash slice question!
Message-Id: <slrn82qevj.2kq.tadmc@magna.metronet.com>
On Sat, 13 Nov 1999 02:56:18 GMT, Max <mholland@bestweb.net> wrote:
>#Why doesn't my slice subset include the keys 'red' and 'green'
>#with their corresponding values? All I get are their values.
>
>%hash=('blue',10,'red',20,'green',5);
>%hashslice=@hash{'red','green'};
@hashslice{'red', 'green'}=@hash{'red','green'};
keys on the LHS, values on the RHS.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 13 Nov 1999 14:44:12 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: How can I determine different "use" statements?
Message-Id: <80jtfs$jng$1@pegasus.csx.cam.ac.uk>
David Kernen <david.kernen@bms.com> wrote:
>Your problem requires that you use require instead of using use.
>
>Eg:
>if(condition){
> require 'module1.pm';
> require 'module2.pm';
>}else{
> require 'module3.pm';
> require 'module4.pm';
>}
>
>Of course there are implications when using require instead of use.
>First, require doesn't like double colons, and it won't assume the .pm.
>So if your module has '::' in it you need to replace it with the
>separator character (i.e. a forward slash). And of course you'll need
>to include the ".pm" part of the module name regardless.
No need for all that. Just use the correct form of require:
if(condition){
require module1;
require module2;
}else{
require module;
require module;
}
See perlfaq8: "What's the difference between require and use?" and in
particular items (3) and (4).
Mike Guy
------------------------------
Date: Sat, 13 Nov 1999 09:45:34 -0800
From: hookman <hookman@cwnet.com>
To: "M.J.T. Guy" <mjtg@cus.cam.ac.uk>
Subject: Re: How can I determine different "use" statements?
Message-Id: <382DBFDE.6A3429BA@cwnet.com>
I use this:
sub BEGIN {
if(condition){
use 'module1.pm';
use 'module2.pm';
}else{
use 'module3.pm';
use 'module4.pm';
}
}
BEGIN gets called when the script first starts...
"M.J.T. Guy" wrote:
>
> David Kernen <david.kernen@bms.com> wrote:
> >Your problem requires that you use require instead of using use.
> >
> >Eg:
> >if(condition){
> > require 'module1.pm';
> > require 'module2.pm';
> >}else{
> > require 'module3.pm';
> > require 'module4.pm';
> >}
> >
> >Of course there are implications when using require instead of use.
> >First, require doesn't like double colons, and it won't assume the .pm.
> >So if your module has '::' in it you need to replace it with the
> >separator character (i.e. a forward slash). And of course you'll need
> >to include the ".pm" part of the module name regardless.
>
> No need for all that. Just use the correct form of require:
>
> if(condition){
> require module1;
> require module2;
> }else{
> require module;
> require module;
> }
>
> See perlfaq8: "What's the difference between require and use?" and in
> particular items (3) and (4).
>
> Mike Guy
------------------------------
Date: 13 Nov 1999 06:15:15 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: How can I vist a number of websites and email addys
Message-Id: <m13duamqa4.fsf@halfdome.holdit.com>
>>>>> "tony" == tony 123 <tony_123@my-deja.com> writes:
tony> Hi Bill
tony> Thanks for the reply. You don't know anything which is at a higher
tony> level than sockets for doing this that is already built?
Go away. Shoo. Get lost.
What you're doing is considered *evil* by most sane people.
So you won't get help from the sane people in this group.
--
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!
------------------------------
Date: Sat, 13 Nov 1999 05:28:37 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How can I vist a number of websites and email addys
Message-Id: <slrn82qfal.2kq.tadmc@magna.metronet.com>
On Sat, 13 Nov 1999 02:51:08 GMT, tony_123@my-deja.com
<tony_123@my-deja.com> wrote:
>How can I write a script that given a web site address, will go to that
>site and extract all email addresses from that page. I want to know
>what modules would help in doing this, is there already a script out
>there that does this, those sort of things.
Most folks here won't want to help with email address harvesting
unless the request for help includes some description of how
what you want to do is not to help you send out spam.
Are you looking for addresses to spam?
The LWP modules can fetch web pages.
The HTML::Parser module can help with parsing HTML.
The Perl FAQ, part 9 has info on recognizing email addresses.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 13 Nov 1999 16:22:57 GMT
From: MetaWizard <microwizard@my-deja.com>
Subject: Let me look a Win32-script on Perl
Message-Id: <80k38v$ncq$1@nnrp1.deja.com>
Tell me were can I find a Win32-script on Perl.
I downloaded Win32::GUI but cannot make with it nothing usefull!
Give me something interesting and EASY TO INSTALL !
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 13 Nov 1999 18:37:48 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: looking for a developer . . .
Message-Id: <0eiX3.6323$YI2.275056@typ11.nn.bcandid.com>
In article <382CFD9F.96B3FC1@iinet.net.au>,
Daniel Barnett <vibrant@iinet.net.au> wrote:
>We have a digital product that we need to sell online. We are looking
>for a programmer that can integrate our credit card providers API's with
>somesort of shopping cart / download manager.
>
>Please e-mail for full details.
This is NOT A JOBS NEWSGROUP. Coprophagous mutant.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 13 Nov 1999 14:30:46 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Module File:Find problem
Message-Id: <80jsmm$j28$1@pegasus.csx.cam.ac.uk>
In article <3829FE62.FE027C25@mail.cor.epa.gov>,
David Cassell <cassell@mail.cor.epa.gov> wrote:
>Bin Zeng wrote:
>[snip]
>> find ( sub { print $File::Find::name, "\n"} , @d );
>>
>> This code works fine for regular directory. But if the directory
>> '/bin' is a symbolic link, (I mean when 'ls -l /bin', the result is
>> something like
>> lrwxrwxrwx 1 root root Jul 8 21:54 /bin -> ./usr/bin
>>
>> Then the code fails to work. What I mean by this is that the code
>> is supposed to print out the names of all the files in the directory
>> /bin. But if /bin is a linked directory, the output for the code is
>> just '/bin'.
>
>Umm, if you read the docs for File::Find you will see a specific
>note about symlinks. It says:
>
> "There is no way to make find or finddepth follow symlinks."
But a version of File::Find has been produced with an option to
follow symlinks. See
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1998-12/msg02063.html
It hasn't yet been included in any Perl release because of performance
problems. But hopefully they can be resolved.
Mike Guy
------------------------------
Date: Sat, 13 Nov 1999 05:34:12 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Need help understanding directory structure (NEWBIE)
Message-Id: <slrn82qfl4.2kq.tadmc@magna.metronet.com>
On Sat, 13 Nov 1999 05:23:56 GMT, Michael Fischer
<votemand@earthlink.net> wrote:
>David Cassell wrote:
>> Why, you ask? Because webservers can start your process in
>> any place they want to, which is quite often in some place
>> you never thought of. So an absolute path gets you to your
>> file, while the relative path may go nowhere fast [because
>> you're not starting in the directory you supposed].
>
>Ah ha!
>
>That answers a bunch of peculiar thingies. Why didn't I
>see this caveat in an FAQ? Or was I just getting bleary?
Because what directory a web server places you in has nothing
to do with Perl, it has to do with web servers.
Looking for info on web servers in the Perl FAQ is sub-optimal.
Looking in web/cgi/server FAQs for info on web servers is better.
:-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 13 Nov 1999 19:11:17 -0000
From: "Simon Brook" <no@spam.com>
Subject: Newbee needs some date functions . . .
Message-Id: <80kcm7$q3n$1@supernews.com>
Hi there,
Recently turned to PERL (2 weeks) for web programming and luving it. However
being an Microsoft programmer (sorry) I am used to there being a function
for everything - e.g. DateDiff() etc etc.
Trying to do various things with dates, namely work out someones age (like
Andrej) and some other slightly more complicated calculations . . . .
I found (to my delight) DateCalc.pm on my Win32 installation of PERL, and
these worked brilliantly (including the awesome decode_date!!) ;-) . . .
however my ISP (demon - UK) doesn't have these modules installed, and when I
tried to use date:datecalc, it told me that dynamic linking was not aloud on
the server.
Damn damn double damn. I usually work these things out eventually, and
thought that I could do a new Make (using the static switch?), but of course
I don't think I can do that from the ISPs server(unix - apache i think).
I thought my next action would be to try and find the code in these modules,
and make my own library, but have just become really stuck. Can anyone help?
I would REALLY like to use these function on the web, and don't think I have
the experience yet to write them myself. What can I do?
Cheers.
------------------------------
Date: Sat, 13 Nov 1999 17:20:46 GMT
From: "Andy (IL)" <akoszyk@flash.net>
Subject: Newbie: Background Sounds
Message-Id: <O5hX3.106$16.13398@news.flash.net>
This should be easy for you all!
What's the exact placement and syntax for inserting background sounds in
pages that are created "on the fly" using the 'print' method? It's
definitely not the same as for behind a straight HTML page. Trial and error
isn't getting the answer - I'm stymied.
Thanks!
--
Andy Koszyk
akoszyk@flash.net
------------------------------
Date: Sat, 13 Nov 1999 18:53:54 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Newbie: Background Sounds
Message-Id: <Pine.HPP.3.95a.991113184734.21249H-100000@hpplus01.cern.ch>
On Sat, 13 Nov 1999, Andy (IL) wrote:
> This should be easy for you all!
Yup, dead easy to see that it's got nothing to do with the Perl
language.
> What's the exact placement and syntax for inserting background sounds in
> pages that are created "on the fly" using the 'print' method?
Exactly the same as those that are written by hand, and equally
annoying, considering that my sound system is already doing something
nice at my behest.
> It's
> definitely not the same as for behind a straight HTML page.
What do you suppose gets sent over the wire from the server to the
client, then? Perl is good, but it isn't telepathic.
Maybe if you revealed your real problem, on the CGI authoring group,
there might be one or two people who aren't equally infuriated by
unwanted audio intrustions who'd be willing to help. Whatever it is,
you haven't said anything here that would help you, honestly.
[f'ups]
--
* Progress (n.): The process through which Usenet has evolved from
smart people in front of dumb terminals to dumb people in front of
smart terminals. -- obs@burnout.demon.co.uk
------------------------------
Date: Sat, 13 Nov 1999 10:13:19 -0800
From: Bill Moseley <moseley@best.com>
Subject: Re: Newbie: Background Sounds
Message-Id: <MPG.12974a1ede6a85af98986f@nntp1.ba.best.com>
Andy (IL) (akoszyk@flash.net) seems to say...
> What's the exact placement and syntax for inserting background sounds in
> pages that are created "on the fly" using the 'print' method? It's
> definitely not the same as for behind a straight HTML page. Trial and error
> isn't getting the answer - I'm stymied.
Perl's bgsound() method isn't going to be released until Perl 6.003,
which comes out Nov. 31st in beta.
I doubt that browsers can determine what's generating a page, be it perl
or straight HTML.
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Sat, 13 Nov 1999 18:43:08 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: output a binary file to browser from perl script
Message-Id: <0jiX3.6409$YI2.275921@typ11.nn.bcandid.com>
In article <slrn82q36c.1q2.efflandt@efflandt.xnet.com>,
David Efflandt <efflandt@xnet.com> wrote:
>On Fri, 12 Nov 1999 04:16:55 GMT, Kragen Sitaker <kragen@dnaco.net> wrote:
>>open() it, read() it in chunks, and print the results.
>
>Why in chunks? I have never had any trouble sending image files in
>continuous stream, so I don't see why it wouldn't work for any binaries:
>
>if (open(FILE,"$file")) {
> binmode FILE; # only needed for Win servers
> print <FILE>; # prints complete file
> close FILE;
>} else {
> # print error message including $! and exit
>}
This won't work well if $file is 200MB and you only have 32MB of
virtual memory -- or, more reasonably, if $file is 5MB, your virtual
memory is 64MB, and you have 20 people trying to download the file at
once.
Also, it chops the data up into one-line chunks; for some data this
will be very small. I'd use read() to read bigger chunks instead --
and then print each chunk before fetching the next one.
Also, it reads the whole file before beginning to send it, adding
unnecessary delay and probably actually reducing throughput.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 13 Nov 1999 11:24:12 -0500
From: Dave Bakhash <cadet@bu.edu>
Subject: parsing UNIX mail spool files
Message-Id: <cxj9042xsur.fsf@acs5.bu.edu>
Does Perl V have a good library for parsing UNIX mail spool files? What is it
called?
thanks,
dave
------------------------------
Date: Sat, 13 Nov 1999 15:27:05 GMT
From: yjmick@my-deja.com
Subject: Re: perl as first language?
Message-Id: <80k007$lek$1@nnrp1.deja.com>
Whoever says that perl is not a good first programming language is out
of their mind! No offense, but it's probably the easiest fully loaded
programming language on the block. I've always advocated learning
procedural languages first, and then moving upwards to OOP languages
later. Perl has the best of both worlds, you can do nearly anything
without involving yourself in the oop portions of perl. So, you start
with learning perl, and then move on from there.
The thing that I'm going to guess your having a problem with is
"thinking like a machine". It's unfortunate, but if you don't start
programming at a very young age it will be difficult to overcome this
obstacle. I have seen many do so, but the older you are, the harder it
is to do so. Keep at it, you'll get it... I guarantee it! (I started
programming when I was 7 on those old XT machines in BASIC... speaking
of bad first programming languages!) Perl makes this easier with it's
non typed variables, so that should help you out. Try getting a VERY
beginner oriented text book, oreilly series are GREAT (I mean GREAT
GREAT GREAT!) for people that have already learned C, or some other
programming language, but they don't really go into "hm... what is a
variable?", or other such questions. You will appreciate the oreily
books later when you are looking for compact information, but at first
choose a book that's "fluffy", it will help you really get into the
material.
Good Luck...
Shane.
In article <s2929r91hpc35@news.supernews.com>,
"todd" <thirdwaver@inxpress.net> wrote:
> I have been playing with perl off and on now for about 6 months. I
have not
> really accomplished anything useful but I have been supporting Oreily
and a
> few other publishers. One thing that I come across alot is the
sugestion
> that perl is not a great choice for a first language. If that is that
case
> what is a good first language. (shell scripting, sed, awk, java, M$
Visual
> xxx)?
>
> I am a sys admin type who is trying to learn to program mostly to
develop
> creative solutions for mundane daily tasks such as modigying DNS
databases
> and parsing syslogs. OS es that I use are primarily netware, NT,
DG-UX,
> Linux, and 98 in that order.
>
> If perl is not a bad place to start then maybe I should just keep
going. I
> already have a lot of time invested.
>
> todd
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 13 Nov 1999 11:27:51 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl Wizards
Message-Id: <x7wvrmxsoo.fsf@home.sysarch.com>
>>>>> "DC" == David Cassell <cassell@mail.cor.epa.gov> writes:
DC> But I don't consider myself a Perl wizard. Just a satisfied
DC> customer. Abigail, Larry, Uri, Damian... They're wizards.
since i am a wizard, POOFF! you are now a pythoner!
:-)
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 13 Nov 1999 18:16:03 GMT
From: rheoled@my-deja.com
Subject: Re: PostgreSQL help
Message-Id: <80k9t1$rlm$1@nnrp1.deja.com>
[My apologies to perl-mongers for this off-topic thread...]
Jack,
Check out
http://www.postgresql.org/docs/postgres/xplang19094.htm
It may describe how to do what you seek. (See DECLARE)
Note some folks may have to enable the language if that's not already
been done for you. You can determine that by running the
following command (replacing 'yourdb' with whatever yours is):
% psql -d yourdb -c "select * from pg_language"
lanname |lanispl|lanpltrusted|lanplcallfoid|lancompiler
--------+-------+------------+-------------+--------------
internal|f |f | 0|n/a
lisp |f |f | 0|/usr/ucb/liszt
C |f |f | 0|/bin/cc
sql |f |f | 0|postgres
plpgsql |t |t | 3323648|PL/pgSQL
(5 rows)
If PL/pgSQL is not in the table, you can enable it as follows
(assuming its installed in /usr/local/pgsql):
CREATE FUNCTION plpgsql_call_handler () RETURNS OPAQUE AS
'/usr/local/pgsql/lib/plpgsql.so' LANGUAGE 'C';
CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql'
HANDLER plpgsql_call_handler
LANCOMPILER 'PL/pgSQL';
It would give me warm open-src fuzzies to hear if this helps anyone.
Cheers.
In article <38061D58.42A3FA76@vocollect.com>,
"John P. Smith" <jsmith@vocollect.com> wrote:
>
>
> I know that I'm not asking a perl question, but I've noticed a lot of
> postgres users on this newsgroup and I don't think that there are any
> postgres newsgroups and their mailing lists were of no help. I'm just
> wondering if it is possible to create a function in postgres with
local
> variables. The create function that I'm trying to implement is as
> follows:
>
> CREATE FUNCTION newProblem(char(50), char(255){,...}) RETURNS int4
> AS '
> {somehow need to declare a couple of int4 variables}
> int4 PROBoid, SPRoid; <--maybe like this?
> PROBoid = INSERT INTO SPRProblem ({fields}) VALUES ($1,$2{,...});
> SPRoid = INSERT INTO SPRrecord (problemid) SELECT id FROM SPRProblem
> WHERE oid = PROBoid;
> SELECT SPRnum FROM SPRrecord WHERE oid = SPRoid; <-- this will
actually
> make it return the SPR
> ' LANGUAGE 'sql';
>
> Does anyone know how to do this? Thanks in advance.
>
> Jack Smith
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 13 Nov 1999 18:05:47 GMT
From: bluesrift@aol.com (BLUESRIFT)
Subject: return height and width of jpeg, gif accessed via url
Message-Id: <19991113130547.23495.00000783@ng-fv1.aol.com>
Elsewhere Faisal Nasim helpfully shared the following routine that returns the
height and width of a gif file along with "type" which could be used for
capturing errors resulting from a misnamed file. This works fine for gif images
that can be addressed via a path to a file on the same server. I am seeking
routine(s) that will return this type of information for either a gif or a jpeg
AND will work instead for files accessed via a url. I am aware of the
Image::Size module and of other more comprehensive utilities to accomplish this
but please trust me that I need a solution that requires only standard
distribution modules. I don't know if LWP is standard, but it is available and
could be useful?
Just in case I am using the wrong terminology, in the context of the routine
below, I want to be able to pass, for example,
"http://anydomain.com/images/afile.gif" or
"http://anydomain.com/images/afile.jpg" in place of "mygif.gif" and have
returned the width, height, and (confirming) file type. The routine(s) do not
need to be robust in the sense of exhaustive error checking on the actual type
of file passed. A simple confirmation that the file is actually a gif or jpeg
will suffice. Has anyone here accomplished what I desire and willing to share?
Thanks!
Rob Bell
bluesrift@aol.com
What Faisal Nasim shared:
( $width , $height , $type ) = gifsize ( "mygif.gif" );
sub gifsize {
local ($gif) = @_;
local ($w, $w2, $h, $h2, $gifwidth, $gifheight, $type) = ();
open (GIF, $gif);
read (GIF, $type, 3);
seek (GIF, 6, 0);
read (GIF, $w, 1);
read (GIF, $w2, 1);
$width = ord ($w) + ord ($w2) * 256; read (GIF, $h, 1) ;
read (GIF, $h2, 1); $height = ord ($h) + ord ($h2) * 256;
close (GIF);
return ( $width , $height, $type );
}
------------------------------
Date: Sat, 13 Nov 1999 17:40:12 -0000
From: Ben Osman <ben@smooth.co.uk>
Subject: searching flatfile with a hash
Message-Id: <MPG.1297b2d3c19bea83989680@news.btinternet.com>
hello all
I need to search a flatfile database for several queries and would like
help on the way this is most efficient. It is for a shopping cart
application.
I have built up a list of hashes with the product id + quantity.
each product takes up a hash with {id} and {quantity} keys.
The number of hashes within the array is available.
I need to check the ID for each product in the array in a datafile and
add extra key/value pairs to the corresponding hash, such as
title,price,link.
I am not sure on how to search for multiple items without doing multiple
passes. I can get it working using foreach with a while nested but this
is rather inefficient as it has to go through the data file for each
product.
the datafile is in pipe delimited the format-
id|name|category|link|price
I would include some of my code but am away from my normal computer
I am still learning perl and have fairly good knowledge of while and
foreach loops, but at the moment I am struggling to get my head round
this.
I would be grateful if someone could point me in the right direction on
how to approach this.
thanks in advance
Ben Osman
------------------------------
Date: Sat, 13 Nov 1999 18:50:23 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: searching flatfile with a hash
Message-Id: <PpiX3.6487$YI2.276675@typ11.nn.bcandid.com>
In article <MPG.1297b2d3c19bea83989680@news.btinternet.com>,
Ben Osman <ben@smooth.co.uk> wrote:
>I need to search a flatfile database for several queries and would like
>help on the way this is most efficient. It is for a shopping cart
>application.
Hmm, you really need to read
http://photo.net/wtr/thebook/databases-choosing.html. Don't worry --
it's a fun read, and it should leave you shaking your head, saying,
"Why did I ever do it that way?"
>I have built up a list of hashes with the product id + quantity.
>each product takes up a hash with {id} and {quantity} keys.
>The number of hashes within the array is available.
>
>I need to check the ID for each product in the array in a datafile and
>add extra key/value pairs to the corresponding hash, such as
>title,price,link.
>
>I am not sure on how to search for multiple items without doing multiple
>passes. I can get it working using foreach with a while nested but this
>is rather inefficient as it has to go through the data file for each
>product.
I don't understand. You mean you have a hash created by statements like
$allproductshash{$product_id}->{$quantity} = 'true'; ? Or
@edible_lingerie_hash{'id', 'quantity'} = ('xxx6969', 20); Or what?
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Sat, 13 Nov 1999 16:48:27 +0200
From: Re'em Bar <reembar@netvision.net.il>
Subject: sorting a Hash array?
Message-Id: <382D7A3B.81DC4345@netvision.net.il>
I have a Hash array containing numbers.
how can I sort the order of the elements of this hash according to the
value of those numbers (in descending order)?
--
Re'em
http://snark.co.il
------------------------------
Date: Sat, 13 Nov 1999 07:25:15 -0800
From: Bill Moseley <moseley@best.com>
Subject: Re: sorting a Hash array?
Message-Id: <MPG.129722b57a05fcd298986c@nntp1.ba.best.com>
Re'em Bar (reembar@netvision.net.il) seems to say...
> I have a Hash array containing numbers.
> how can I sort the order of the elements of this hash according to the
> value of those numbers (in descending order)?
By reading the FAQ:
perldoc perlfaq
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Sat, 13 Nov 1999 07:35:40 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: sorting a Hash array?
Message-Id: <MPG.12972529b592f17098a1f0@nntp.hpl.hp.com>
In article <382D7A3B.81DC4345@netvision.net.il> on Sat, 13 Nov 1999
16:48:27 +0200, Re'em Bar <reembar@netvision.net.il> says...
> I have a Hash array containing numbers.
> how can I sort the order of the elements of this hash according to the
> value of those numbers (in descending order)?
Would you believe that that is a Question that has been Asked before,
Frequently, in fact?
The answer is in perlfaq4: "How do I sort a hash (optionally by value
instead of key)?"
Amazing, wot?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 13 Nov 1999 07:53:47 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: sorting a Hash array?
Message-Id: <slrn82qnqr.2vr.tadmc@magna.metronet.com>
On Sat, 13 Nov 1999 16:48:27 +0200, Re'em Bar <reembar@netvision.net.il> wrote:
>how can I sort the order of the elements of this hash according to the
^^^^
^^^^
>value of those numbers (in descending order)?
I think the way described in the Perl FAQ is pretty good.
Why does that not work for your application?
perldoc -q sort
You are expected to check the Perl FAQ *before* posting
to the Perl newsgroup!
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 13 Nov 1999 17:57:09 GMT
From: tigra@sky.deep.ru
Subject: Re: Urgent: simple regexp question
Message-Id: <80k8pk$r4s$1@nnrp1.deja.com>
Thank you very much and my apologies for the "Urgent"
Sergey
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 13 Nov 1999 07:27:05 -0800
From: Bill Moseley <moseley@best.com>
Subject: Re: Users uploading pics to a website.
Message-Id: <MPG.12972325e795d69a98986d@nntp1.ba.best.com>
JACULBERTS (jaculberts@aol.com) seems to say...
> I am trying to create a way in which users could upload a photo or pic
> into my website. I was thinking of using just a form but it seems only
> text is being accepted. I would like to have a setup whereby a user clicks
> on a button and a screen comes up for them to ID the pic to be uploaded.
> The pic would then be uploaded to my website. Does anyone know of
> such a thing? Thanks.
Type at your local prompt the following:
perldoc CGI
It will tell you all you need to know to do such a thing.
Have fun.
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 1368
**************************************