[6757] in Perl-Users-Digest
Perl-Users Digest, Issue: 382 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 27 20:07:28 1997
Date: Sun, 27 Apr 97 17: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 Sun, 27 Apr 1997 Volume: 8 Number: 382
Today's topics:
### newbie - FAQs? Dwonload Perf for Win 95??? ### (TACloud)
Re: ### newbie - FAQs? Dwonload Perf for Win 95??? ### (Nathan V. Patwardhan)
BASH & CGI -- HTML call to BASH <jroemer@spiderpub.com>
Re: BASH & CGI -- HTML call to BASH <jroemer@spiderpub.com>
Re: BASH & CGI -- HTML call to BASH (Tad McClellan)
Color Matching (Alan Fraser)
Does "<<" only work with print (Reinoud van Leeuwen)
Re: Does "<<" only work with print <tchrist@mox.perl.com>
Re: Getting it back OUT again! (R.O. (Ted) Russ)
How do you delete from a CGI database? mchoi@webexpert.net
Interactive Perl Webpage (Henry Avatar Chan)
Loading hash from file colind@oanet.com
Re: Loading hash from file (David Alan Black)
Re: Loading hash from file (Tad McClellan)
MLDBM|Argh my brain is frying! (Blake Kritzberg)
Re: MLDBM|Argh my brain is frying! (David Alan Black)
Re: Notice to antispammers (Nathan V. Patwardhan)
Re: NT WEB SERVERS SUCK! (Neil Briscoe)
Re: Object IDs are bad (was: Ousterhout and Tcl lost th (Andrew Koenig)
Perl Win32: how to specify all drives (or multiple dire (Terry Carroll)
Re: Please Help: MSDOS EOF in binary file (Andrew M. Langmead)
Re: Replacing + (Chris Schleicher)
Re: Replacing + (etta )
Re: Substitute File Path For URL (Tad McClellan)
Re: Use Variable in Shell (Tad McClellan)
Re: What does "UNIX" stand for.. colind@oanet.com
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Apr 1997 20:15:58 GMT
From: tacloud@aol.com (TACloud)
Subject: ### newbie - FAQs? Dwonload Perf for Win 95??? ###
Message-Id: <19970427201400.QAA29347@ladder01.news.aol.com>
Where can I find a FAQ list for Perl?
Where can I download Perl 5.0 for Windows 95?
Thanks
------------------------------
Date: 27 Apr 1997 20:33:12 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: ### newbie - FAQs? Dwonload Perf for Win 95??? ###
Message-Id: <5k0d68$8ds@fridge-nf0.shore.net>
TACloud (tacloud@aol.com) wrote:
: Where can I find a FAQ list for Perl?
http://www.perl.com/FAQ -or- keep your eyes on this newsgroup - someone
posts it periodically. You might also check the http://www.dejanews.com
archives for comp.lang.perl.misc for FAQ, which should be successful.
: Where can I download Perl 5.0 for Windows 95?
http://www.activeware.com
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Sun, 27 Apr 1997 14:56:08 -0500
From: "J. Roemer" <jroemer@spiderpub.com>
Subject: BASH & CGI -- HTML call to BASH
Message-Id: <3363AF58.6737@spiderpub.com>
I'm looking for somebody who
can help me with a BASH/CGI question.
(If this isn't the appropriate newsgroup,
could you point me in the right direction?
Thanks!)
If you have a moment, i'd really appreciate it!
(Please don't be scared off by the length of this
post -- i'm just wordy is all =)
I have a question regarding using
the BASH shell for a cgi script. The hard
part has been done, which is the writing
of the shell script. The part i'm getting hung
up on is making a call to the shell script
from my html document. Anyway, i'm hoping
you can spare the time to take a look.
If not, I truly understand.
So, if you're so inclined, here's what's up:
I have a web site which holds the complete song
lyrics of Bob Dylan.
( http://fciav3.bsd.uchicago.edu/~jrr/tbob )
I wrote a script that allows the user to type in a
string and search the lyric archive for that
string. Pretty straight-forward grep-type stuff.
Anyway, I got this to work just fine as a BASH
shell script. I had the script prompt for a string.
It also outputs all the appropriate HTML code (which
is to be interpreted by the browser).
The problem:
As you can guess, i've never written a CGI program.
So, i'm having trouble figuring out how to make
the browser call the script and hand to the script
the search string; then have the browser
interpret the output of the script.
Note: I've been creating this search function on
my Linux box, which is NOT on a network. After
it's all ready to go, i'll upload it to a different
machine. So, when you see that the paths specified
in my code don't point to a cgi-bin, this is the
reason.
My questions:
1) How do you make the HTML document hand-off
the string variable to the bash script?
2) Does my MIME statement at the head of my
bash script look correct?
3) When I run this cgi program "as is", the browser
echos the actual code of the bash script. It
DOES NOT interpret the programs output.
(In fact, i'm quite sure that the program
isn't being executed at all when called by
the HTML file.)
4) Do I use a "POST" or "GET" call in the HTML
document?
Still with me??? Hope I haven't scared you off.
I've just typed a lot of stuff describing my problem.
However, i'm certain that the answer is a simple one
for somebody who has done this stuff.
Make no mistake, I would be *very* grateful if you
can help me. I'm really excited at the prospect
of implementing this search function.
Thanks a 1,000,000 for any help you can give.
Regards:
Jim Roemer
jroemer@spiderpub.com
PS Please respond to me via email as well as
posting here. Thanks!
~~~~~~~~~~~~~~~~~~~~~~
Begin BASH code
~~~~~~~~~~~~~~~~~~~~~~
#!/bin/bash
echo 'Content-type: text/html'
echo
# Is this the correct way to receive the string from the HTML doc?
# "SONGSEARCH" should be the string that Im searching for.
read SONGSEARCH
numofsongs=`grep -li $SONGSEARCH public_html/lyrics/*.html | wc -l`
### SNIP BASH SCRIPT###
if [ $numofsongs -gt 0 ]
then
cat search_hdr.txt
echo '<H2>Your search for ' \"$SONGSEARCH\" ' yielded '$numofsongs'
songs.</H2>'
echo '<BR>'
echo '<BR>'
for i in public_html/lyrics/*.html
do
songname=`grep -li $SONGSEARCH $i | cut -c 20-`
grep -ih $songname public_html/alpha/*.html
done
cat search_ftr.txt
### SNIP BASH SCRIPT###
fi
exit 0
~~~~~~~~~~~~~~~~~~~~~~
End BASH code
~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~
Begin HTML code
~~~~~~~~~~~~~~~~~~~~~~
### SNIP HTML FILE###
<FORM Method="get" Action="/home/jrr/april/findbob.cgi">
<CENTER>
<B>Search Function</B>
</CENTER>
<BR>
Enter your search string:
<CENTER><INPUT TYPE="text" Size=30 Name="SONGSEARCH">
</CENTER>
<BR>
<CENTER>
<INPUT TYPE=submit Size=40 VALUE="Search">
<INPUT TYPE=reset Size=40 VALUE="Reset">
</CENTER>
</FORM>
### SNIP HTML FILE###
~~~~~~~~~~~~~~~~~~~~~~
End HTML code
~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Sun, 27 Apr 1997 16:47:41 -0500
From: "J. Roemer" <jroemer@spiderpub.com>
Subject: Re: BASH & CGI -- HTML call to BASH
Message-Id: <3363C97D.3418@spiderpub.com>
I withdraw my post. Sorry -- didn't realize
the enormity of my faux pas by posting such
a question here.
Respectfully,
J. Roemer
------------------------------
Date: Sun, 27 Apr 1997 15:26:51 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: BASH & CGI -- HTML call to BASH
Message-Id: <bqc0k5.l32.ln@localhost>
J. Roemer (jroemer@spiderpub.com) wrote:
: I'm looking for somebody who
: can help me with a BASH/CGI question.
: (If this isn't the appropriate newsgroup,
: could you point me in the right direction?
: Thanks!)
This most certainly is not the appropriate newsgroup.
Can't imagine what led you to think it might be.
This is the Perl newsgroup.
Perl has no connection to CGI nor to bash.
Perl was widely used before the WWW was even invented...
There are several good pointers to CGI info in the Perl FAQ:
---------------------
=head2 Where can I learn about CGI or Web programming in Perl?
For modules, get the CGI or LWP modules from CPAN. For textbooks,
see the two especially dedicated to web stuff in the question on
books. For problems and questions related to the web, like "Why
do I get 500 Errors" or "Why doesn't it run from the browser right
when it runs fine on the command line", see these sources:
The Idiot's Guide to Solving Perl/CGI Problems, by Tom Christiansen
http://www.perl.com/perl/faq/idiots-guide.html
Frequently Asked Questions about CGI Programming, by Nick Kew
ftp://rtfm.mit.edu/pub/usenet/news.answers/www/cgi-faq
http://www3.pair.com/webthing/docs/cgi/faqs/cgifaq.shtml
Perl/CGI programming FAQ, by Shishir Gundavaram and Tom Christiansen
http://www.perl.com/perl/faq/perl-cgi-faq.html
The WWW Security FAQ, by Lincoln Stein
http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
World Wide Web FAQ, by Thomas Boutell
http://www.boutell.com/faq/
---------------------
Please ask CGI questions in the CGI newsgroup:
comp.infosystems.www.authoring.cgi
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Sun, 27 Apr 1997 14:53:21 -0400
From: a_fraser@one.net (Alan Fraser)
Subject: Color Matching
Message-Id: <a_fraser-2704971453210001@port-34-8.access.one.net>
Here's a script for testing colors for new pages. It will prompt you for
the background color to be used for the page and will then display all the
colors in text against it. You can then quickly determine which will be
most effective on your page and you won't have to play around with
hexadecimal codes to do it. To get the script, visit my home page below
and click the Source Code button.
--
Alan Fraser
Home Page: http://w3.one.net/~a_fraser/
E-mail: a_fraser@one.net
------------------------------
Date: Sun, 27 Apr 1997 21:04:07 GMT
From: reinoud@xs4all.nl (Reinoud van Leeuwen)
Subject: Does "<<" only work with print
Message-Id: <3364bdca.2081432@news.xs4all.nl>
When I try the following code:
print <<"EOF"
-- start of SQL code
use master
go
select name from sysdatabases
go
EOF
I get the lines between the two EOF codes printed on my screen, but
when I run:
system ("isql -Usa -P ") <<"EOF"
-- start of SQL code
use master
go
select name from sysdatabases
go
EOF
I get lots of error messages. Even the line
system ("isql -Usa -P << \"EOF\"")
does not work....
Does this mean the << construction only works with the print
statement, or am I doing something wrong?
(system: NT 4.0, Perl 5.001 and Sybase 11.01 for isql)
__________________________________________________
Reinoud van Leeuwen reinoud@xs4all.nl
http://www.xs4all.nl/~reinoud
I specifically DO NOT give anyone permission to use my email adress
for any commercial or non commercial mailings. I will bill everyone
who sends me this kind of mail for wasting my time. Under Dutch law,
people who don't let me know they disagree with such a bill are obliged
to pay it.
Attention: remove extra anti-spam info at end of reply adress
------------------------------
Date: 27 Apr 1997 21:44:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Does "<<" only work with print
Message-Id: <5k0hb9$6co$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, reinoud@xs4all.nl writes:
:Does this mean the << construction only works with the print
:statement, or am I doing something wrong?
The << token is a mechanism for quoting, and HAS NOTHING
WHATSOEVER TO DO WITH I/O REDIRECTION. Watch
fn(3, <<'EO_1', "fred", <<"EO_2", stuff);
i do not expand
my $10.00 here.
EO_1
but here we will expand $ENV{HOME} variables
and the like.
EO_2
sub fn {
for ($i = 0; $i < @_; $i++) {
print "argument $i is ===$_[$i]===\n";
}
}
If you expect to pipe things to a command, use open
and feed it directly.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Let us be charitable, and call it a misleading feature :-)
--Larry Wall in <2609@jato.Jpl.Nasa.Gov>
------------------------------
Date: Sun, 27 Apr 1997 15:50:36 GMT
From: ted@faroc.com.au (R.O. (Ted) Russ)
Subject: Re: Getting it back OUT again!
Message-Id: <5k007r$4h3$1@demeter.omen.com.au>
Thanks Chip and Andrew - eyes are opening here, I'll be playing with
this in the morning - luvverly, thanks!
--
Teddles
_______________________________________________________
*** *** *** Intelligent Internet Services
* * * * Support: 0417 919 912
* * * Data: 61+ 09 445 7979
* * *
* * * * $30/month flat rate
*** *** *** $165 saver rate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Also visit:/ FAROC ENTERPRISES, http://www.faroc.com.au/~fe /
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HELP STOP THE TELSTRA INTERNET GRAB!
WRITE TO YOUR LOCAL MEMBER!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Sun, 27 Apr 1997 14:21:06 -0600
From: mchoi@webexpert.net
Subject: How do you delete from a CGI database?
Message-Id: <862168530.21404@dejanews.com>
I have written a simple database that would let users add links to a list.
I am trying to get the CGI script, written in perl, to delete and modify
records as needed.
I use splice(@database, $i, 1) in a "for" loop to delete. However, it
doesn't seem to delete the noted record.
Please E-Mail me any help that you can give. I will give you more
information about the script if needed.
Thank you very much.
Michael
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 27 Apr 1997 23:31:06 GMT
From: q8e192@ugrad.cs.ubc.ca (Henry Avatar Chan)
Subject: Interactive Perl Webpage
Message-Id: <5k0njq$3h0$1@nnrp.cs.ubc.ca>
Hi,
I have just written an Interactive Perl Webpage for beginners to
learn Perl.
This Java Applet allows a user to write Perl code and submit it
through the web
The URL is:
http://www.cs.ubc.ca/spider/hchan/Perl/intro.html
and the applets can be found by
doing a FIND on subsequent searches on QUIZ
Any feedback is appreciated.
Regards
Henry
q8e192@ugrad.cs.ubc.ca
------------------------------
Date: Sun, 27 Apr 1997 20:16:49 GMT
From: colind@oanet.com
Subject: Loading hash from file
Message-Id: <5k08v1$k9a@pulp.ucs.ualberta.ca>
I have a script that runs a loop which writes a hash to file. I would
like to expand my script to have a few more capabilities but to do
this, I have to load the file into a seperate associative array for
every line.
I know that to load into an array you would go:
@array = <FILE>;
but I would like to load every line of the file into a seperate hash.
Right now, each line of the file looks something like this...
m1whatever, m2whatever, m3whatever... m18whatever (where
m1..m18 are the keys of the hash that was written).
What is the most efficient (or any) way to do this?
Reply by email is appreciated.
Thanks in advance,
Colin
colind@oanet.com
------------------------------
Date: 27 Apr 1997 21:44:04 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: Loading hash from file
Message-Id: <5k0hb4$4ok@pirate.shu.edu>
Hello -
colind@oanet.com writes:
>I have a script that runs a loop which writes a hash to file. I would
>like to expand my script to have a few more capabilities but to do
>this, I have to load the file into a seperate associative array for
>every line.
>I know that to load into an array you would go:
>@array = <FILE>;
>but I would like to load every line of the file into a seperate hash.
>Right now, each line of the file looks something like this...
>m1whatever, m2whatever, m3whatever... m18whatever (where
>m1..m18 are the keys of the hash that was written).
>What is the most efficient (or any) way to do this?
^^^^^^
Don't ask that around here. :-)
One way would be:
@hashes = map { {/(m\d+)([^,]+)/g} } <FILE>;
which will put a list of hash references into @hashes, which you
can then get at separately. You might have to modify the
regex - my example sticks very literally to the format you've
used ('m' followed by digit(s) as unique to keys, commas used
only to separate records).
David Black
dblack@icarus.shu.edu
------------------------------
Date: Sun, 27 Apr 1997 17:00:35 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Loading hash from file
Message-Id: <3ai0k5.ec2.ln@localhost>
colind@oanet.com wrote:
: I have a script that runs a loop which writes a hash to file. I would
: like to expand my script to have a few more capabilities but to do
: this, I have to load the file into a seperate associative array for
: every line.
: I know that to load into an array you would go:
: @array = <FILE>;
: but I would like to load every line of the file into a seperate hash.
: Right now, each line of the file looks something like this...
: m1whatever, m2whatever, m3whatever... m18whatever (where
: m1..m18 are the keys of the hash that was written).
I see the keys, but where are the values for the hash elements?
I'll just assume that all of the values are '1'.
: What is the most efficient (or any) way to do this?
----------------------
#! /usr/bin/perl -w
while (<>) {
push(@hash_names, 'hash'.$.); # save the names of the hashes
foreach $key (split /, /) {
${'hash'.$.}{$key} = 1; # store each key/value pair
}
}
foreach (@hash_names) { # for each hash
print "$_:\n";
foreach $k (sort keys %{$_}) { # show each key in this hash
print " $k\n";
}
}
----------------------
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 27 Apr 1997 22:36:36 GMT
From: kritzber@ucsub.Colorado.EDU (Blake Kritzberg)
Subject: MLDBM|Argh my brain is frying!
Message-Id: <5k0kdk$6ef@lace.colorado.edu>
Hello, all. I'm using MLDBM/GDBM for some pretty standard
database storage retrieval stuff (duh), and getting stuck
on the retrieval part.
Now, normally I write slightly better code than below. Really.
But as I said, my brain is not answering the phone.
The point is, each record's key is a number. The number
stores a bunch of keys, one of which is "status."
On the first round, I want to make status ACTIVE
or INACTIVE, depending on the dates stored in that record.
At the same time, I want build a hash from all
the ACTIVE records (%req) for further processing.
I'm getting a weird error ("gdbm store returned -1, errno 2, key
"CO6616" at /usr/local/lib/perl5/site_perl/MLDBM.pm line 92."),
but what's worse, I can't think of an intelligent way to do
this seemingly simple task.
I am also not clear whether with MDLBM, it's possible to
reach directly into the hash and yank out a value like
$active = $req{CO55515}{status}, which would save me a lot
of work. If it is, I'm not using the right approach.
----------------
#!/usr/local/bin/perl -w
use Fcntl;
use MLDBM qw(GDBM_File);
....
$dbm = tie my %pr, "MLDBM", "$db", "O_RD", 0640 or die $!;
while((my $k, my $v) = each (%pr)) {
while ((my $k1, my $v1) = each (%$v)) {
if ($k1 eq "openDate") {
my $toggleOpen = $v1 if ($mydate >= $thisdate);
}
if ($k1 eq "closeDate") {
my $toggleClose = $v1 if ($mydate <= $thisdate);
}
}
if ($toggleOpen && $toggleClose) {
$mystatus = "ACTIVE";
$reloop = "on";
} else {
$mystatus = "INACTIVE";
}
$tmp = $pr{$k};
$tmp->{status} = "$mystatus";
$pr{$k} = $tmp;
### stolen from T. Christianson's Ye Olde Data Cookbooke
if ($reloop eq "on") {
$num = $k;
$rec = {};
$req{$num} = $rec;
while ((my $k1,my $v1) = each (%$v)){
$rec->{$k1} = $v1;
}
}
}
untie(%pr);
-------------------------
Perhaps if I go out and drink a prodigious amount of beer,
the solution will become clear to me. But the likelihood
seems pretty small. Can you save me from oblivion, however
temporarily?
TIA,
Blake
--
________________________ ___________
LONDON - Former students at two British schools, judged
by government inspectors as failing their pupils, are ------------
suing [the schools] for their poor education. REUTERS B. Kritzberg
------------------------------
Date: 27 Apr 1997 23:01:25 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: MLDBM|Argh my brain is frying!
Message-Id: <5k0ls5$b48@pirate.shu.edu>
Hello -
kritzber@ucsub.Colorado.EDU (Blake Kritzberg) writes:
>Hello, all. I'm using MLDBM/GDBM for some pretty standard
>database storage retrieval stuff (duh), and getting stuck
>on the retrieval part.
>Now, normally I write slightly better code than below. Really.
>But as I said, my brain is not answering the phone.
I hope it's reading Usenet :-)
This is probably no more than .333 of an answer, but:
>while((my $k, my $v) = each (%pr)) {
> while ((my $k1, my $v1) = each (%$v)) {
> if ($k1 eq "openDate") {
> my $toggleOpen = $v1 if ($mydate >= $thisdate);
> }
> if ($k1 eq "closeDate") {
> my $toggleClose = $v1 if ($mydate <= $thisdate);
> }
> }
> if ($toggleOpen && $toggleClose) {
These variables have gone out of scope. My, my, my :-)
Usen Sie strict, bitte.
David Black
dblack@icarus.shu.edu
------------------------------
Date: 27 Apr 1997 20:29:35 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Notice to antispammers
Message-Id: <5k0cvf$8ds@fridge-nf0.shore.net>
William E. Hatch (hatch@cais2.cais.com) wrote:
: Does this guy have a life !!
Yes. Do you? You seem to have a real e-mail address, so that's a start. :-)
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 27 Apr 1997 20:07:32 GMT
From: neilb@zetnet.co.uk (Neil Briscoe)
Subject: Re: NT WEB SERVERS SUCK!
Message-Id: <memo.19970427210749.27421A@skep.compulink.co.uk.cix.co.uk>
In article <01bc533a$42673580$11464ccf@giorgio.superlink.net>,
giorgio@superlink.net (John) wrote:
>
> I am tring desperatly to have a form send my client mail containing the
> values
> of the form.
> Ok normally this is no big deal if the ISP is a UNIX server but it is NT
> with
> no STDIN or out. I need to make a .dll call or something. I don't know
> which
> or how to do this.
>
> This also wouldn't be a problem I can use the MAILTO action and
> Javascript,
> but
> again MS dicked me! Explorer fires off its mailtool.
>
> CAN ANYONE please help me with this problem......
>
Well, you don't need to make a dll call - you just need some kind of mail
server to talk to. I have code that would allow you to talk to a mail
server that existed either on your NT box or on some Unix server. Send
mail to neil@fourthnet.co.uk and I'll send you the code. Of course, you
need to know how to talk to the mail server - just use standard RFC82[12]
chat, and if you have a right, you can send your mail.
Regards
Neil
------------------------------
Date: Sun, 27 Apr 1997 18:46:49 GMT
From: ark@research.att.com (Andrew Koenig)
Subject: Re: Object IDs are bad (was: Ousterhout and Tcl lost the plot with latest paper)
Message-Id: <E9B862.Jry@research.att.com>
In article <5k02gh$jhj@lyra.csx.cam.ac.uk> Tony Finch <fanf@lspace.org> writes:
> In the tree example that you started with, what is wrong with just
> passing round the whole subtree so that it can be compared with as
> necessary? Any reasonable implementation will only be passing round a
> pointer so you lose nothing.
Because it will compare equal with any other subtree that happens to
have the same structure, which is not what I want.
--
--Andrew Koenig
ark@research.att.com
http://www.research.att.com/info/ark
------------------------------
Date: Sun, 27 Apr 1997 21:52:14 GMT
From: carroll@tjc.com (Terry Carroll)
Subject: Perl Win32: how to specify all drives (or multiple directories) to File::Find?
Message-Id: <3363c727.4717614@news.aimnet.com>
This is a Win32/Perl-specific question.
Is there any way, using Perl for Win32, to specify a directory to
File::Find to indicate all drives installed on a system?
Basically, I want to be able to search all my drives (C:, D:, E:, and F:)
for files meeting a specific criteria. Here's a simple example of what
I'm thinking of:
>#!/perl/bin/perl -w
>use File::Find;
>
>print "Here are the MIDI files\n";
>find(\&wanted, '/');
>
>sub wanted {
> if ((not -d $_) and
> ($File::Find::name =~ /.MID$/))
> {
> my $size = (stat($_))[7];
> print "$File::Find::name \t$size\n";
> }
>}
This is intended to list the names and filesizes of all *.MID files on my
system. However, it only looks at the current drive. Is there any way to
specify that File::Find should look at all drives in the system (sort of
like what the Windows 95 "Find File" dialog does if you specify "My
Computer")?
Alternatively, is there a way to pass multiple directories to File::Find?
I'd rather have the program search whatever drives are online, but I'd be
happy with hard-coding all four drives I have installed at present.
My ultimate goal is to write a program that will look over all the MIDI
files on any of my drives, find files that have the identical filesizes,
and identify them as possible duplicates. Later I will probably modify
this to actually compare candidates to see whether they are in fact
duplicates.
Thanks!
--
Terry Carroll | "Al Gore is doing for the federal government what
Santa Clara, CA | he did for the Macarena. He's removing all the
carroll@tjc.com | unnecessary steps."
Modell delenda est | - Bill Clinton, September 20, 1996
------------------------------
Date: Sun, 27 Apr 1997 20:48:10 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Please Help: MSDOS EOF in binary file
Message-Id: <E9BDsA.BIw@world.std.com>
lts@bjt.com (T L) writes:
>Is trying to strip out non-printable characters in MS-DOS binary
>files. When using Perl 5.0, while ( <> ) will stop once an crtl-Z is
>encounterred before the actual end of file is reached.
The binmode function will turn a filehandle from text mode to binary
mode. On an MS-DOS (or similar) system, that will change the line
ending characteristics and end-of-file determination.
Searching the perl documentation for "binary" should have lead you to
this function fairly easily.
Also, you might want to look at the read() function. Your scalars
might get awfully long before it comes to a newline.
>T L (lts x@y bjt.net)
>[Please remove x,y and pack the rest, thanks.]
I'm not going to take a stand on the "munge e-mail addreses to avoid
spammers" argument, but you might want to take a look at your
postings. If you want to munge your e-mail address, and upset the
people who want to reply to you via e-mail (maybe to tell you that
your question has a simple RTFM answer.) you might as well do it
correctly. You mangled your "Reply-To" header, and the signature in
your sig, but your "From" header is still correct.
I would bet that the spammers searching through Usenet for e-mail
addresses are looking at every header and the entire body of your
text. (or at least the headers and the sig portion of the article.)
Right now, you are pissing off people who might want to help, yet not
doing anything to hide from the people you want to hide from.
--
Andrew Langmead
------------------------------
Date: 27 Apr 1997 12:01:26 -0700
From: chrissch@cs.uoregon.edu (Chris Schleicher)
Subject: Re: Replacing +
Message-Id: <5k07q6$7lq@psychotix.cs.uoregon.edu>
In article <01bc532c$67e10d80$29c477ce@john>,
John D. Hamel <john@RevereMa.com> wrote:
>I'm trying to write me first perl program and can't get this line to work:
>
>$value=~s/+/ /g;
That's because + has special meaning in a regular expression. It allows you
to match patterns "one or more times". For example,
$value =~ /\w+/;
matches if $value contains one or more (consecutive) word characters. If
you want to match a literal +, you need to escape it as in
$value =~ s/\+/ /g;
which will probably do what you want. See the perl documentation on regular
expressions for further details.
> Also, please suggest another way of getting the data from the form. I
> can't get the -->param( ) stuff to work either!
Go directly to
http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
(or your favorite CPAN site) and get the latest version of CGI.pm and
read the documentation. The ->param() stuff isn't difficult. It can be
as easy as:
use CGI;
$query = new CGI;
$name = $query->param('name');
Use CGI.pm. It's your friend.
Hope this helps,
--Chris
--
Chris Schleicher Office: 541/346-3998
Univ of Oregon CIS GTF email: chrissch@cs.uoregon.edu
URL: http://www.cs.uoregon.edu/~chrissch/
------------------------------
Date: Sun, 27 Apr 1997 20:08:37 GMT
From: etta@x.com (etta )
Subject: Re: Replacing +
Message-Id: <3363b242.97585947@netnews.worldnet.att.net>
On 27 Apr 1997 16:59:08 GMT, "John D. Hamel" <john@RevereMa.com>
wrote:
>
>Please Help!
>
>I'm trying to write me first perl program and can't get this line to work:
>
>$value=~s/+/ /g;
I should be:
$value =~ s/\+/ /g;
+ has special meaning in perl so you have to use the \ slish to tell
perl that is a char + and not a plus sign.
>
>I'm trying to transfer the data from the form to the perl script.
>This line should get rid of the + signs.
>Please let me know what is wrong. Also, please suggest
>another way of getting the data from the form.
>I can't get the -->param( ) stuff to work either!
>
>
>This is what I'm using:
>
>@name_value_pairs=split('&',$ENV{'QUERY_STRING'});
>foreach $name_value_pair (@name_value_pairs)
> {
> ($name,$value)=split('=',$name_value_pair);
> $value=~s/+/ /g;
> $value=~s/%([0-9A-Fa-f][0-9A-Fa-f])/hex($1)/g;
> $form{$name}=$value;
> }
>
>thanks,
>john
>
>
------------------------------
Date: Sun, 27 Apr 1997 15:16:52 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Substitute File Path For URL
Message-Id: <k7c0k5.i22.ln@localhost>
Greg Hassan (gwhassan@prodigy.net) wrote:
: Steve Sloan wrote:
: >
: > I'm attempting to get a HTTP_REFERER file name and change it to the actual
: > file name needed for reading. I can hardcode the URL and the path, i.e.
: > 'http://www.longbow.com/" will always be the URL path, and the file path
: > (from my cgi bin directory) will always be "../html/"
: >
: > I'm trying to do this:
: >
: > $urlPath = "http://www.longbow.com/";
: > $filePath = "../html/";
: >
: > $fn = $ENV{'HTTP_REFERER'}; #returns "http://www.longbow.com/filename.html"
: > ($fn = $fn) =~ tr/$urlPath/$filePath/; #want to return
: > "../html/filename.html"
: >
: > Why is this not working?
: >
: > TIA to any and all.
: you would probably jsut want to do:
^^^^^^^^^
Did you leave out a 'not' from in between those two words? ;-)
If not, then _why_ would he want to do the below?
( I agree that he wants s/// rather than tr///, but I don't see why
he can't use the variable to hold his replacement text, nor why
you would want to obfuscate what is being done by escaping things
that do not need escaping, and choosing delimiters that make the
other escaping necesary...
)
: $fn =~ s/$urlPath/\.\.\/html\//;
^ ^
These are not needed, even _with_ the default delimiters. Why
backslash something that does not have any special meaning that
you want to escape?
Dots are not special in the replacement text (unless using 'e': s///e)
Rampant backslashitis. The treatment for this disease is to
use an alternate delimiter:
$fn =~ s#$urlPath#../html/#; # this sure is easy to read and understand
$fn =~ s/$urlPath/$filePath/; # works fine though...
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Sun, 27 Apr 1997 15:05:04 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Use Variable in Shell
Message-Id: <ghb0k5.712.ln@localhost>
Alessandro Forghieri (alf@orion.it) wrote:
: Alex `Taker` Pircher <pircher@informatik.tu-muenchen.de> writes:
: [...]
: > $ENV{"PERLVARIABLE"}=$thisisit;
: > ------------
: >
: > Then I want to use the Variable 'PERLVARIABLE' generated in the
: > Perl-Program. BUT if I do a 'set' in the shell-script I can't see
: > this Variable.
: > Anyone knows what I have to do, to use it in the shell-script?
: >
: In short: you can't. This has been beaten to death over the years in
^^^^^^^^^^^^^^^
: several newsgrouops - but especially comp.unix.shell.
...and in c.l.p.m.
This Question is Asked so Frequently that it has been included in
the Perl FAQ (part 8):
=head2 I {changed directory, modified my environment} in a perl script.
How come the change disappeared when I exited the script? How do I get
my changes to be visible?
: A child process cannot export to its parent's environment - period.
: Now it is my turn to ask a question: why try to do a half shell,
: half perl job?
: If the shell is not enough for your task, why not go perl all the way?
: Just my .03 ;)
As I'm sure Alex is a good 'net citizen, then he surely must have looked
for his question in the Perl FAQ before posting to the Perl newsgroup.
He must have missed that one when he did...
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Sun, 27 Apr 1997 20:22:26 GMT
From: colind@oanet.com
Subject: Re: What does "UNIX" stand for..
Message-Id: <5k099i$k9a@pulp.ucs.ualberta.ca>
I think UNIX started out as UNICS which stood for uniplexed computer
system or something like that. The people who worked on it did do it
more or less in their spare time after the MULTICS project they were
working on got it's funding taken away. MULTICS stood for Multiplexed
computer system... I think. I'm probably wrong but I think I read
that somewhere.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 382
*************************************