[7701] in Perl-Users-Digest
Perl-Users Digest, Issue: 1327 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 17 03:27:29 1997
Date: Mon, 17 Nov 97 00:00:39 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 17 Nov 1997 Volume: 8 Number: 1327
Today's topics:
Re: A wierd error: Premature end of script headers (brian d foy)
Re: Block comments in Perl? (brian d foy)
Re: Debugging CGI programs <webmaster@fccj.cc.fl.us>
Re: downloading a file using perl from lynx <mweber@atlas.de>
Re: Easily using databases - am I reinventing a wheel? <zenin@best.com>
Re: exclusive file rights (Steve)
Re: exclusive file rights (brian d foy)
Re: how do you execute external programs with perl <webmaster@fccj.cc.fl.us>
Re: Newbie Question (brian d foy)
Re: Opinions please (and maybe help) <mindmore@mindless.com>
Re: oraperl (John D Groenveld)
perl bug? <sysop@diamonds.com>
Re: perl bug? (brian d foy)
Re: perl bug? <phousto@cse.dnd.ca>
Re: perl bug? (brian d foy)
Re: PIPE question (brian d foy)
Re: PIPE tutorials (brian d foy)
Re: print "Location: my_html.html\n\n"; <sysop@diamonds.com>
Re: Tracking people leaving a website (brian d foy)
variable scope question (Scratchie)
Re: Why no case statement in Perl? (brian d foy)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 16 Nov 1997 23:20:25 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: A wierd error: Premature end of script headers
Message-Id: <comdog-ya02408000R1611972320250001@news.panix.com>
In article <If3fHJAv+5b0Ewhy@worsdall.demon.co.uk>, Mark Worsdall <jaydee@worsdall.demon.co.uk> wrote:
>In article <comdog-ya02408000R1611971900080001@news.panix.com>, brian d
>foy <comdog@computerdog.com> writes
>>In article <WbO5hbA1f2b0EwzD@worsdall.demon.co.uk>, Mark Worsdall
>><jaydee@worsdall.demon.co.uk> wrote:
>>
>>>What can cause this error? The script still seems to run, the error is
>>>reported in the webservers error_log file.
>>
>>see the various FAQs referenced in the CGI Meta FAQ - especially the
>>Perl section.
>>
>Already read it still no help:-) can you point me more closely to the
>gaurded secret knowledge:-)
the Idiot's Guide to Solving Perl CGI Problems should lead you to
your error. if not, it leads you through all the information that
you will need to provide to enable (empower?) someone to help you.
we're not mind readers after all.
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 16 Nov 1997 23:13:46 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Block comments in Perl?
Message-Id: <comdog-ya02408000R1611972313460001@news.panix.com>
In article <eli$9711151424@qz.little-neck.ny.us>, Eli the Bearded <usenet-tag@qz.little-neck.ny.us> wrote:
>brian d foy <comdog@computerdog.com> wrote:
>> Eli the Bearded <usenet-tag@qz.little-neck.ny.us> wrote:
>> > It will bugger your $1, etc variables, but it won't clobber
>> > saved RE used for the m// blank RE context.
>$ perl5.00401 -we ' $a="NY.PM";
> $a=~/(\w*)(\W*)(\w*)/;
> print "$1 $2 $3 --";
> 1=~/(?#beat the dead horse)/;
> print "$1 $2 $3\n"
> '
>Use of uninitialized value at -e line 5.
this seems to be a reason not to make comments in this fashion, since
comments should not have side effects :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 16 Nov 1997 09:38:20 -0500
From: "Bill Jones" <webmaster@fccj.cc.fl.us>
Subject: Re: Debugging CGI programs
Message-Id: <346f063a.0@usenet.fccj.cc.fl.us>
Also, you may wish to try 'use diagnostics'
HTH,
Sneex :-)
Joseph N. Hall wrote in message <346D5023.A2215414@5sigma.com>...
>Navid S Kamali wrote:
>>
>> Hi I'm fairly new to Perl.
>> I was wondering how i can print the value of variable into standard
>> output instead of into a web page. My perl programs uses cgi.
>> I want to be able to do something like:
>> print $variable; (for debugging purposes)
>
>Get the CGI module (that's what it's called, and it's part of
>the 5.004 distribution) and learn to run your program from the command
>line. Also you might want to check out Lincoln's book.
>
> -joseph
------------------------------
Date: Mon, 17 Nov 1997 07:49:37 +0100
From: "Mathias-H. Weber" <mweber@atlas.de>
Subject: Re: downloading a file using perl from lynx
Message-Id: <346FE901.19F5ACF0@atlas.de>
SoniK wrote:
>
> for my website, i need to download many files, mostly over 1MB in size.
> i'm on a slow modem and so use my shell's speed to download most of
> them, which means opening lynx and copying the url over and waiting for
> it to download then save.. this is ok but not very efficient. what i
> would like to do is either have a little form on a page where i can put
> the url and send and the server will download or have a little line in
> the .cgi that users already send that would hopefully be as simple as '
> download http://blah.com/blah.exe ' so that the file will be all ready
> when i need it.
>
> i suppose if i do ' lynx http://etc.. ' from the .cgi it will load up
> lynx, but i dont think it would download, because usually i need to type
> 'd' to start downloading and then it probably would save it.
>
> anyhelp would be nice! -- please CC to my email
>
> --
Sorry, if I didn't totally understand what your problem is. If you are
looking for a tool that will download files if you feed it with the URL
from the command line, have a look at "wget":
----cite:
GNU Wget is a freely available network utility to retrieve files from
the World Wide Web using HTTP and FTP, the two most widely used
Internet protocols. It works non-interactively, thus enabling work in
the background, after having logged off.
The recursive retrieval of HTML pages, as well as FTP sites is
supported -- you can use Wget to make mirrors of archives and home
pages, or traverse the web like a WWW robot (Wget understands
/robots.txt).
...
The latest version is also available via FTP from the maintainer's
machine, at:
<URL:ftp://gnjilux.cc.fer.hr/pub/unix/util/wget/wget.tar.gz>.
This location is mirrored at:
<URL:ftp://sunsite.auc.dk/pub/infosystems/wget/> and
<URL:http://sunsite.auc.dk/ftp/pub/infosystems/wget/>.
Wget has its own mailing list at <wget@sunsite.auc.dk>. To subscribe,
Mail to <wget-request@sunsite.auc.dk> with the word `subscribe' in the
subject.
----end cite
Mathias
--
__________________________________________________________________
| Dr. Mathias-H. Weber --- mailto:mweber@atlas.de |
| STN ATLAS ELEKTRONIK GmbH {~@_@~} |
| Brueggeweg 54 / Dept ETS21 _( Y )_ Phone: +49 421 457 4401 |
| 28305 BREMEN (:_~*~_:) Fax : +49 421 457 3177 |
| Germany (_)-(_) Telex: 2 457 460 |
___________________________SIGSIG: Signature too long (core dumped)
------------------------------
Date: 17 Nov 1997 04:16:04 GMT
From: Zenin <zenin@best.com>
Subject: Re: Easily using databases - am I reinventing a wheel?
Message-Id: <879740323.452285@thrush.omix.com>
[ posted & mailed ]
Peter J. Schoenster <pschon@baste.magibox.net> wrote:
FYI, when sending a CC of a post to the author, it's polite
to mention this fact (as I do above) so that the author (me)
doesn't end up replying twice. -Once in email, then once in
Usenet. Thanks.
>snip<
: I do an "agrep" on a directory
: which contains the comments people left.
What is "agrep"? Egrep, fgrep, zgrep, these I know. Agrep?
: The file name for their
: commnet is the key in the dbm so I open the dbm and get their personal
: details to stick in the results.
Hmm...sounds shaky, but if it works hey, more power to ya. :)
: This is a major reason why I use text files when I need to search on
: text.
Well, there are ways to index the files into a database if you
_really_ want fast searches and/or your data size becomes large.
Greping through data will become slow vary quickly as your
data size grows.
: From all I have read there is no guarantee of real LOCKING.
Well, there is. It's just system dependent. Perl does a nice
job of masking most, but not all of these system dependences.
The use of .lock files however, is not the way to lock files
safely. When using DB_File (Berkeley DBM files), you can get
access to the real file descriptor and lock it safely. I think
DB v2.0 also has some more advanced features that might allow
row locking, but I'm not sure. -And I don't think the perl
DB_File module has them implemented yet...
: If the mSQL, for example, could guarantee
: that I could put the database on the web and thus be available to
: mulitple users at the same time and yet not corrupt the database and
: yet record all changes then that in itself is excellent.
I'm pretty sure it can guarantee not to corrupt a table when
multiple processes are trying to write to it. I don't think
it has column or row locking however, but it doesn't sound like
you would need them anyway.
: About the searching. I am used to find exactly what I want or close
: do it (where I choose how close I want to be). Can I do this with any
: other databases?
This _really_ depends on how you do your searches and what database
you're using. MiniSQL (if memory serves me) has regular expression
search capabilities for CHAR() columns that is actually pretty fast,
while others such as Oracle only allow simple "like" clauses that
are next to useless and slow as mud.
If you build a word index set, you can do massive searches vary
quickly, but it does limit what searches you can do. That is, it's
easy to find all documents that contain both "foo" and "bar", but
it's vary hard to tell if they are next to each other as simply "foo
bar".
: I have seen so many examples of forms which seem so
: limited. Is this the limitation of the programmer or the database I
: wonder.
Could be either or both. Like I said, when searching huge amounts
of data the "grep" method quickly shows that it can't scale, which
is where faster but less "exact" word index methods start getting
used.
: What do you use for databases?
Oracle, Informix, MiniSQL, DBM files, flat files, Unix file
structure. It _really_ depends on the job.
--
-Zenin
zenin@best.com
------------------------------
Date: Mon, 17 Nov 1997 06:51:38 GMT
From: syarbrou@ais.net (Steve)
Subject: Re: exclusive file rights
Message-Id: <346fe953.43127662@news.ais.net>
Unfortunately, I've done that. The perl information on the subject is
less than, shall we say, helpful. It might as well not even mentioned
it.
Steve
On Mon, 17 Nov 1997 03:09:17 GMT, jzawodn@wcnet.org (Jeremy D.
Zawodny) wrote:
>[original author automagically cc'd via e-mail]
>
>On Mon, 17 Nov 1997 01:20:02 GMT, syarbrou@ais.net (Steve) wrote:
>
>>from multiple writes and reads at once. How do you go about locking
>>access to the file so nothing else can access it while reading and
>>writing? The program does the following and I would like it locked
>>for the entire process(any other suggestions are welcom):
>
>This is covered in the Perl documentation. Search for the work 'lock'
>and you're bound to find it.
>
>Jeremy
------------------------------
Date: Mon, 17 Nov 1997 03:03:19 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: exclusive file rights
Message-Id: <comdog-ya02408000R1711970303190001@news.panix.com>
>>JeremyIn article <346fe953.43127662@news.ais.net>, syarbrou@ais.net (Steve) wrote:
>On Mon, 17 Nov 1997 03:09:17 GMT, jzawodn@wcnet.org (Jeremy D.
>Zawodny) wrote:
>>This is covered in the Perl documentation. Search for the work 'lock'
>>and you're bound to find it.
>Unfortunately, I've done that. The perl information on the subject is
>less than, shall we say, helpful. It might as well not even mentioned
>it.
well, perhaps you could explain on which part you are confused.
searching for lock seems to find all of the relevant info:
***************
dog[6] man perlfunc | grep lock
[snip]
flock FILEHANDLE,OPERATION
[snip]
***************
dog[7] perldoc -f flock
=item flock FILEHANDLE,OPERATION
Calls flock(2), or an emulation of it, on FILEHANDLE. Returns TRUE for
success, FALSE on failure. Produces a fatal error if used on a machine
that doesn't implement flock(2), fcntl(2) locking, or lockf(3). flock()
is Perl's portable file locking interface, although it locks only entire
files, not records.
[snip]
***************
dog[8] man perlfaq
[snip]
the perlfaq5 manpage: Files and Formats
I/O and the "f" issues: filehandles, flushing, formats
and footers.
[snip]
***************
then, looking in the perlfaq5 manual page, i find the answers to
these questions:
How can I lock a file?
What can't I just open(FH, ">file.lock")?
I still don't get locking. I just want to increment
the number in the file. How can I do this?
which seem to cover the situation pretty well. i'm not even going to
list all of the post to this newsgroup that deal with the subject.
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 16 Nov 1997 10:02:48 -0500
From: "Bill Jones" <webmaster@fccj.cc.fl.us>
Subject: Re: how do you execute external programs with perl
Message-Id: <346f0bf7.0@usenet.fccj.cc.fl.us>
I always liked this -
while (($acct, $pswd, $uid, $gid, $quota, $cmt, $gcos, $home, $shell) =
getpwent()) {
next if $acct ne $usrID;
$flag = 1;
print "<P>Requested User ID was Found! Continuing...";
print "<P>Permanently Changing the Password for $usrID... Please
wait...";
$z = "WebPass.expect $usrID $passwd $passNew";
$erc = system($z) / 256;
if ($erc) {
print "<P>ERROR! System Call to \'WebPass.expect\'
generated an error of type $erc!<P>Exiting...<P> ";
print "<P>You may want to report this to the <A
HREF=\"http://webbster.fccj.cc.fl.us/cgi-bin/mail?webmaster\"
onMouseOver=\"window.status='E-Mail the FCCJ Webmaster about this...';
return true\">FCCJ Webmaster</A>";
exit $erc;
} else {
print "<P> - Processing Completed...<BR>";
print "<P>If you have received an Error, you may want to report this to
the <A HREF=\"http://webbster.fccj.cc.fl.us/cgi-bin/mail?webmaster\"
onMouseOver=\"window.status='E-Mail the FCCJ Webmaster about this...';
return true\">FCCJ Webmaster</A>";
}
}
# The interesting part here is $z = "...";
# $erc = system($z) / 256;
# Always test for errors :-)
HTH,
Sneex :-)
Joseph N. Hall wrote in message <346D521C.C568C371@5sigma.com>...
>Mike Stok wrote:
>>
>> In article <346B1876.7B07@swansea.ac.uk>,
>> Dean Parratt <eeparrad@swansea.ac.uk> wrote:
>> >I am trying to execute a program or command which has arguments from a
>> >loop within a perl program so that the command will execute over and
>> >over again. I have tried exec and system but I can't make them execute
>> >my command. Can anybody tell me how to do this?
>>
>> Well system is probably what you want, could you post the code that fails
>> and any error diagnostics?
>
>I can see how exec probably isn't the right approach:
>
> for (;;) {
> exec 'echo please do this more than once'
> }
>
>heh.
>
> -joseph
------------------------------
Date: Sun, 16 Nov 1997 23:08:14 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Newbie Question
Message-Id: <comdog-ya02408000R1611972308140001@news.panix.com>
In article <346F6291.5CDE3D33@ix.netcom.com>, nyc-guy@ix.netcom.com wrote:
>I'm trying to format a number field that looks like 999,999,999.00
>and would like the output to strip out the commas and decimal
>places so it would look like : 999999999. BTW I'm using perl 5.
$number =~ tr/,//; #get rid of commas
$number =~ s/\..*//; #chop of the fractional part
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 17 Nov 1997 07:32:45 +0100
From: Nathan|Fain <mindmore@mindless.com>
To: andrewe@technologyXchange.com
Subject: Re: Opinions please (and maybe help)
Message-Id: <346FE50D.93899F31@mindless.com>
This is a multi-part message in MIME format.
--------------993D522D36441F3B0BD83227
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Wow.. the way you did your database is really cool. It looks a lot like the
URL parsing routine.
I still don't know how that will solve my problem (remember I'm new to perl
so I won't know a lot of things about CGI for awhile).
If it helps you can check out what I'm trying to do as far as printing to the
screen at http://www.edwil.com/catalog/ed11.html .
what you will find is Tables on Tables of products for that page in the
catalog (if you just go to www.edwil.com/catalog/ you will find a index of
all the pages in the catalog (the site is under construction)).
My problem is that on that page there a x# of cells in each table and in
another page in the catalog there are y# of cells in the tables.
I don't understand how what you explained will help me accomplish fixing that
problem.
Andrew Ellerton wrote:
> Nathan|Fain wrote:
> >
> > (the problems I see).
> > The problem is that every Product in the catalog has a differing number
> > of variables needed and is different in the way it is printed to the
> > browser.
> >
>
> OK.
>
> > As of now the only thing I know to do is to build a separate file for
> > each of the differing products of which will contain subroutines for
> > printing out the unique page for that product (the main script will
> > check to see what product it needs to print and then require the
> > appropriate subroutine file for the product and then runs those
> > subroutines).
>
> um, This is a little confusing!
OK, what I mean is something like this (please excuse me for the
syntaxerrors):
## the main CGI program
######################
if (FORM{'page'} eq 11) {
require "routinefile11.cgi";
}
if (FORM{'page'} eq 12) {
require "routinefile12.cgi";
}
if (FORM{'page'} eq 13) {
require "routinefile13.cgi";
}
&program;
# &program is coming from one of the required files (whichever one
# matches $page)
_________________________________________________
If you looked at one of the routinefile##.cgi files you would find the
subroutine &program which contains all the code for each of the Pages
of the Catalog and prints to the screen the format that the page needs.
But I am thinking of doing something else.
after examining the catalog I have found that the most cells in a table we
are going to need is 7 and the least is 5 so, what if in the datafile for
each line I first had my key values and then I setup up a string of variable
like: |table1|table2|......|table7| and then I could write something to
determine if $table7 is empty or not and then the program would know how many
cells to print out.
> > Is there any easier way to do this (remember... I'm a new comer to
> > Perl)?
>
> I have an alternative, but I'm not sure you'll find it easier.
>
> I have done something similar using a flat text file approach. I used
> the first few "columns" (where a column is separated by some characters,
> eg "::", as a key, and the remaining columns as name=value pairs. For
> example, a user with id "biotools", with password "excelsior", name
> "Andrew Ellerton" and phone number "+1 234 567" could be done like this:
>
> (file members_database)
> biotools::password=excelsior::name=Andrew Ellerton::phone=+1 234 567
>
> etc.
>
> The databases I used (at the site in my signature) use this approach.
> The useful thing is that you can add/remove fields as you like, except
> for the primary key in the first column.
>
> To get all the components you'd do something like
>
> %members = ();
>
> while (<MEMBER_DATABASE>) {
>
> chop; # remove trailing new line
> my ($id, @pair) = split /::/; #split parts
>
> foreach (@pair) {
> my ($key, $value) = split /=/;
> $members{$id}{$key} = $value;
> }
> }
>
> at the end of this loop, the value of $members{'biotools'}{'name'} is
> "Andrew Ellerton" etc.
>
> If you're new to Perl, as I was several months ago, I suggest you get
> Larry Wall's Programming Perl book, or the new Learning Perl book, and
> get stuck into it. You're not tackling a light problem, but its far from
> impossible too.
>
> I really don't like the sound of the way you were suggesting
> (subroutines and separate files?). Maybe I misunderstood you though.
>
> Oh, if you do go ahead with the text database thing, look into ways of
> locking files to prevent multiple accesses. *Very* important if there's
> even a chance of more than one person using the database at once.
>
> >
> > I'm having trouble getting the Newsgroup into Netscape 4.0 so if you
> > could, please send your reply to my e-mail ( mindmore@mindless.com ).
>
> Well, you posted fine. Make sure you nominate the correct mail server,
> then use the subscribe to newsgroups menu under the file menu (I think).
>
> Hope this is useful.
>
> Regards,
> Andrew
>
> --
> Andrew Ellerton andrewe@technologyXchange.com
> Software Engineer +61 8 9367 7006
> International Technology Exchange Fax +61 8 9367 7343
> Australia http://www.technologyXchange.com
>
> "Quotes attached to email messages are a last ditch attempt
> by the sender to express themself to the masses." -- AE
Thanks a Million.
- Nathan Fain
mindmore@mindless.com
--------------993D522D36441F3B0BD83227
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Nathan Fain
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Nathan Fain
n: Fain;Nathan
org: Gesher Labs
adr: 3412 Hawthorne Ave, Richmond Va. 23222 USA;;71 Shabtia Hanegbi (apt # 13);Jerusalem;;;ISrael
email;internet: mindmore@mindless.com
tel;home: 917.2.676.0960
x-mozilla-cpt: ;0
x-mozilla-html: TRUE
version: 2.1
end: vcard
--------------993D522D36441F3B0BD83227--
------------------------------
Date: 17 Nov 1997 00:49:30 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: oraperl
Message-Id: <64olta$6dj$1@tholian.cse.psu.edu>
DESCRIBE is not an Oracle function, but a SQL*Plus function. Query the
data dictionary instead.
John
groenvel@cse.psu.edu
------------------------------
Date: Sun, 16 Nov 1997 23:14:34 -0500
From: "Zisha Weinstock" <sysop@diamonds.com>
Subject: perl bug?
Message-Id: <346fc447.0@news1.ibm.net>
Try this:
#!/usr/bin/perl
sub FOO { print "foo!\n"; }
open FOO or die;
On my system (SCO OpenServer 5 perl version 5.003), this prints out "foo"
and then
dies. Why? Is it confusing a filehandle with a function call or is this by
design?
------------------------------
Date: Sun, 16 Nov 1997 23:53:34 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: perl bug?
Message-Id: <comdog-ya02408000R1611972353340001@news.panix.com>
In article <346fc447.0@news1.ibm.net>, "Zisha Weinstock" <sysop@diamonds.com> wrote:
>#!/usr/bin/perl
>sub FOO { print "foo!\n"; }
>
>open FOO or die;
>
>On my system (SCO OpenServer 5 perl version 5.003), this prints out "foo"
>and then
>dies. Why? Is it confusing a filehandle with a function call or is this by
>design?
perhaps you could explain what you are trying to do or why you would
use the same name for a subroutine and a filehandle.
perhaps you wanted to do something like
#!/usr/bin/perl
sub FOO { return "filename" }
open FOO, "$ARGV[0]" or die "$!\n";
while ( <filename> ) { print }
__END__
?
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 17 Nov 1997 04:51:14 GMT
From: Phil Houstoun <phousto@cse.dnd.ca>
Subject: Re: perl bug?
Message-Id: <346FCBB5.678E941A@cse.dnd.ca>
Zisha Weinstock wrote:
>
> Try this:
>
> #!/usr/bin/perl
> sub FOO { print "foo!\n"; }
>
> open FOO or die;
>
> On my system (SCO OpenServer 5 perl version 5.003), this prints out "foo"
> and then
> dies. Why? Is it confusing a filehandle with a function call or is this by
> design?
Yikes, it does the same on my Linux box. Guess we'd better avoid
using the same name for two distinct entities, eh?
------------------------------
Date: Mon, 17 Nov 1997 00:29:25 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: perl bug?
Message-Id: <comdog-ya02408000R1711970029250001@news.panix.com>
In article <346FCBB5.678E941A@cse.dnd.ca>, Phil Houstoun <phousto@cse.dnd.ca> wrote:
>Zisha Weinstock wrote:
>> #!/usr/bin/perl
>> sub FOO { print "foo!\n"; }
>>
>> open FOO or die;
>Yikes, it does the same on my Linux box. Guess we'd better avoid
>using the same name for two distinct entities, eh?
they aren't distinct entities. read what the perlfunc manpage has
to say about the first argument to open() to see what it is doing. :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 16 Nov 1997 23:29:28 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: PIPE question
Message-Id: <comdog-ya02408000R1611972329280001@news.panix.com>
In article <347101F3.46D8@ibm.net>, bradenb@ibm.net wrote:
>open (SEARCH, |$searchprog) || die;
don't you want some "'s with that?
open (SEARCH, "|$searchprog" );
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 16 Nov 1997 23:43:25 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: PIPE tutorials
Message-Id: <comdog-ya02408000R1611972343250001@news.panix.com>
In article <34710269.40A0@ibm.net>, bradenb@ibm.net wrote:
>Does anyone know of a comprehensive tutorial of using PIPE to
>communicate with external programs?
there's not much to it, especially if you use something like
IPC::Open3 which comes with documentation. :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 16 Nov 1997 23:04:29 -0500
From: "Zisha Weinstock" <sysop@diamonds.com>
Subject: Re: print "Location: my_html.html\n\n";
Message-Id: <346fc1e6.0@news1.ibm.net>
>print "Location: my_html.html\n\n";
Use the full URL including http:// and the server name.
------------------------------
Date: Sun, 16 Nov 1997 23:24:15 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Tracking people leaving a website
Message-Id: <comdog-ya02408000R1611972324150001@news.panix.com>
In article <64o1k9$fsk$1@daily.bbnplanet.com>, jgloudon@bbn.remove.com (Jason Gloudon) wrote:
>Peter Schoon (alex1@#nospam#.usa.net) wrote:
>: Does anybody know of the existence of a perl script that tracks users
>: leaving a webpage and where they are going ie.
>: http://www.whatever.com/redirect?url=www.yahoo.com
>Try ask a group like comp.unix.security about this, as it should not be
>possible.
what shouldn't be possible?
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
if you think that's bad, think about what the phone company knows...
------------------------------
Date: Sun, 16 Nov 1997 23:00:07 -0500
From: upsetter@ziplink.net (Scratchie)
Subject: variable scope question
Message-Id: <upsetter-1611972300070001@mfs-01-214.port.shore.net>
Greetings;
I'm looking for some Perl advice.
Here is a code fragment:
sub printTableNew {
my ($flag, $save_these, $total, %my_hash) = @_;
I wanted to do something like this:
my($sort_method);
if ($flag eq 'a') {
$sort_method = sub { ($a cmp $b) };
} else {
$sort_method = sub {
($my_hash{$b} <=> $my_hash{$a}) || ($a cmp $b)
};
}
foreach $key (sort &$sort_method keys %my_hash){
# do some processing here...
}
However, this failed... I believe that this is because the my(%my_hash) is
not visible to the anonymous subroutines referenced by $sort_method.
Correct?
I wound up doing what I wanted with something like this:
if ($flag eq 'a') {
@my_keys = sort keys %my_hash;
} else {
@my_keys = sort {
($my_hash{$b} <=> $my_hash{$a}) || ($a cmp $b);
} keys %my_hash;
}
foreach $key (@my_keys) {
# etc...
But I'm wondering if this is the best way to do it. It seems somewhat
inelegant to have to declare the additional @my_keys array.
I suppose that I could declare %my_hash as a local variable (rather than
"my") which would make it visible to the anon. subroutines, but I've
gotten the impression that the use of "local" is deprecated in Perl 5. Is
this correct? Is there a better (more efficient, more elegant) way of
providing multiple sort options on a "my" hash within a subroutine?
Thanks,
--Art
---------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.ziplink.net/~upsetter/ska/calendar.html
---------------------------------------------------------------------
------------------------------
Date: Sun, 16 Nov 1997 23:33:16 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Why no case statement in Perl?
Message-Id: <comdog-ya02408000R1611972333160001@news.panix.com>
In article <64o806$bvt@camel12.mindspring.com>, "Jim Scofield" <jscofield@mindspring.com> wrote:
>Jaime Metcher wrote in message <346F8A70.49349ADD@no.junk.mail>...
>>Phil R Lawrence wrote:
>>> SWITCH: {
>>> if (/^abc/) { $abc = 1; last SWITCH }
>>> if (/^def/) { $def = 1; last SWITCH }
>>> if (/^xyz/) { $xyz = 1; last SWITCH }
>>> $nothing = 1;
>>> }
>>Is this actually any different to:
>>
>> if (/^abc/) { $abc = 1; }
>> elsif (/^def/) { $def = 1; }
>> elsif (/^xyz/) { $xyz = 1; }
>> else { $nothing = 1; }
>>
>Actually, there is a difference here. In C and Perl, the right side if an
>if only gets executed if true. So, let's say that /^abc/ evaluates to
>true. In the top example, all three if statements will get evaluated. In
>the bottom example, the first will be true, which will set $abc = 1, and
>then skip the rest of the block.
how do you explain that
last SWITCH
statement in each if() block?
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
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 1327
**************************************