[8454] in Perl-Users-Digest
Perl-Users Digest, Issue: 2071 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 11 11:07:32 1998
Date: Wed, 11 Mar 98 08:00:57 -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 Wed, 11 Mar 1998 Volume: 8 Number: 2071
Today's topics:
Re: ? on http://www.perl.com/CPAN-local/doc/FMTEYEWTK/s <fp@pmpcs.com>
Re: ? on http://www.perl.com/CPAN-local/doc/FMTEYEWTK/s (Andrew M. Langmead)
Re: ? on http://www.perl.com/CPAN-local/doc/FMTEYEWTK/s (Andrew M. Langmead)
Re: array question (Hunter Johnson)
Re: Brand new and completely bewildered!!! <edwardj@webpromote.com>
Re: Brand new and completely bewildered!!! (Bjoern Guenzel)
Deeply nested functions in Perl <glew@cs.wisc.edu>
Detecting if STDIN has been redirected. <steveg_nospam@gcg.com>
Re: Detecting if STDIN has been redirected. <jdporter@min.net>
Re: Detecting if STDIN has been redirected. <steveg_nospam@gcg.com>
Re: difference between 's' and 'tr' <wd@uebemc.siemens.de>
Does anybody know how to do ftp in perl? <jast@ms.com>
Re: Does anybody know how to do ftp in perl? (Aaron B. Dossett)
Re: Does anybody know how to do ftp in perl? (Mike Stok)
Re: dumb question... <edwardj@webpromote.com>
Re: Extracting binary data <jdporter@min.net>
Re: FREE Auto-Generated Web Pages! With Full HTML Forma <webmaster@disconova.com>
HELP IN A PERL SCRIPT wsayegh@lynx.neu.edu
Re: HELP, can't get PERL script to work through web bro <barnett@houston.Geco-Prakla.slb.com>
Re: How to embed special characters in replacement stri (Vincent Fatica)
Re: interested question <jdporter@min.net>
Re: Is there a way to dynamically link subroutines? <oliver.schoenwald@fernuni-hagen.de>
m//x punctuation + comment oddity jnutting@rebisoft.com
Re: m//x punctuation + comment oddity <ajohnson@gpu.srv.ualberta.ca>
Re: multiple blank lines into one <dboorstein@shopcfn.com>
Re: Perl & Cookies: How do I delete once a person leave <webmaster@disconova.com>
Re: perl binary for SGI (I R A Aggie)
Re: Printing Hash of Hashes Problem <jdporter@min.net>
Re: Problem with "goto" in Perl <jdporter@min.net>
Re: Problem with "goto" in Perl <jdporter@min.net>
Re: Problem with "goto" in Perl <jdporter@min.net>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 11 Mar 1998 09:44:29 -0500
From: "Peter Perchansky" <fp@pmpcs.com>
Subject: Re: ? on http://www.perl.com/CPAN-local/doc/FMTEYEWTK/sort.html --- Sorting ?
Message-Id: <6e68lp$7q2$1@usenet46.supernews.com>
Greetings John:
John Porter wrote in message <350695F0.5C24@min.net>...
>Short answer: you need "\t" instead of '\t'.
>That is, double quotes instead of single quotes.
>It has to do with interpreting special characters, e.g. backslash,
>in the string.
Thank you for your reply. You are right about the new line split vs. push.
I tried the "\t" instead of '\t' and while it changed the results it is
still not sorted.
Prior to the change, it was
Sam Perchansky
Lori Perchansky
Marilyn Faughner
Peter Perchansky
After the change, it is
Peter Perchansky
Marilyn Faughner
Lori Perchansky
Sam Perchansky
Original data in the form of timestamp, time spelled out, name, etc. -- tab
delimited, new line record separated.
--
===========================================================
Peter Perchansky, Computer Consultant & Microsoft FrontPage MVP
Dynamic Net, Inc. DBA PMP Computer Solutions
Providing Dynamic Databases, Design, & Electronic Commerce Solutions
FrontPage Web Hosting at http://www.pmpcs.com/services/fpwebhosting.htm
FrontPage Support http://www.pmpcs.com/support/frontpage.htm
------------------------------
Date: Wed, 11 Mar 1998 14:51:17 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: ? on http://www.perl.com/CPAN-local/doc/FMTEYEWTK/sort.html --- Sorting ?
Message-Id: <Epnt9H.63I@world.std.com>
"Peter Perchansky" <fp@pmpcs.com> writes:
> my @newrefs = sort { $a->[1] <=> $b->[1] } @listrefs;
The operator "<=>" is for numeric comparisons. I think you want the
"cmp" operator instead. The term "'Sam' <=> 'Lori'" will always
evaluate that they are equal.
This type of error can be flagged by running perl with the "-w"
warning switch.
You also might want to look at the Sort::Fields module that covers up
a lot of the ugliness.
<URL:http://www.perl.com/CPAN-local/modules/by-module/Sort/
Sort-Fields-0.90.tar.gz>
--
Andrew Langmead
------------------------------
Date: Wed, 11 Mar 1998 15:33:41 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: ? on http://www.perl.com/CPAN-local/doc/FMTEYEWTK/sort.html --- Sorting ?
Message-Id: <Epnv86.BvC@world.std.com>
John Porter <jdporter@min.net> writes:
>Short answer: you need "\t" instead of '\t'.
That isn't the problem.
perl treats "split('\t', $_)" the same as "split(/\t/,$_)"
>That is, double quotes instead of single quotes.
>It has to do with interpreting special characters, e.g. backslash,
>in the string.
Actually, double quotes can be worse because then the variable gets
interpolated twice. (Once in the double quotes, and then again in the
match operator.)
Check the difference between these three:
$var = join '|', 'a' .. 'e';
print map { "$_\n" } split '\|', $var;
print map { "$_\n" } split /\|/, $var;
print map { "$_\n" } split "\|", $var;
--
Andrew Langmead
------------------------------
Date: 11 Mar 1998 14:06:15 GMT
From: jhunterj@lexis-nexis.com (Hunter Johnson)
Subject: Re: array question
Message-Id: <6e65on$qtf@mailgate.lexis-nexis.com>
[CCed to the original author.]
In article <6e4ei5$6up$1@nnrp1.dejanews.com>,
<mchunziker@us.fortis.com> wrote:
> I would like to scan the /dev directory for vg?? and stuff them into
> an array or scaler....no problem so far...easy enough....but I also
> want to create a new array based on a variable...in other words if I
> find vg00 I want to create a @vg00 array. Is there a way to create
> an array using a variable...I've been unable to figure out a way to
> do it without a bunch of if's and elsif's....I know something silly
> like @$VG= isn't going to get me very far! Thanks in advance....
So $VG contains "vg00" and you then want to create @vg00, right?
$VG = "vg00";
eval ("@" . $VG . " = (1, 2, 3);");
eval ("print @" . $VG . ";");
print "\n", @vg00, "\n";
outputs:
123
123
Hunter
--
J. Hunter Johnson | "A little consistent wholesome modeling and
jhunterj@lexis-nexis.com | costly servanthood are worth millions of
(937) 865-6800 x5385 | true words harshly spoken."
Lexis-Nexis, Dayton, OH | -- Ron Sider
------------------------------
Date: Wed, 11 Mar 1998 14:58:43 GMT
From: Ed Jamison <edwardj@webpromote.com>
To: Sarah Medway <sarah@shiver.demon.co.uk>
Subject: Re: Brand new and completely bewildered!!!
Message-Id: <3506A678.117BAE8A@webpromote.com>
Scrap the other books and go out and purchase "Learning Perl," from O'Reilly.
As I have said before, and as I am sure I will say again, there is not a better
book out there for learning Perl. I used a number of other Perl tutorial books
before someone I work with lent me a copy of Learning Perl. I learned more from
the first chapter than from any of the other books. Randall Schwartz and
company will not let you down...
HTH,
Edward Jamison
Sarah Medway wrote:
> Hello there
>
> I am a graphic designer relatively new to the wonders of the web. I have a
> few sites under my belt.
> But, however, I am completely brand new to Perl.
>
> I am doing a web site for a friend. She has a ftp download area for some
> demo programs (this is all set up and working). But she doesn't know who is
> downloading what! I have designed a form for her in Adobe Pagemill for
> people to fill in before they download her demos. The information in the
> form she wants emailed to her so she can build up a user database.
>
> I have bought 'Perl 5 for Dummies', 'The CGI/ Perl Cookbook' (which does
> have a script, but I don't understand how to configure it!) and 'Perl CGI
> Programming, no experience required'. All of them seem to go from ABC into
> rocket science in the space of one page.
>
> Am I being to ambitious to even contemplate doing this or is it a fairly
> straight forward task, or am I being extremely cheeky as it is a skill that
> takes years to master? I have no idea. However I would like to learn but
> feel I'm getting nowhere.
>
> Yours in anticipation
>
> Sarah
------------------------------
Date: Wed, 11 Mar 1998 15:35:05 GMT
From: guenzel.p1@usa.net (Bjoern Guenzel)
Subject: Re: Brand new and completely bewildered!!!
Message-Id: <889630276.14389.0.nnrp-01.c1ed20e5@news.demon.co.uk>
Eric Bohlman <ebohlman@netcom.com> wrote:
[...]
>: Even if you know Perl, you still have to learn CGI programming.
>: That alone is very difficult, since every machine has a different
>: way of handling it.
>Huh? CGI.pm makes those differences almost completely transparent to the
>programmer. And understanding the CGI interface is *not* that hard. If
>you can grasp the notion of statelessness, you're over the biggest
>hurdle. There's nothing particularly unusual about CGI programming.
I have downloaded several CGI-documentations and tutorials, but I
haven't come across 'statelessness'. What does it mean? Maybe then I
finally could make some sense of all this stuff :-)
I admit that I haven't got CGI.pm yet, I promise it's the next thing
I'll get.
Thanks!
Bjoern
------------------------------
Date: Wed, 11 Mar 1998 09:35:29 -0600
From: Andy Glew <glew@cs.wisc.edu>
Subject: Deeply nested functions in Perl
Message-Id: <3506AF41.4136C24@cs.wisc.edu>
A script based on a Perl module that I am writing
just started failing when I added "just one more level of indirection"
to my function/methood calling tree.
Inside the Perl debugger, I get told "More than 100 levels of subroutine nesting!"
or some similar message.
Well, yeah - maybe its a bit excessive, but it isn't a bug so far as I can tell.
Is this a limit of Perl - the amount of nesting?
(Respond by email to glew@cs.wisc.edu)
------------------------------
Date: Wed, 11 Mar 1998 08:33:32 -0600
From: Steve Goldstein <steveg_nospam@gcg.com>
Subject: Detecting if STDIN has been redirected.
Message-Id: <3506A0BC.41C6@gcg.com>
How do I detect if STDIN has been redirected within a Perl script?
A partial solution is to parse the command line for redirects, but
that's lame because the filehandle STDIN may have been reassigned
somewhere else (for example, in another script that calls this one).
The context of this question is in the following pseudo code:
///
if ( INTERACTIVE() )
{
ask for response;
}
///
sub INTERACTIVE
{
if (STDIN has been redirected to a file or a pipe)
return 0;
else
return TRUE;
}
------------------------------
Date: Wed, 11 Mar 1998 09:51:38 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Detecting if STDIN has been redirected.
Message-Id: <3506A4FA.655F@min.net>
Steve Goldstein wrote:
>
> How do I detect if STDIN has been redirected within a Perl script?
-t STDIN
> A partial solution is to parse the command line for redirects, but
> that's lame because the filehandle STDIN may have been reassigned
> somewhere else (for example, in another script that calls this one).
In fact, it's not just lame, but quite wrong.
> The context of this question is in the following pseudo code:
>
> if ( -t STDIN ) {
> issue prompt;
> }
>
> sub INTERACTIVE
> {
> if (STDIN has been redirected to a file or a pipe)
> return 0;
> else
> return TRUE;
> }
What?! Time to stop writing pascal and start writing perl.
hth,
John Porter
------------------------------
Date: Wed, 11 Mar 1998 08:52:15 -0600
From: Steve Goldstein <steveg_nospam@gcg.com>
Subject: Re: Detecting if STDIN has been redirected.
Message-Id: <3506A51F.167E@gcg.com>
OK, I'll be the first to flame.
Read the FAQ, you #@$$$!! .
In perlfaq8, you'll find "How do I find out if I'm running interactively
or not?"
Steve Goldstein wrote:
>
> How do I detect if STDIN has been redirected within a Perl script?
------------------------------
Date: 11 Mar 1998 13:47:31 GMT
From: Wolfgang Denk <wd@uebemc.siemens.de>
Subject: Re: difference between 's' and 'tr'
Message-Id: <6e64lj$hfa$1@galaxy.mchh.siemens.de>
Keywords: substitute translate
CHADM1@UConnVM.UConn.Edu (Carl David) writes:
>If in the perl program one write tr/a/A one gets uppercase translation, but if
>one writes:
>$a = 'a';
>$A = 'A';
>$b =~ tr/$a/$A/;
>well, to be honest, nothing happens.
Read the perlop man page:
Note that because the translation table is built at
compile time, neither the SEARCHLIST nor the
REPLACEMENTLIST are subjected to double quote
interpolation. That means that if you want to use
variables, you must use an eval():
Wolfgang Denk
Office: (+49)-89-722-27328, Fax -36703 Wolfgang.Denk@oen.siemens.de
Private: (+49)-89-95720-110, Fax -112 wd@denx.muc.de
I have a very small mind and must live with it. -- Edsger Dijkstra
------------------------------
Date: Wed, 11 Mar 1998 10:20:42 -0500
From: Peter Jastreboff <jast@ms.com>
Subject: Does anybody know how to do ftp in perl?
Message-Id: <3506ABCA.5DB5454A@ms.com>
Does anybody know how to do ftp in perl? Thanks.
------------------------------
Date: 11 Mar 1998 15:26:58 GMT
From: aarond@alpha.ewl.uky.edu (Aaron B. Dossett)
Subject: Re: Does anybody know how to do ftp in perl?
Message-Id: <6e6ag2$p3s$1@service3.uky.edu>
Peter Jastreboff (jast@ms.com) wrote:
> Does anybody know how to do ftp in perl? Thanks.
use Net::FTP;
--
Aaron B. Dossett | Finger aarond@london.cslab.uky.edu for PGP key
dossett@bigfoot.com|
Comp. Sci. Senior | http://www.ewl.uky.edu/~aarond
University of Kentucky 1996 NCAA Basketball Champions
------------------------------
Date: 11 Mar 1998 15:30:30 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Does anybody know how to do ftp in perl?
Message-Id: <6e6amm$8n2@news-central.tiac.net>
In article <3506ABCA.5DB5454A@ms.com>, Peter Jastreboff <jast@ms.com> wrote:
>Does anybody know how to do ftp in perl? Thanks.
You should look at the modules available on CPAN (the comprehensve perl
archive network) - the master ftp site is at ftp.funet.fi under
/pub/languages/perl/CPAN or you can point a browser at http://www.perl.com
and follow the CPAN links.
CPAN also contains the list of Frequently Asked Questions which may well
save you time and effort in the future.
The libnet bundle includes Net::FTP whose documentation starts like this:
NAME
Net::FTP - FTP Client class
SYNOPSIS
use Net::FTP;
$ftp = Net::FTP->new("some.host.name");
$ftp->login("anonymous","me@here.there");
$ftp->cwd("/pub");
$ftp->get("that.file");
$ftp->quit;
DESCRIPTION
Net::FTP is a class implementing a simple FTP client in
Perl as described in RFC959. It provides wrappers for a
subset of the RFC959 commands.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Wed, 11 Mar 1998 15:01:49 GMT
From: Ed Jamison <edwardj@webpromote.com>
To: ndufort <ndufort@cadre.sjsu.edu>
Subject: Re: dumb question...
Message-Id: <3506A732.B3F61513@webpromote.com>
Try this...
<A HREF="http://www.yoururlhere.com/cgi-bin/cgiscript.cgi">
Obviously, substitute in the appropriate location of your file before you
try this...
HTH,
Edward Jamison
ndufort wrote:
> hi everybody,
>
> i had psoted a first dumb question for a current art project using PERL,
> and i have a new one.
> i have been able to write the script i want, and it works (which made me
> pretty glad, since i don't know PERL at all). but now i would like to
> attach my script to one of the hyperlinks on the web page i did for the
> assignment (a regular text based page, nothing fancy) so when the user
> clicks on the link, he would run the script in the background without
> knowing about it (the cript is supposed to check the time and write it
> to a file. i have it to work, but i would like to have it activated
> when someone clicks on a link).
>
> how should i do this? sorry if my question is dumb, but i don't have
> enough time to learn PERL (it's just an art assignment using PERL)
>
> thank you
> --
> The young (who always want more and have no game to protect),
> the artists (who always hunger for the ecstatic moment),
> and the alienated (the wise slaves and noble minority groups watching
> from the periphery of the society). "High Priest," -- Timothy Leary
------------------------------
Date: Wed, 11 Mar 1998 08:59:02 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Extracting binary data
Message-Id: <350698A6.39C7@min.net>
Elf Sternberg wrote:
>
> In article <35058D2C.9138EAAA@columbia.edu>,
> Kaushal Shah <krs28@columbia.edu> wrote:
> ,
> > How would I go about extracting a binary file, specifically, gif
> >file. I want to extract the resolution which happen to be bytes 7 & 8
> >and 9 & 10. These bytes are in reverse order ie. I have to concatenate
> >bytes 8 then 7 and 10 & 9 to get width and height. how can I go about
> >extracting and concatenating the byes to get the resolution. I am
> >working with Perl 4. thanks.
>
> perldoc -f pack
> perldoc -f unpack
>
> sub gifsize {
But, of course, for this particular question, the answer is
Image::Size.
John Porter
------------------------------
Date: Wed, 11 Mar 1998 16:59:59 +0200
From: Markku Uttula <webmaster@disconova.com>
To: Mark Polakow <mark@imp.net>
Subject: Re: FREE Auto-Generated Web Pages! With Full HTML Formatting and online editing!
Message-Id: <3506A6EF.3A66@disconova.com>
To start with, this is not a group for commercial messages. Use some
other place to post this stuff.
To continue with, using HTML in your messages that many of us read with
text/plain-capable readers in usenet.
--
Markku Uttula | If I ever though yo would read this, I would
webmaster@disconova.com | have written something useful in here...
http://www.disconova.com/ | - Mickey Mouse
------------------------------
Date: Wed, 11 Mar 1998 09:24:33 -0600
From: wsayegh@lynx.neu.edu
Subject: HELP IN A PERL SCRIPT
Message-Id: <6e6a99$hmr$1@nnrp1.dejanews.com>
I am not a PERL professional, and I need the following help. How could I do
the following:
Store the first 140 characters of each line (line by line) in a variable, and
the rest of the characters (141+) in another variable. If the first character
in the variable is equal to X the do so else do that....
Please get back with your help
Thanks,
Waseem
wsayegh@lynx.neu.edu
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Wed, 11 Mar 1998 08:29:29 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
To: Sanghyun Lee <dragon@soback.kornet.nm.kr>
Subject: Re: HELP, can't get PERL script to work through web browser
Message-Id: <35069FC9.ED019485@houston.Geco-Prakla.slb.com>
Sanghyun Lee wrote:
>
> OK, I wrote a simple Perl script. I ran it on my ISP (UNIX) through Telnet.
Good start. Perl related topic.
> It appeared to work. Then I typed in the address of the script through my
> web-browser. It just printed the whole script out instead of running it!!
> What's wrong?
Oops. Fell of the deep end here.
The script runs when executed by perl, but not by your web server = This
is not a Perl related topic.
Check out the documentation for the web server. Contact your ISP. Ask
in a CGI related newsgroup, such as
comp.infosystems.www.authoring.cgi
They will be far better able to help you than we can regarding your web
server/cgi questions.
Once the web server is set up to run the script, come see us if you have
problems with the script itself. ie not giving the results you
expected, not getting a regular expression (RE) to work, etc.
> Also is there anyway to use C to write CGI scripts?
CGI scripts can be written in anything you like: shell scripting, perl,
C, C++, java(?), python, tcl(?), fortran
Perl is by far the most natural choice, but ....
> I tried C too but it
> just returns a 500 error...
Well, that could mean anything. What do your web server error logs have
to say? They are a great source of information. Again, not a perl
related issue here.
> Maybe you have to compile the thing under a UNIX
> compiler? Where do I get one of these if they are available??
If you want it to run on unix, it must be compiled on unix.
http://www.fsf.org
offers gcc/g++ which are C/C++ compilers. Have a look there.
>
> Please help me to get PERL CGI to work in web browser...
Please help yourself by contacting your ISP, reading your web server
documentation, and looking at the error logs generated by the web
server.
> Or better yet help me get C/C++ CGI to work...
> Or even better help me get both to work...
>
> Note: I am a complete beginner and know next to nothing about UNIX, CGI,
> PERL, etc. etc. etc.
>
Well, _Learning Perl_ by Randal Schwartz, published by O'Reilly &
Associates (httP://www.ora.com) is a great place to start learning Perl.
> PS. Please E-mail reply also...
>
Ok.
> Thanks
HTH.
Dave
--
"Security through obscurity is no security at all."
-comp.lang.perl.misc newsgroup posting
------------------------------------------------------------------------
* Dave Barnett U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------
------------------------------
Date: Wed, 11 Mar 1998 14:10:42 GMT
From: vefatica@syr.edu (Vincent Fatica)
Subject: Re: How to embed special characters in replacement string?
Message-Id: <350697f9.144463046@news.ican.net>
On 9 Mar 1998 18:15:24 GMT, lpoon@Glue.umd.edu (Leon Poon) wrote:
>How does one embed special characters like \n, \t, etc. in the
>replacement string and have it interpreted by perl? Recently, I
>wanted to replace some words in a file with a multiline replacement,
>but I don't know how to do it with perl regex.
>
>For example, I want
> blah[return]blah[return]blah[return]
>to be replaced by
> blah
> blah
> blah
It's not clear what you want to do above (replace "returns" [newlines] with
newlines?). If you remove the newlines, the result won't be "multiline".
$_ = "blah\nblah\nblah\n";
s/\n//g;
will turn the string into:
blahblahblah
while,
$_ = "blah blah blah";
s/ /\n/g;
will replace the spaces with newlines, and you'll get:
blah
blah
blah
In any case, there's no difficulty using "\n" is either string of s///.
- Vince
___
Vincent Fatica
Syracuse University Mathematics
vefatica@syr.edu
http://barnyard.syr.edu/~vefatica/
------------------------------
Date: Wed, 11 Mar 1998 09:15:42 -0500
From: John Porter <jdporter@min.net>
Subject: Re: interested question
Message-Id: <35069C8E.4ED9@min.net>
Matteo wrote:
>
> I have to produce an interactive CD-ROM on HTML language with research on a
> database.
> I think I can use a program which emulate a server and consider the browser
> as client.
>
> I think there is a program (netsddeserver) by Netscape which does this, but
> I'm not sure and I didn't find it on Netscape web site.
This is not a Perl question -- but I'd be glad to turn it into one.
Check out the CGI::MiniSvr module, which is part of the
CGI-modules distribution on CPAN.
John Porter
------------------------------
Date: Wed, 11 Mar 1998 16:17:23 +0000
From: Oliver Schoenwald <oliver.schoenwald@fernuni-hagen.de>
To: Gene A Brock <gbrock@isc.sjsu.edu>
Subject: Re: Is there a way to dynamically link subroutines?
Message-Id: <3506B913.FCB41CE3@fernuni-hagen.de>
Hello Gene,
Gene A Brock wrote:
> I am working on a program that loads in many Perl variables, and it
> would be great if I could include the data as a subroutine after
> saving it in Perl syntax. The problem is, I don't know the name of
> the file to require beforehand. I must ask the user, then load his
> /her data. So initially, I included a set temporary file, then copied
> the file that the user requested to that temporary file, and tried
> to require the copied file as a subroutine. It compiles, but I always
> get a run-time error "<STDIN> chunk 3." Is there any way to dynamically
> change code during run-time? If anyone could answer my question, I
> would greatly appreciate it.
Gene, I think you shouldn't "require" the file, as this will be loaded at
startup-time.
You should load the file during run-time into a scalar $var and make an eval
$var to run it.
Maybe this will work.
Oliver Schvnwald
------------------------------
Date: Wed, 11 Mar 1998 08:02:49 -0600
From: jnutting@rebisoft.com
Subject: m//x punctuation + comment oddity
Message-Id: <6e65fn$e86$1@nnrp1.dejanews.com>
Here's something odd. With the following program:
$testString = "bill=evil";
if ($testString =~
/\w+ # bill comment
=
\w+ # evil comment
/x) { print "case 1: Matched the =.\n"};
if ($testString =~
/\w+ # bill comment
= # comment of death
\w+ # evil comment
/x) { print "case 2: Matched the =.\n"};
I get this output:
1: Matched the =.
when I would expect it to output the third line as well. The only difference
between case 1 & 2 is the absence/presence of the "# comment of death".
Somehow in case 2, the presence of the comment prevents the pattern from
matching. I have seen the same effect with other single punctuation
characters too, such as ";". I can't see anything in the docs that describe
this behavior.
Any ideas why this happens? I'm running 5.001m on OpenStep 4.2
// Jack Nutting
// jnutting@rebisoft.com
// www.rebisoft.com
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Wed, 11 Mar 1998 09:08:54 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: m//x punctuation + comment oddity
Message-Id: <3506A906.2C892FD8@gpu.srv.ualberta.ca>
jnutting@rebisoft.com wrote:
!
! Here's something odd. With the following program:
!
! $testString = "bill=evil";
! if ($testString =~
! /\w+ # bill comment
! =
! \w+ # evil comment
! /x) { print "case 1: Matched the =.\n"};
! if ($testString =~
! /\w+ # bill comment
! = # comment of death
! \w+ # evil comment
! /x) { print "case 2: Matched the =.\n"};
! I get this output:
!
! 1: Matched the =.
!
! when I would expect it to output the third line as well. The
! only difference between case 1 & 2 is the absence/presence of the
! "# comment of death". Somehow in case 2, the presence of the
! comment prevents the pattern from matching. I have seen the same
! effect with other single punctuation characters too, such as ";".
! I can't see anything in the docs that describe this behavior.
!
! Any ideas why this happens? I'm running 5.001m on OpenStep 4.2
a cut/paste/run of your code here gives:
case 1: Matched the =.
case 2: Matched the =.
perl5.00404 and 5.003 on linux-2.0.29 --- maybe an upgrade is in order.
regards
andrew
------------------------------
Date: Wed, 11 Mar 1998 10:18:41 -0500
From: Dan Boorstein <dboorstein@shopcfn.com>
To: SenimotBor <tomines@rohan.sdsu.edu>
Subject: Re: multiple blank lines into one
Message-Id: <3506AB51.A295738D@shopcfn.com>
SenimotBor wrote:
> How do you substitute multiple consecutive blank lines for one blank line.
> I've tried the following but can't figure out what I'm doing wrong.
>
> s/(^$)+/^$/g
>
instead of thinking of the problem as blank lines, i would think of it
as consecutive newlines (i.e., \n). so, i would replace 3 or more
consecutive newlines with 2 newlines:
$multiline =~ s/\n{3,}/\n\n/g;
hth,
--
# dan boorstien <dboorstein@shopcfn.com>
seek DATA,0,0;print($_=<DATA>),__END__
Just another Perl hacker,
------------------------------
Date: Wed, 11 Mar 1998 17:11:07 +0200
From: Markku Uttula <webmaster@disconova.com>
Subject: Re: Perl & Cookies: How do I delete once a person leaves my site?
Message-Id: <3506A98B.14CA@disconova.com>
Chocolate wrote:
> Is it possible to delete a cookie once a person leaves my domain? If so
> how?
It would propably be a good idea for you to read about cookies from
somewhere.
a) Nope, it is not possible in the traditional way(*
b) why would you like to remove a _client-side_ cookie ?
c) if you don't state any value for the cookies lifetime, it is removed
from the giant cookie-jar as soon as the users surfing session is over -
so... this is the closest you get to removing them - except...
*) If you like to use JavaScript, you could make up a piece of code that
overwrites the cookie with nothing as soon as the user leaves (using the
onUnload, perhaps)
--
Markku Uttula | If I ever though yo would read this, I would
webmaster@disconova.com | have written something useful in here...
http://www.disconova.com/ | - Mickey Mouse
------------------------------
Date: Wed, 11 Mar 1998 10:13:43 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: perl binary for SGI
Message-Id: <fl_aggie-1103981013440001@aggie.coaps.fsu.edu>
In article <35068BDC.554C@fhw.gr>, kamari@fhw.gr wrote:
[posted && cc'd]
+ I am looking for a perl binary for an SGI Irix 6.2
<url:http://reality.sgi.com/scotth/info/perl5.html>
You can use 'swmgr' to install this package into the /usr/freeware/
directory structure.
The more recent versions of IRIX (6.4? and better) will include
version 5 of perl. Finally.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: Wed, 11 Mar 1998 09:59:57 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Printing Hash of Hashes Problem
Message-Id: <3506A6ED.7CC0@min.net>
toml@synnet.com wrote:
>
> $matrix = [$_, $file, $result];
> push (@{$file_index{$file}}, $matrix);
>
> How I print it is like so:
>
> foreach $i (sort keys %file_index) {
> foreach $rl (sort @{$file_index{$i}}) {
> if (($rl->[1] ne $filename) || ($rl->[2] != $days)) {
> print "\n";
> print "The license(s) in $rl->[1]
> will expire in $rl->[2] days:\n";
> $filename = $rl->[1];
> $days = $rl->[2];
> }
> printf " %-96s\n",$rl->[0];
> }
> }
I'll bet the problem is in the second foreach:
the values over which that foreach is iterating (and setting
$rl to) are in the array @{$file_index{$i}}. Good.
But you know that those values are array-refs. After all,
you're using them that way in expressions like $rl->[2].
Now what happens if you sort a list of array-refs?
Not what you think; in fact, not anything predictable, on
most machines.
Are you sure you want the list of matrices in some order
other than that in which they were pushed on the list?
If not, just take out the sort.
If so, you'll need to resort (:-) to something like the
following, which sorts on filename:
foreach $rl (
sort { $a->[1] cmp $b->[1] } @{$file_index{$i}}
) {
hth,
John Porter
------------------------------
Date: Wed, 11 Mar 1998 09:31:45 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Problem with "goto" in Perl
Message-Id: <3506A051.50E6@min.net>
Uri Guttman wrote:
>
> goto was invented by uncle bill, lord of the evil empire :-)
Better to blame those other, not quite so nefarious, Bills, K&K...
> this technique can be nested as deep as you want and any statement can
> exit any labeled block. also you can use next as well to perform the
> next loop of any labeled loop.
It is much better than goto in many respects, as Uri has enumerated.
But 'last'ing out of any arbitrary depth to any other outer arbitrary
depth is JUST AS BAD as goto, in its potential for s.c. (spag code).
John Porter
------------------------------
Date: Wed, 11 Mar 1998 10:07:13 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Problem with "goto" in Perl
Message-Id: <3506A8A1.A2A@min.net>
Tony Fitzgerald wrote:
>
> Rather than be a slave to goto dogmas, I've found the following methodology
> for handling error recovery simpler, more straight forward and easier to
> maintain than the alternative of failure switches and complex if/leave/etc
> nestings:
>
> sub Fail {
> my $msg= "$0: ".(my $em=shift)."\n";
> my %opt= @_;
> local $_;
> ($_=$opt{Resume})
> ? ( (warn $msg),
> ('CODE' eq ref $_)?$_->($em):(goto $_))
> : die $msg;
> }
>
> while(...) {
> open IFA,$whatever or Fail "open $whatever: $!", Resume=> sub{next};
> open IFB,$wherever or Fail "open $wherever: $!", Resume=>'KEEP_GOING';
> KEEP_GOING:
> close IFA;
> }
Somehow that doesn't strike me as simpler, clearer, and easier to
maintain
than:
while (...) {
open F,$whatever or croak "open $whatever: $!";
open F,$whatever or carp "open $whatever: $!", next;
open F,$whatever or carp "open $whatever: $!", goto KEEP_GOING;
KEEP_GOING:
close F;
}
Not to mention:
while (...) {
open F,$whatever or croak "open $whatever: $!";
open F,$whatever or carp "open $whatever: $!", next;
open F,$whatever or carp "open $whatever: $!", next;
}
continue {
close F; # fails silently if not open.
}
John Porter
------------------------------
Date: Wed, 11 Mar 1998 10:16:00 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Problem with "goto" in Perl
Message-Id: <3506AAB0.3177@min.net>
schwern@starmedia.net wrote (severely edited by John Porter:
>
> LABEL;
> # A few hundred lines
> if ( $CertainErrorCondition ) {
> goto LABEL; # Start over
> }
> # Lots more code...
>
> there are other possiblities.
> He could have wrapped the program in a labeled
> block and done a next LABEL or redo LABEL
> (wait... can you do that in a non-loop block?),
Yes. Quite.
{
# tons o' code.
redo if $oh_no; # returns to beginning of bare block.
# continue blithely.
}
> but would that really have been any different from the
> goto? No.
Not, except for all the other advantages of next/last/redo, which
you don't get with goto.
John Porter
------------------------------
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 2071
**************************************