[7217] in Perl-Users-Digest
Perl-Users Digest, Issue: 842 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 11 00:07:14 1997
Date: Sun, 10 Aug 97 21:00:24 -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, 10 Aug 1997 Volume: 8 Number: 842
Today's topics:
2 variables = 1 <ptrainor@aura.title14.com>
Re: Browser interaction in DOS (Scott McMahan)
Re: can regexp do balanced match? (Dean Inada)
Re: can regexp do balanced match? (Mike Stok)
Re: Clearing browser screen before sending HTML code to <petri.backstrom@icl.fi>
Re: Code breaks <weck@atweb.com>
Re: Converting cgi submission to variable names? <weck@atweb.com>
Re: FILEHANDLE actually IO::Handle? (Andrew Pimlott)
Help me!! Image cache-ing problem <tony@web-edge.comX>
How do you determine program runtime? (Scott Card)
Re: How do you determine program runtime? (Jim Trocki)
Re: How to secure data? (Scott Card)
Re: How to secure data? <rootbeer@teleport.com>
Re: Input a record in the middle of an Array <petri.backstrom@icl.fi>
Re: Is there a perl IDE? (Scott McMahan)
Re: newbie: can't export vars from module (Mike Stok)
Perl5 can not load cgi-lib.pl ("MS. JONES")
Re: Problem installing 5.004_02 on MkLinux / Dynamic Lo <shimpei@socrates.caltech.edu>
Re: Q: Recompiling Modules during execution <rootbeer@teleport.com>
Regex wizard (was: Re: Is there a perl IDE?) <rootbeer@teleport.com>
Sorting Challenge (Ranson)
Re: Sorting Challenge <weck@atweb.com>
Re: Sorting this file is killing me <jefpin@bergen.org>
Re: Sorting this file is killing me <rootbeer@teleport.com>
Re: textarea - Script not producing line feeds?? (Joshua J. Kugler)
Visual Perl! (Scott McMahan)
Re: Visual representation of UNIX Directories? (Tushar Samant)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 10 Aug 1997 22:40:03 -0400
From: Pat Trainor <ptrainor@aura.title14.com>
Subject: 2 variables = 1
Message-Id: <Pine.LNX.3.95.970810223359.27774A-100000@aura>
Greetings,
I wonder if any of you know how this is done:
variables:
$abcd0001
$abcd0002
...
How can I represent this variable as it changes, with another? For example:
###############################
dbmopen (%MAIN_CHOICES,"main_choices",0600);
$count=0001;
while (($key, $value) = each(%MAIN_CHOICES)) {
$count=$count + 1
print "key $key has a value of $urlb$count \n";
} ^^^^^^^^^^^
dbmclose(%MAIN_CHOICES);
###############################
Where $urlb would always be: abcd and $count would increment by 1 on each pass.
The reason this is needed is that the output of this while loop is unsorted.
tia!
pat
:)
System Administrator Guy
ptrainor@aura.title14.com
------------------------------
Date: 10 Aug 1997 21:15:31 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Re: Browser interaction in DOS
Message-Id: <5slb1j$68b$1@scully.new-era.net>
Hedin Meitil (hm@royal.net) wrote:
: Now, though, I would like to make a simulated trip into CGI-scripting.
[Large amounts of totally irrelevant stuff deleted]
I've never heard of a browser which could run CGI scripts.
You need a web server for that.
Scott
------------------------------
Date: 11 Aug 1997 01:32:25 GMT
From: dmi@delta1.deltanet.com (Dean Inada)
Subject: Re: can regexp do balanced match?
Message-Id: <5slq39$adu$1@news01.deltanet.com>
In article <b2mhs5.hj.ln@localhost>, Tad McClellan <tadmc@flash.net> wrote:
>doritozilla (ouij@triples.math.mcgill.ca) wrote:
>
>: I'd sleep easier knowing that the parenthesis
>: were balanced.]
>
>Regular expressions cannot match balanced things to an arbitrary
>depth of nesting
Sure they can:
warn $@ if( eval{($re=$_)=~s/(\()|(\))|./$2.$1/gs&&/$re/s},$@=~/unmatched/ );
Or in 5.004
warn $@ if( eval{/@{[m(([()]))g]}/},$@=~/unmatched/ );
> >If you can establish a maximum nesting depth, then you can write
>a regex to match it.
e.g.:
'\(' . '([^()]|\(' x $depth . '[^()]*' . '\))*' x $depth . '\)'
HREF="http://enterprise.ic.gc.ca/~jfriedl/regex/errata.html"
>
>See also "Can I use Perl regular expressions to match balanced text?"
>in the Perl FAQ, part 6 ;-)
Should that be updated?-)
------------------------------
Date: 11 Aug 1997 02:21:32 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: can regexp do balanced match?
Message-Id: <5slsvc$9v8@news-central.tiac.net>
In article <5slq39$adu$1@news01.deltanet.com>,
Dean Inada <dmi@delta1.deltanet.com> wrote:
>warn $@ if( eval{/@{[m(([()]))g]}/},$@=~/unmatched/ );
>>See also "Can I use Perl regular expressions to match balanced text?"
>>in the Perl FAQ, part 6 ;-)
>Should that be updated?-)
Surely you're using perl's code which compiles the regular expressions
rather than using regular expression engine itself? But it's neat - maybe
the FAQ should be "Can I use Perl's regular expression mechanisms to match
balanced text?" :-)
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@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Fri, 08 Aug 1997 23:58:07 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Clearing browser screen before sending HTML code to browser.
Message-Id: <33EB885F.2072@icl.fi>
Steve Schmitz wrote:
>
> I have a PERL script that is sending the output from a COBOL program to
> the browser screen. While the program is running, I display a message
> at the top of the screen telling the person to "please wait" for the
> output from my program.
>
> The problem is that when my PERL script sends the output to the browser,
> instead of the output starting at the top of the screen, it follows the
> "please wait" message that I already have on the screen. I would like
> for the "please wait" message to be overwritten at this point.
>
> Can anyone help me with this.
A CGI script can be written in any language (that supports environment
variables and can read/write standard input/output).
If I needed this kind of thing, I'd do in Perl like this:
print 'whatever it is that needs to be printed';
If my script was written in C, I'd do:
printf( "whatever it is that needs to be printed" );
If my script was a UNIX shell script, I'd use 'echo'.
If it was in Pascal, I'd use 'writeln'.
In COBOL I'd put a lot of stuff in the IDENTIFICATION DIVISION,
some more stuff in the ENVIRONMENT DIVISION, maybe a bit in
the DATA DIVISION, and in the PROCEDURE DIVISION I'd do
DISPLAY "whatever it is that needs to be printed".
So, what I'm trying to say is that yours isn't a Perl question at
all, and you need to figure out what, exactly (if anything) is:
whatever it is that needs to be printed
I.e., you should really be asking in another newsgroup such as
comp.infosystems.www.authoring.misc or c.i.w.a.html, or perhaps
some browser specfic one.
As far as I know, you can't do it with HTML, except indirectly.
A possible approach is to create a datafile for the COBOL program
output (generate a unique filename using a timestamp, process ID
& such), and lock it for exclusive write access.
Then send a page with a redirection header and your "wait" message.
Redirect the browser back to your server (possibly to the same
script, which at the beginning determines by the parameters you
pass to it what "state" it is in), and with the filename as a
parameter too.
Now your first script can launch the COBOL program, capture its
output and write it to the datafile.
In the meanwhile the browser has redirected itself to the new URL,
where the script receives the datafile name, and also tries to
open it for exclusive access.
If if fails, it does another redirection (to itself), and terminates.
When the first script is ready, and finishes (closes the datafile),
then your second succeeds in getting the lock, and knows that the
first script is done (the first script could also have written an
error status into the file, if you wish) and that it can send the
results to the client.
The second script can then clean up after itself and delete the
temporary file (and you also need to set up something to clean up
the system periodically, because the user at the browser may abort
before the data is ready, and the second script may thus never get
to the point where it should delete the file).
Remember to also put a link on the "wait" page that the user
can press, in case the user's browser doesn't for some reason
or other handle the automatic redirection.
Or you do browser dependent things such as use, e.g., Microsoft
Internet Explorer 4.0 supported Dynamic HTML...
Anyway, no matter how you do it, it isn't a Perl issue.
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: Sun, 10 Aug 1997 15:57:38 -0700
From: Peter Weck <weck@atweb.com>
To: Eric Hilding <eric@hilding.com>
Subject: Re: Code breaks
Message-Id: <33EE4762.938526BC@atweb.com>
Eric Hilding wrote:
>
> I'm sure I'm 'escaping' things right, but in trying to process
> this form data the darn thing breaks. perl -wc checks out okay
> for the whole script.
>
> #print MAIL " Work Tel: $FORM{'e7'), \"/\", $FORM{'e8'}, \"ext\",
> $FORM{'e9'}\n";
> #print MAIL " Home Tel: $FORM{'e10'}, \"/\", $FORM{'e11'},\n";
>
> (presently ###'d out)
>
> Any ideas?
>
> Tnx.
>
> Eric
Have you tried running in taint mode (-T)?
If "MAIL" and/or "$FORM" is tainted, you will have problems if the
script is running suid. You will have to untaint the variables to make
it work. See the Cammel book for more info on tainted variables.
-Peter Weck
::::::::::::::::::::::::::::::::::::::: / ______ \ AtWeb Inc. :::::
/ / _____ \ \ . . . . . . .
!Register-it! / // __ /\/ /\ . . . . . . .
Promote Your Web Site / // /_/ /_/ / / . . . . . . .
register@register-it.com / / \________/ / . . . . . . . .
http://www.register-it.com \ \/_\_______\/ . . . . . . . .
\_________/\ . . . . . . . . .
::::::::::::::::::::::::::::::::::::: \________\/ :::::::::::::::::::
------------------------------
Date: Sun, 10 Aug 1997 14:56:32 -0700
From: Peter Weck <weck@atweb.com>
To: Ariel Y Fishman <ayfishma@mail2.sas.upenn.edu>
Subject: Re: Converting cgi submission to variable names?
Message-Id: <33EE3910.AD774E17@atweb.com>
Ariel Y Fishman wrote:
> In principle, is there a way to assign a variable without actually
> typing out the variable name? (Can I assign $variable to be something
> without actually typing the command line '$variable = '?)
If you are using Perl 5, you can do the following:
$foo = "hello";
$$foo = "world";
this will set $hello = "world".
If you are using Perl 4 (also works with Perl 5):
$foo = "hello";
eval("\$$foo = \"world\"");
will do the same thing.
-Peter Weck
::::::::::::::::::::::::::::::::::::::: / ______ \ AtWeb Inc. :::::
/ / _____ \ \ . . . . . . .
!Register-it! / // __ /\/ /\ . . . . . . .
Promote Your Web Site / // /_/ /_/ / / . . . . . . .
register@register-it.com / / \________/ / . . . . . . . .
http://www.register-it.com \ \/_\_______\/ . . . . . . . .
\_________/\ . . . . . . . . .
::::::::::::::::::::::::::::::::::::: \________\/ :::::::::::::::::::
------------------------------
Date: 11 Aug 1997 03:16:15 GMT
From: andrew@pimlott.student.harvard.edu (Andrew Pimlott)
Subject: Re: FILEHANDLE actually IO::Handle?
Message-Id: <slrn5ut15e.6nt.andrew@pimlott.student.harvard.edu>
On 7 Aug 1997 05:07:19 GMT, Todd O'Boyle <oboyle@.cs.purdue.edu> wrote:
>I am encountering an error in some code that I wrote, and the error
>is quite puzzling. Using perl5.004 I am getting a "Can't locate object
>method "print" via package "IO::Handle" at Authd.pm line 257." error
>when passing around a filehandle. (Using perl 5.003 I get FileHandle
>instead of IO::Handle)
>
>I don't use IO::Handle anywhere in my code, so I was wondering if perl
>uses it in it's underlying data structure. If so, why is it not
>finding print(), I know it has it?
As you suspect, some magic is going on under the hood--read the
IO::Handle(3) man page. As for why it cannot find a print method--did you
use IO::Handle?
>Here is some of my code:
[snip]
Thi is way too long for anyone to read. Try to produce a concise test
script next time.
Andrew
------------------------------
Date: Sun, 10 Aug 1997 23:08:51 -0400
From: Tony <tony@web-edge.comX>
Subject: Help me!! Image cache-ing problem
Message-Id: <33EE8243.EBB3BB1F@web-edge.comX>
I wrote a Perl CGI for a friend and it works - only once per session.
It seems to somehow be using images from cache - it doesn't change when
I change the form picks. The form is at
http://web-edge.com/checks/form.html
and the script (partial) is below. It should display an image based on
a
form selection. I am using the GD.pm module, because I have more things
to do with the graphics (this is just a test). I would appreciate any
help if someone can ....
If you go back and change the pick - it keeps the old display image but
will do it correctly if you 'refresh'.
Thanks,
Tony
---------------------------------------
&ReadParse;
open (GIF,"/usr/local/etc/httpd/htdocs/checks/$in{'icon'}.gif") || die;
$back=newFromGif GD::Image(GIF) || die;
close GIF;
$gif_data=$back->gif;
open (DISPLAY,">/usr/local/etc/httpd/htdocs/checks/images/stack.gif");
print DISPLAY $gif_data;
close DISPLAY;
print &PrintHeader;
print "<HTML><BODY>\n";
print "Here is the image you selected:<br><br>\n";
print "<img src=\"http://web-edge.com/checks/images/stack.gif\">\n";
print "</BODY></HTML>\n";
exit;
------------------------------
Date: Mon, 11 Aug 1997 02:24:38 GMT
From: ils@pipcom.com (Scott Card)
Subject: How do you determine program runtime?
Message-Id: <33ee7756.10233296@news.pipcom.com>
How can i determine the running time of a program?
I have a cron cgi program and need to know exactly how many
milliseconds it runs until it terminates.
Thanks.
------------------------------
Date: 11 Aug 1997 03:53:28 GMT
From: trockij@transmeta.com (Jim Trocki)
Subject: Re: How do you determine program runtime?
Message-Id: <5sm2bo$4er$1@palladium.transmeta.com>
In article <33ee7756.10233296@news.pipcom.com>,
Scott Card <ils@pipcom.com> wrote:
>How can i determine the running time of a program?
>
>I have a cron cgi program and need to know exactly how many
>milliseconds it runs until it terminates.
You'll need to do a "require 'syscall.ph'", and use the getrusage(2)
system call to get this information. getrusage(2) will return the amount
of consumed user and system time.
It could be a little tedious to do the rusage structure correctly in Perl.
Use pack to create the scalar that you pass to getrusage(2), and use
unpack to separate the results.
--
Jim Trocki
Computer System and Network Engineer
Transmeta Corporation
Santa Clara, CA trockij@transmeta.com
------------------------------
Date: Sun, 10 Aug 1997 23:51:05 GMT
From: ils@pipcom.com (Scott Card)
Subject: Re: How to secure data?
Message-Id: <33ee52f0.915434@news.pipcom.com>
On Sat, 9 Aug 1997 13:27:53 -0700, Tom Phoenix <rootbeer@teleport.com>
wrote:
>On Sat, 9 Aug 1997, Scott Card wrote:
>
>> After data on a form has been submitted what's the best way
>> to lock the data away securly?
>
>You're closing the barn door after the horse has escaped if the data were
>sent insecurely over the web. But you may want one of the PGP interface
>modules or something similar from CPAN. Hope this helps!
>
>--
>Tom Phoenix http://www.teleport.com/~rootbeer/
>rootbeer@teleport.com PGP Skribu al mi per Esperanto!
>Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
It doesn't matter if the data is secure during transmission. What i
wish to do is after the user presses the Submit button save the data
in a file that cannot be changed by the user (NOBODY) or any other
user except me.
Thanks.
------------------------------
Date: Sun, 10 Aug 1997 18:17:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Scott Card <ils@pipcom.com>
Subject: Re: How to secure data?
Message-Id: <Pine.GSO.3.96.970810181526.4912L-100000@julie.teleport.com>
On Sun, 10 Aug 1997, Scott Card wrote:
> It doesn't matter if the data is secure during transmission. What i
> wish to do is after the user presses the Submit button save the data
> in a file that cannot be changed by the user (NOBODY) or any other
> user except me.
So you want to put the data into a file whose owner permission bits are
set so that only you (and root) have access. You may need to make a set-id
script to make this possible, so see the perlsec(1) manpage for the
security issues. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 09 Aug 1997 00:12:36 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Input a record in the middle of an Array
Message-Id: <33EB8BC4.5FEF@icl.fi>
Jeroen Kustermans wrote:
>
> Is there a way to input a record in the middle of an Array?
> So, if I have:
Use splice() to remove stuff from the array (it'll return
what was removed, so save that, then add your stuff to
the end of the remaining piece - the "middle" - and stick
back with push() what you removed with splice().
Or loop through each element, and save it in a new array
as you go on. When you get to the point where you wanted
the new value, put in the new value, and then continue
with the loop. When you're done, replace the stuff in
the original array with the stuff in the temporary new
array you created.
This is really a task for linked lists, and push/pop,
shift/unshift and splice are the mechanisms to do it.
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: 10 Aug 1997 21:25:59 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Re: Is there a perl IDE?
Message-Id: <5slbl7$68b$2@scully.new-era.net>
: I can't seem to find a perl IDE for Win95 anywhere.
Yeah, you'd think someone would write one. Visual P++ or something. An
IDE, a debugger, syntax highlighting. I think it would be a big hit.
If it had a builtin way to somehow run a program as a CGI application
without requiring a web server, and with decent debug support (fill out
an HTML form in one window, and watch the IDE execute the perl program
in another), it would sell billions of copies (if not more). The
ability to create a native Windows EXE, even if it required a
perlrun100.dll, would make it a big seller.
One wonders why opportunistic software developers wouldn't
throw a team of developers into this project. You could do it
quick (compare how fast Microsoft created a Java IDE!), and
it would sell like bibles on judgement day.
Think of the possibilities: a Regex Wizard -- it takes English
phrases like "match everything on the line up to a space",
and translates them into regexes.
: What do you folks use?
Same thing we use for everything else, Emacs. Emacs for Win32's
shell window makes a great interactive perl testing platform.
You run commands, and all output is preserved in the buffer.
: Is perl not worthy of anything more robust that Notepad?
I'm honestly stunned that anyone actually *USES* notepad.
It's little more than a joke, a throwaway example of an
edit control.
Scott
------------------------------
Date: 10 Aug 1997 22:01:53 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: newbie: can't export vars from module
Message-Id: <5sldoh$p77@news-central.tiac.net>
In article <5skva2$f46$1@nntp.ucs.ubc.ca>,
Jeffery Chow <jefferyc@unixg.ubc.ca> wrote:
>Hi, I'm trying to access some variables in one of my modules, but
>can't get them exported properly. I would appreciate it if
>you experts can comment:
>
>--- here's what's in my module: --
>package UVCommon
>require Exporter;
>@ISA=qw(Exporter);
>@EXPORT=qw(MOB_DIR ZON_DIR OBJ_DIR WLD_DIR);
>@EXPORT_OK=();
>
>$BASE='/some/path/to/system/root';
>$MOB_DIR="$BASE/m";
>$ZON_DIR="$BASE/z";
>$OBJ_DIR="$BASE/o";
>$WLD_DIR="$BASE/w";
>1;
>If someone can steer me in the right direction, I'd appreciate it
>greatly.
You probably want to say:
@EXPORT=qw($MOB_DIR $ZON_DIR $OBJ_DIR $WLD_DIR);
as you're exporting the scalars - your line would export subroutines with
those names.
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@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Sun, 10 Aug 1997 21:57:46 -0700
From: shakes999@huskynet.com ("MS. JONES")
Subject: Perl5 can not load cgi-lib.pl
Message-Id: <01BCA5D8.73C2DA80@dialup2.huskynet.com>
I am new to Perl5 and I am using the Perl for win32 5.004 version. I =
have a question that I can not get past. I do not know why I can not =
load the cgi-lib.pl library properly. My syntax for the survey1.pl =
program works. It says syntax OK. The error is can not load cgi-lib.=20
What I have done:
I have installed Perl for Win32 5.004.=20
I am using windows 95 and Microsoft Internet Explorer.=20
My Internet Service Provider "Huskynet" supports Perl.=20
I type in the ftp huskeynet directory, then anonymous, cd ..., my =
password then=20
I type bin
I send c:\perl\5.004\bin\survey1.htm
I copied the html and perl script from a book and made only the changes =
the book directed me to make.=20
I associated the .pl extension to run with c:\perl\5.004\bin\perl.exe.
The directory where perl.exe is located.
The book stated that it used the cgi-lib so I have also copied the =
cgi-lib.pl to c:\perl5\cgi-bin. I repalce in the survey1.pl program #! =
/usr/local/bin to=20
#! /perl5/cgi-bin. I execute perl survey1.pl from dos and it works. It =
says syntax OK.=20
Then I try to run without the -w and it says Fatal error cannot load cgi =
library. I know that the do cgi-lib is not running correctly and I do =
not know why.
I tried it on the Internet Explorer http://www....survey.htm and when I =
select send survey it gives the error can't exec at c:\microsoft =
internet\ cache\ survey1. pl.
I have read the internets documentation, books, and the idiots guide to =
perl and cgi and I can not get it to load the cgi-lib. I am confused.
What am I doing wrong?
Do I have to get an interpreter?
Thanks.
Robin.
------------------------------
Date: 11 Aug 1997 01:01:12 GMT
From: Shimpei Yamashita <shimpei@socrates.caltech.edu>
Subject: Re: Problem installing 5.004_02 on MkLinux / Dynamic Loading
Message-Id: <5slo8o$l2p@gap.cco.caltech.edu>
Chris Nandor <pudge@pobox.com> writes:
>
>MkLinux2.1,update4 (2.0.30-osfmach3)
>
>Everything runs perfectly through the config/make process, but I get the
>following error on testing of all dynamically loaded modules:
>
> undefined symbol: Perl_markstack_ptr at ../lib/DynaLoader.pm line 155.
>
>Now, if I can't figure it out, I can always compile for static loading, but
>I'd rather not. Any ideas?
Download
<ftp://ftp.linuxppc.org/RedHat/SRPMS/perl-5.004-1A.src.rpm>
and study the patch file. I can't remember the exact flags offhand,
but you need to change the flags sent to ld to ones different from the
Intel Linux defaults in order to get dynamic loading working. (This
also goes for other programs that use dynamic loading, such as
Python.) I put the information in MkLinux FAQ-o-Matic a few months
ago, but it's gone now; I wonder why....
--
Shimpei Yamashita <http://www.patnet.caltech.edu/%7Eshimpei/>
------------------------------
Date: Sun, 10 Aug 1997 17:56:00 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Aaron Bawcom <aaron@bawcom.net>
Subject: Re: Q: Recompiling Modules during execution
Message-Id: <Pine.GSO.3.96.970810174723.4912G-100000@julie.teleport.com>
On Sun, 10 Aug 1997, Aaron Bawcom wrote:
> Given the following situation:
> 1) Script foo:
>
> #! /usr/bin/perl
> if (fork) {exit;}
> use MyClass;
>
> while (1) {
> do stuff..
> }
>
> 2) Package MyClass:
>
> package MyClass;
> More code....
>
> 1;
I'm not sure what you mean by "2) Package MyClass". But you seem to mean
"2) Module MyClass". Is that right?
> Is it possible to ask Perl to recompile the MyClass module during
> run-time?
Why? Didn't you like the way perl compiled it the first time? :-)
Once perl has compiled some Perl code, it keeps the compiled (bytecode)
form around until the process exits, in most cases.
> I tried doing a 'require MyClass;' in the while loop but the originally
> compiled code is used instead of any new code that was introduced since
> the module was 'require'd.
It sounds as if your program is editing the MyClass.pm file and then using
routines from that file. Is that it? If so, you probably want to solve
your problem a different way. You _could_ diddle with %INC, I suppose, but
it sounds more like you might want to use anonymous subs, possibly created
through eval STRING. Either way, it can make your head swim!
# Recompile my sub, using current value of $some_code
$my_sub = eval "sub { $some_code }";
# Call the new routine
@results = &$my_sub($parameter);
Can you tell more about why you would want to edit the module on the fly?
Maybe someone here will be able to suggest a better way to do whatever
you're trying to do. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 10 Aug 1997 18:04:46 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Scott McMahan <scott@lighthouse.softbase.com>
Subject: Regex wizard (was: Re: Is there a perl IDE?)
Message-Id: <Pine.GSO.3.96.970810175824.4912I-100000@julie.teleport.com>
On 10 Aug 1997, Scott McMahan wrote:
> Think of the possibilities: a Regex Wizard -- it takes English
> phrases like "match everything on the line up to a space",
> and translates them into regexes.
Ah, but could it recognize how vague that description is, and generate a
dozen regexps to match?
/.* /
/(.*) /
/(.*)(?= )/
/^.* /m
/.* /s
/(.*)\s/
I could write at least three dozen which someone could mean by that
phrase. Gee, I wonder what the wizard comes up with when you type in
"match an e-mail address"? :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 10 Aug 1997 22:36:41 GMT
From: ranson@infoave.net (Ranson)
Subject: Sorting Challenge
Message-Id: <5slfpp$b1b@news1.infoave.net>
Greetings, I am searching for an answer for a sort question.
I have a program that opens data files and prints the data foreach file
to an HTML page for viewing.
The program sorts the files, lowest number first.
So the oldest data is always at the top. I want to reverse this order
and put the newest data at the top. I have researched this some and
have not found a way to do this. Does someone know how to do this?
I have used the Camel book and did find some information, but
it is confusing.
My files are numbered like: f1001.rec f1002.rec
foreach $ad (@FILES) {
open (AD,"$ad");
@LINES=<AD>;
--
Many thanks,
Ranson
------------------------------
Date: Sun, 10 Aug 1997 16:10:43 -0700
From: Peter Weck <weck@atweb.com>
To: ranson@infoave.net
Subject: Re: Sorting Challenge
Message-Id: <33EE4A73.5D47D156@atweb.com>
Ranson wrote:
>
> Greetings, I am searching for an answer for a sort question.
>
> I have a program that opens data files and prints the data foreach file
> to an HTML page for viewing.
>
> The program sorts the files, lowest number first.
> So the oldest data is always at the top. I want to reverse this order
> and put the newest data at the top. I have researched this some and
> have not found a way to do this. Does someone know how to do this?
> I have used the Camel book and did find some information, but
> it is confusing.
>
> My files are numbered like: f1001.rec f1002.rec
>
> foreach $ad (@FILES) {
>
> open (AD,"$ad");
> @LINES=<AD>;
> --
> Many thanks,
> Ranson
Use the reverse function.
foreach $ad (reverse(@FILES)) {
-Peter Weck
::::::::::::::::::::::::::::::::::::::: / ______ \ AtWeb Inc. :::::
/ / _____ \ \ . . . . . . .
!Register-it! / // __ /\/ /\ . . . . . . .
Promote Your Web Site / // /_/ /_/ / / . . . . . . .
register@register-it.com / / \________/ / . . . . . . . .
http://www.register-it.com \ \/_\_______\/ . . . . . . . .
\_________/\ . . . . . . . . .
::::::::::::::::::::::::::::::::::::: \________\/ :::::::::::::::::::
------------------------------
Date: Sun, 10 Aug 1997 20:28:35 -0400
From: Anagrams of the Word <jefpin@bergen.org>
To: paries@advicom.net
Subject: Re: Sorting this file is killing me
Message-Id: <Pine.SGI.3.95.970810202213.17877A-100000@vangogh.bergen.org>
>anyways , I have a file that looks like this
>
>Marge Simpson|100.00
>bart Simpson|1000.00
>joe simth|300.00
>
>I need to read in this file and the sort the pairs by field 2 and then
>load into either an array of arrays or hash.
so try this:
open (FILE, "/foo/bar/file") || die "Can't open file: $!";
@data = <FILE>;
close (FILE);
foreach (@data){
chop;
($salary{$person},$salary{$money}) = split(/\|/,$_);
}
# now have hash %salary
# "Marge Simpson","100.00"
# "Bart Simpson","1000.00"
# "Joe Smith","300.00"
sub num { $salary{$b} <=> $salary{$a}; }
%people = sort keys num %salary;
# now have hash %people:
# "Bart Simpson","1000.00"
# "Joe Smith","300.00"
# "Marge Simpson","100.00"
If you have any trouble, let me know.
----------------
| "Here we are now, entertain us!"
| - Nirvana
----------------
Jeff "TechMaster" Pinyan | http://users.bergen.org/~jefpin
I do: HTML!! CGI!! Perl!! JavaScript!! jefpin@bergen.org
Got a JavaScript/CGI/Perl question or problem? Let me know!
webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS
------------------------------
Date: Sun, 10 Aug 1997 18:50:56 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Anagrams of the Word <jefpin@bergen.org>
Subject: Re: Sorting this file is killing me
Message-Id: <Pine.GSO.3.96.970810184140.4912O-100000@julie.teleport.com>
On Sun, 10 Aug 1997, Anagrams of the Word wrote:
> so try this:
>
> open (FILE, "/foo/bar/file") || die "Can't open file: $!";
> @data = <FILE>;
> close (FILE);
>
> foreach (@data){
> chop;
> ($salary{$person},$salary{$money}) = split(/\|/,$_);
That's not going to build a very big hash. :-) You've never set $person
and $money to anything. And if you had, you still wouldn't be associating
$salary{"Bart Simpson"} with 1000.00. (But you seem to want
$salary{"1000.00"} to have a value... :-)
> sub num { $salary{$b} <=> $salary{$a}; }
> %people = sort keys num %salary;
I don't think that's right; I see at least three important errors there.
Besides, you should call that sub something more meaningful like
"by_salary" or even "by_decr_salary".
> If you have any trouble, let me know.
Nope, it didn't give me any trouble at all. :-) I hope it didn't give any
trouble to the person you were trying to help!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 11 Aug 1997 03:33:52 GMT
From: FIGHT-SPAMjkugler@inreach.com (Joshua J. Kugler)
Subject: Re: textarea - Script not producing line feeds??
Message-Id: <33ee8816.31515415@news.inreach.com>
On 4 Aug 1997 14:52:23 GMT, Burt lewis@ici.net (Burt Lewis) wrote:
()In my Perl scripts I have:
()
()print "<TR><TD><textarea Rows=8 Cols=65 name=\"body\"
()wrap=\"physical\"></textarea></TD></TR>\n";
()
()Problem is that I need line feeds after each line that is wrapping
and
()I'm not getting any. The input is coming out as one long string
with
()no breaks.
()
()Any ideas or suggestions is appreciated.
Get the Text::Wrap module. Works like a charm, and does the job.
Please reply via e-mail as well.
Joshua J. Kugler
Computer Consultant--Web Developer
Real e-mail address spelled out to prevent spam. jkugler at inreach dot com
http://www.cwebpages.com/jkugler
Every knee shall bow, and every tongue confess, in heaven, on earth, and under the earth, that Jesus Christ is LORD -- Count on it!
- - - - -
To reply via e-mail, please remove 'FIGHT-SPAM' from my e-mail address. Thanks.
------------------------------
Date: 10 Aug 1997 21:40:39 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Visual Perl!
Message-Id: <5slcgn$68b$3@scully.new-era.net>
------------------------------
Date: 10 Aug 1997 22:40:58 -0500
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: Visual representation of UNIX Directories?
Message-Id: <5sm1ka$gmg@shoga.wwa.com>
roswell@umbc.edu writes:
>I'm looking for a visual representation of directories in UNIX. Any
>solutions are welcome.
Trying to reconstruct a command I had snarfed off the net long ago:
find . -print | sed -e 's,[^/]*/\([^/]*\)$,`--\1,' -e 's,[^/]*/,| ,g'
Perl would of course give more spectacular results, but this one is
just so sleek ...
------------------------------
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 842
*************************************