[8148] in Perl-Users-Digest
Perl-Users Digest, Issue: 1766 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 29 23:10:22 1998
Date: Thu, 29 Jan 98 20:00:25 -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 Thu, 29 Jan 1998 Volume: 8 Number: 1766
Today's topics:
Re: A Rounding Question (brian d foy)
Re: Array refs and hashes -- bug or misunderstanding? <zenin@best.com>
Re: Buffering output (Jeffrey Drumm)
Can anyone help me?????????????? <seong@cse.bridgeport.edu>
Re: Converting to Leadingcap format? (Tad McClellan)
Re: delete function (Abigail)
Re: FAQ too big (Was: Re: PERL forking) (Tad McClellan)
Re: Freidl's book mystery (Ilya Zakharevich)
Re: How can I set enviroment variables on Win32? <metcher@spider.herston.uq.edu.au>
How do I copy files <kelby@mplx.com>
Re: How do I copy files (brian d foy)
Re: How do you make the something case-insensitive? (brian d foy)
How to invoke the process through netscape ? <seyang@cise.ufl.edu>
howto find out if $x is a blessed reference (object) (Marc Duponcheel)
Re: howto find out if $x is a blessed reference (object (brian d foy)
Re: HTML/CGI to play midi file? (brian d foy)
Re: IP Address as new File <rjk@coos.dartmouth.edu>
Re: OLE and MS Word on NT <lutz@muc.de>
Re: Perl connection to Informix (brian d foy)
Re: perl script -> secure webpage (brian d foy)
Re: Problems converting Bourne shell to Perl <omg2@hrzsp1.horizon.waii.com>
Re: regex with variables? (Tad McClellan)
Re: regex with variables? (Ilya Zakharevich)
Re: regexes: fun with /x <rjk@coos.dartmouth.edu>
Re: regexes: fun with /x (Ilya Zakharevich)
Re: regexes: fun with /x (brian d foy)
Re: regexes: fun with /x <rjk@coos.dartmouth.edu>
Re: Retrieving remote page using CGI Script (brian d foy)
Re: Seeking Search Engine Code (brian d foy)
Re: Some possible bugs (brian d foy)
Re: Split <rjk@coos.dartmouth.edu>
Re: Where are all the scripts? (Gabor)
Re: Where are all the scripts? (brian d foy)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 29 Jan 1998 21:55:32 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: A Rounding Question
Message-Id: <comdog-ya02408000R2901982155320001@news.panix.com>
Keywords: from just another new york perl hacker
In article <34D10677.2EAC@mail.delcoelect.com>, "V. Chandrasekhar" <vchandra@mail.delcoelect.com> posted:
>1. I have requirements to process a set of numbers the following way:
>
> a. Multiply the number by 10
>
> b. Round to whole integer
>
> c. Make sure that the number is in the range -32768 to
> 32767
>
> d. Print the number out in FORTRAN Z4 format i.e., as a
> two-byte hex number.
>
>2. I was having some problems with step 'b'. The following is one
> way I found, to do this. I would appreciate constructive comments/
> suggestions for alternatives.
i think use of int() and the modulo function might make your life
easier :)
however, you may wish to see the article on rounding numbers in
this quarter's Perl Journal [1].
[1]
if it's not at your local bookstore, demand it! or see
<URL:http://www.tpj.com>
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: 30 Jan 1998 02:49:26 GMT
From: Zenin <zenin@best.com>
Subject: Re: Array refs and hashes -- bug or misunderstanding?
Message-Id: <886128863.280865@thrush.omix.com>
[posted & mailed]
Larry Rosler <lr@hpl.hp.com> wrote:
: The program constructs a reference to an array and puts the
: reference into both the key and the value of a one-item hash.
from man perlfaq4:
How can I use a reference as a hash key?
You can't do this directly, but you could use the standard
Tie::Refhash module distributed with perl.
: It then tries to print the array reference and the array value
: using various ways, all of which should be identical.
Not exactly. When a reference is used as a key, it is
first converted to a string and can no longer be used
as a reference.
: print map { "$_ |@{$list{$_}}|\n" } values %list;
Since the value of $list{'ARRAY(0x40026844)'} is a valid
array reference, this works.
: print map { "$_ |@{$list{$_}}|\n" } keys %list;
Ditto here too.
: print map { "$_ |@$_|\n" } values %list;
Since you're pulling the values, and since the
single value is still a real reference (not a string
form of it) this works.
: print map { "$_ |@$_|\n" } keys %list;
Now since the keys are strings, what you're really
asking here is for @{'ARRAY(0x40026844)'}, which of course
then dynamically creates this new "soft" reference with
no values and you get the output you saw.
This is another good use of 'use strict'. Since the above
is now a soft reference (because it's using the string, not
the hard reference), use strict would have told you this:
Can't use string ("ARRAY(0x74048)") as an ARRAY ref while "strict refs" in use at foo.pl line 10.
Learn use strict. Love use strict. It's your best Perl friend.
Even if you're only codeing a 3 line program, one of those 3 lines
should be "use strict;".
--
-Zenin
zenin@best.com
------------------------------
Date: Fri, 30 Jan 1998 02:02:16 GMT
From: drummj@mail.mmc.org (Jeffrey Drumm)
Subject: Re: Buffering output
Message-Id: <34d33463.182114525@news.mmc.org>
On Thu, 29 Jan 1998 11:28:34 -0500, Curt Peredina
<peredina@bedford.progress.com> wrote:
>I have a perl script with an HTML interface and the script processes
>some rather large arrays.
>
>What is the best way to force output to the browser each iteration
>through the array - it runs so long that the client disconnects.
>
>Thanks.
Look in the perlvar man page for $|, the autoflush variable.
Then look at your web server's documentation re: nph scripts. If you need
help with nph-specific problems, ask in an appropriate group (hint: not
here, where we generally like our Perl without the special sauce ;-)).
Good luck!
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center Information Services
420 Cumberland Ave, Portland, ME 04101
drummj@mail.mmc.org
------------------------------
Date: Wed, 28 Jan 1998 22:13:48 -0500
From: "Seong Y. Kim" <seong@cse.bridgeport.edu>
Subject: Can anyone help me??????????????
Message-Id: <34CFF3EC.4FA@cse.bridgeport.edu>
Hi, there. . .
Please, Can anyone know the value of PERL language? I mean if I write
200 lines of perl program, how much is this program worth? How much is
this on the market?
As a CGI programmer in perl language, how much can I make a month?
------------------------------
Date: Thu, 29 Jan 1998 14:04:52 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Converting to Leadingcap format?
Message-Id: <4dnqa6.7o8.ln@localhost>
Mike Noel (noel@integrityonline.com) wrote:
: Ok. This is mostly for the amusement of the experienced perl hacks.
: You know how it is when you just want something to work and it doesn't
: have to be pretty? Several times I've had to convert a string from mixed
: case to Leadingcap format (eg, "miKe" -> "Mike"). I am imagining that
: there is a super slick way to do this but here's my solution.
: What's the one liner?
Do you find the one liner for this that is given in the Perl FAQ,
part 4, unsatisfying in some way?
"How do I capitalize all the words on one line?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 30 Jan 1998 02:12:50 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: delete function
Message-Id: <6arcv2$hp3$1@client3.news.psi.net>
Justin (jwhite@thegrid.net) wrote on 1612 September 1993 in
<URL: news:34CFF632.4893EAAD@thegrid.net>:
++ Hi,
++
++ I'm having a hard time understanding the delete function in perl. Some
++ of the scripts that I have running on a BSDI machine require that I
++ delete certain lines of a file. It seems that the delete function only
++ likes to delete a specified key and associated value from a specified
++ hash. If I have a file full of tilde delimited text, do I have to dump
++ all of it into an associative array? It seems like it should be easier
++ than that, so I figured I'd post a question here in hopes that someone
++ might point out what I'm overlooking.
You need open, grep, seek, print & truncate.
Abigail
--
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
print+Just (), another (), Perl (), Hacker ();'
------------------------------
Date: Thu, 29 Jan 1998 13:56:43 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: FAQ too big (Was: Re: PERL forking)
Message-Id: <rtmqa6.7o8.ln@localhost>
Tom Christiansen (tchrist@mox.perl.com) wrote:
: [courtesy cc of this posting sent to cited author via email]
: In comp.lang.perl.misc,
: MARTIN@RADIOGAGA.HARZ.DE writes:
: :Exactly my opinion, too, with regard to PoBs. What the hell is a "KLB"??
: KLB is an acronym for `Known Lazy Bastard', aka non-FAQ reader, aka person
: who would rather make someone take their time to explain something basic
: than look it up in a FAQ.
My newsreader maintains a list of KLB's posting addresses in a config
file, and I never even knew that they were called that...
;-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 30 Jan 1998 00:56:36 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Freidl's book mystery
Message-Id: <6ar8g4$9u8$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Chip Salzenberg
<chip@pobox.com>],
who wrote in article <6ar1ic$940$1@cyprus.atlantic.net>:
> According to ilya@math.ohio-state.edu (Ilya Zakharevich):
> >Chip writes:
> >> >Which is what you have to do if you're lexing.
> >>
> >> Yes, quite. So it was a bit of a slowdown for that purpose.
> >> OTOH, it was only a _bit_, not the absurd factor mentioned earlier.
> >
> >Yeah, sure, because you say so.
>
> Well, yes, I have committed the sin of not including benchmarks.
> However, given all the malloc'ing and freeing that Perl does, it
> stretches my credulity to believe that _one_ malloc/free, of the
> size of the match (not the size of the target), can be that much
> of a factor in performance.
You do not need to believe anything. The guy who found this 10000x
slow-down in a real application created a short demo which showed 100x
slowdown. This demo was sent to you, and it was you who analysed the
behaviour and found the reason in your faulty patch.
> I'm not claiming complete knowledge of 5.004's regex performance.
> I *am* claiming that if something slowed way down, this ain't it.
Then unclaim it.
Ilya
P.S. Of course the malloc *is* the size of the target (not the size
of the match), otherwise $', $` would not work.
------------------------------
Date: Fri, 30 Jan 1998 11:27:49 +1100
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: How can I set enviroment variables on Win32?
Message-Id: <34D11E84.8F05179@spider.herston.uq.edu.au>
This kind of thing is often discussed in FAQs on NT logon scripts.
There are little utility programs that let you set environment variables
in the various environments that proliferate under Windows. One of them
is called SETENV, which I think is the Win16 version.
On one of the Windows 95 CD's here (the one with "PLUS" written on it)
there is a programmed called WINSET in the \admin\apptools\envvars
directory that does the same thing for Win32.
--
Jaime Metcher
Jamie O'Shaughnessy wrote:
>
> On 14 Jan 1998 09:19:46 GMT, "Xaver Weibel" <nweibx@abs.ascom.ch> wrote:
>
> >How can I set enviroment variables on Win32?
> >nweibx@abs.ascom.ch
>
> That depends on what you mean by set :)
>
> If you want to set the env var within your script and for any programs you call
> from within your script (e.g. by doing a system()) - just add/set the env var
> in %ENV, e.g.
> $ENV{new_var} = "value";
>
> If you want to set the env var in *future* command prompts then you can set the
> env var in the registry (using Win32::Registry). The env vars are stored in:
> \\HKEY_CURRENT_USER\\Environment
>
> Some example code to set an env var in the registry is:
>
> use Win32::Registry;
> my $regkey;
> $HKEY_CURRENT_USER->Open('Environment', $regkey) || die;
> $regkey->SetValueEx("env_var_name", &NULL, ®_SZ, "value");
> $regkey->Close();
>
> You get my drift. This only works on NT as 95 doesn't store env vars in the
> registry. For 95 you have to alter autoexec.bat.
>
> If you want to alter the env vars within the shell/program that called your
> perl script, this is a different matter. The only way I've found to do this is
> to write out a temporary file from within your perl script, and then execute
> this as a batch file, e.g.
>
> @rem = 'Perl Script Wrapper';
> @rem = '
> set CMD=%0
> set ARGS=
> :loop
> if .%1==. goto endloop
> set ARGS=%ARGS% %1
> shift
> goto loop
> :endloop
> perl.exe -S %CMD% %ARGS%
> if exist %temp%\shellenvs.bat call %temp%\shellenvs.bat
> if exist %temp%\shellenvs.bat del %temp%\shellenvs.bat
> goto endofperl
> @rem ';
>
> # this is where the perl starts!!!
> my $tempfile = $ENV{TEMP} . "\\shellenvs.bat";
> open(BATFILE, "> $tempfile") || die;
> print BATFILE "set THISVAR=VALUE\n";
> close(BATFILE);
>
> __END__
> :endofperl
>
> Save all of the above in a .bat file and it should work. Note the couple of
> lines at the top of the .bat bit that calls the shellenvs.bat - this is the
> script your perl script will generate and it's in here that you issue the shell
> "set" commands to set the env vars.
>
> All of the above methods work and I use them in a number of scripts we use
> daily.
>
> Hope that helps,
> Jamie
>
> ___________________________________________________________________________
> Jamie O'Shaughnessy Work: joshaugh @ uk.oracle.com
> Oracle C++ Object Layer Generator Team
> ______________________________________________________ __ __ _ __ . __
> Opinions expressed here are my own and not those of... (__)|-</-\(__ |__ -_
------------------------------
Date: Thu, 29 Jan 1998 20:26:06 -0500
From: "Kelby Valenti" <kelby@mplx.com>
Subject: How do I copy files
Message-Id: <6arabq$6lg@aaron.hamilton.edu>
I would like to create a temp file that I can look over to make sure all the
information is correct. Once this is verified, I want to copy the temp file
over the original. I could also do this by renaming my temp file as the
original. If anyone has any suggestions please let me know. Preferably
e-mail me at kelby@mplx.com.
Thank you,
Kelby
------------------------------
Date: Thu, 29 Jan 1998 22:17:01 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: How do I copy files
Message-Id: <comdog-ya02408000R2901982217010001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6arabq$6lg@aaron.hamilton.edu>, "Kelby Valenti" <kelby@mplx.com> posted:
>I would like to create a temp file that I can look over to make sure all the
>information is correct. Once this is verified, I want to copy the temp file
>over the original. I could also do this by renaming my temp file as the
>original. If anyone has any suggestions please let me know. Preferably
>e-mail me at kelby@mplx.com.
rename() perhaps?
or File::Copy?
or is you like lots of work, open()?
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Thu, 29 Jan 1998 21:59:12 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: How do you make the something case-insensitive?
Message-Id: <comdog-ya02408000R2901982159120001@news.panix.com>
Keywords: from just another new york perl hacker
In article <Pine.BSI.3.96.980129165312.17002A-100000@xanadu.io.com>, Chocolate <poohba@io.com> posted:
>I have this form and I want to be able to search but I want the case to be
>insensitive. How do I do this?
how are you searching it? perhaps the i modifier on the m// operator
would be useful? or maybe lc() or uc()?
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Thu, 29 Jan 1998 22:08:03 -0500
From: Seokwon Yang <seyang@cise.ufl.edu>
Subject: How to invoke the process through netscape ?
Message-Id: <34D14413.2986@cise.ufl.edu>
Hi!
I have a perl script that invoke several prcocess in sequence.
What I want to do now is to divide this script into several and
call these through nestcape. I heard I can do it using CGI.
So, I made the following file.
----------------------------------------------------------------
use CGI;
&Print_Html_Top("JMDP DEMO");
print "<PRE>\n";
system "/cis/homes/sharma/public_html/demo/SIGMOD97/Java/proxy lightning
&";
system "/cis/homes/sharma/public_html/demo/SIGMOD97/Java/agent &";
system "sleep 5";
print "PLEASE CLICK ON FINISH DEMO AFTER DEMONSTRATION\n</PRE>";
&Print_Html_Bottom();
sub Print_Html_Top {
local($TITLE_STRING) = @_;
print ("Content-type: text/html\n\n");
print ("<HTML><HEAD>\n<TITLE> $TITLE_STRING </TITLE>\n");
print ("</HEAD><BODY>\n");
}
sub Print_Html_Bottom {
print ("</BODY></HTML>\n");
}
exit;
-----------------------------------------------------------------
But, after invoking two process, the netscape does not get answer and
wait with a watch icon indefinitly until I kill the processes through
the terminal.
Any one know why? Is there any better way or example that I can
look at to do what I want to do? If you knows, let me know.
I appreciate your help in advance.
------------------------------
Date: 30 Jan 1998 00:48:34 GMT
From: marc@offline.be (Marc Duponcheel)
Subject: howto find out if $x is a blessed reference (object)
Message-Id: <886122035.476500@many-brew.cisco.com>
Is it possible for a $x to know if it is an object?
ref $x tells me if it is a reference
and $x->isa(Class) tells me if it is an object of class Class
I wonder if there is a simple foolproof way to know if
$x is a blessed reference (in other words an object).
I am writing a module Exception which is based on what
I read in the manpages and in exception.pl but which
throws and catches any kind of thing.
So if you catch a A and a B was thrown where B isa A then
$a->handle() would handle B's method (like in C++).
It works fine but a bit restricted in that I want to allow
throwing of other things than objects only. In fact one
can already throw anything but I don't know very well what
to do with them if I catch non objects.
For example throw(1) or throw([]). Somewhere in the code
I use $e->isa(X) but then I want to be sure $e is an object.
I think I could hack a 'sub obj($);' which would have
obj $x = 1 <=> $ is an object
but I am sure real gurus would write something better.
In fact, maybe perl should provide the answer itself with a
perlfunc (if so sorry I don't know which one), or with some
equivalent of the UNIVERSAL module.
Thanks for any help.
--
Marc Duponcheel
marc@offline.be [home]
mduponch@cisco.com [work]
------------------------------
Date: Thu, 29 Jan 1998 21:47:13 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: howto find out if $x is a blessed reference (object)
Message-Id: <comdog-ya02408000R2901982147130001@news.panix.com>
Keywords: from just another new york perl hacker
In article <886122035.476500@many-brew.cisco.com>, marc@offline.be (Marc Duponcheel) posted:
>Is it possible for a $x to know if it is an object?
>
>ref $x tells me if it is a reference
>and $x->isa(Class) tells me if it is an object of class Class
>
>I wonder if there is a simple foolproof way to know if
>$x is a blessed reference (in other words an object).
did you check the return value of ref? or did you want something
different?
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Thu, 29 Jan 1998 21:48:51 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: HTML/CGI to play midi file?
Message-Id: <comdog-ya02408000R2901982148510001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6ar1pl$kdp$1@hermes.seas.smu.edu>, "Scott Norris" <snorris@post.cis.smu.edu> posted:
>Location: ~~~~~~~~~~
>
>However, that gives me the
>"you have started to download a file of type .mid: save it or open it?"
>option.
this is a server configuration issue, or a CGI/HTTP issue if you
are handling the transaction yourself. check the CGI Meta FAQ.
if your questions are not answered by any of those references, then
a post to a newsgroup that deals with servers of CGI may be
warranted.
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Thu, 29 Jan 1998 20:18:41 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: IP Address as new File
Message-Id: <34D12A71.3DF2C5BF@coos.dartmouth.edu>
Tom Phoenix wrote:
>
> What warning message would that be? I don't get one with this code running
> under 5.004_04:
>
> #!/usr/bin/perl -w
>
> use strict;
>
> my $remote_address = 'some-remote-address';
> my $url = 'some-URL';
>
> open TEMP_FILE, ">&STDOUT" or die "Can't dup STDOUT: $!";
> print TEMP_FILE ("$remote_address|$url\n"); # Jason's
> print(TEMP_FILE "$remote_address|$url\n"); # Tad's
>
> Did earlier versions of Perl warn about something here?
Oops!
print (FILE "foo"), "bar";
will cause a warning, but neither of these will:
print FILE ("foo");
print (FILE "foo");
Sorry about that!
Chipmunk
------------------------------
Date: Thu, 29 Jan 1998 07:58:50 +0100
From: Lutz Albers <lutz@muc.de>
Subject: Re: OLE and MS Word on NT
Message-Id: <34D028A9.2EDECEF2@muc.de>
David Greaves wrote:
> Hi
> I'd like to run an MS Word Macro (doc->html) from perl without actually
> launching Word.
> That is I'd like it to run quietly in the background on a web server.
>
> I know perl's got OLE.. capabilities so I kinda hoped...
It should work, but ... It WILL start word, albeit without the interface.
The only thing you need is Word's object model to automate it.
ciao
lutz
--
Lutz Albers, lutz@muc.de
Do not take life too seriously, you will never get out of it alive.
------------------------------
Date: Thu, 29 Jan 1998 22:02:53 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl connection to Informix
Message-Id: <comdog-ya02408000R2901982202530001@news.panix.com>
Keywords: from just another new york perl hacker
In article <34D0E7DD.7E0D@iname.com>, Ravi Krishna <rkrishna@iname.com> posted:
>This is the first time I am posting in this group , so pardon me if
>I this is not the right forum to ask this question.
>
>I want to know the site from where I can download DBperl or its
>equivalent for perl to informix connection.
see the DBI module on CPAN. follow the instructions in the docs.
you might also want to see the article by Alligator Descartes and
TIm Bunce in The Perl Journal #5 [1]
good luck. :)
[1]
The Perl Journal
<URL:http://www.tpj.com>
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Thu, 29 Jan 1998 22:13:14 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: perl script -> secure webpage
Message-Id: <comdog-ya02408000R2901982213140001@news.panix.com>
Keywords: from just another new york perl hacker
In article <34d088c1.173402671@news.dircon.co.uk>, alex@online.emap.com (alex) posted:
>Is there anyway in which to create a perl script and the output from
>that page be displayed as a secure web page?
use a secure server. despite the fact that "perl" appears in the
question, this is not a perl question, since the same answer would
be given despite the language used.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Fri, 30 Jan 1998 03:11:33 +0000
From: Omega User 2 <omg2@hrzsp1.horizon.waii.com>
Subject: Re: Problems converting Bourne shell to Perl
Message-Id: <34D144E5.41C6@hrzsp1.horizon.waii.com>
Steve Bourgeois wrote:
>
> I've been going nuts with this one.
>
> In Bourne shell, I can do the following to pass info to a command:
>
> COMMAND <<_EOF_
> line 1
> line 2
> ...
> _EOF_
>
> How can I do this in Perl? The Perl "here document" functionality
> seems similar, but it doesn't appear to work the same way.
>
> Any info would be appreciated,
>
> Steve (sbourgeo@ici.net)
Hi, Steve
print <<EOF;
line1
...
EOF
should do the job. Just the semicolon was missing...
Marko Kind
------------------------------
Date: Thu, 29 Jan 1998 13:52:32 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: regex with variables?
Message-Id: <0mmqa6.7o8.ln@localhost>
Doug (doug@1dlabs.com) wrote:
: I am writing an index/search engine on NT perl 5. I have a text
: file which hold two fields. The first is a url and the second is a
: list of keywords on the urls page. So something like the following:
: http://webserver/home/usr1:books mountains bread money
: The text file hold a list of all the urls on the website and the
: associated keywords. I have an html form which allows the user to
: select directories to search (such as usr1, usr2, usr3, etc.). The
: search area is passed to the perl script in the usual way by the form.
: Based on the search area I want to open the text file and grep for
: lines containing the correct directory.
: $searchaarea = "http:\/\/webserver\/home\/usr1";
$searchaarea = 'http://webserver/home/usr1';
That gets exactly the same string into the variable, but is easier
to understand. Slashes are not "special" in strings, they do not
need to be escaped.
(I only use double quotes when I want variable interpolation or
backslash "escapes". I always use single quotes for literal strings)
: @linesfromfile = grep /^$searcharea/, <INPUTFILE>;
You probably want to throw in a quotemeta() type of thing there,
else $searcharea='machine.domain.com' would allow 'machinesdomain.com'
to match...
You might also want to include the colon, else $searcharea='http.../foo'
would allow 'http.../foobar' to match...
@linesfromfile = grep /^\Q$searcharea:/, <INPUTFILE>;
^^ ^
: And the result should be the @linesfromfile should contain all lines
: from the INPUT file that start with http://webserver/home/usr1
http://webserver/home/usr1/subdir
would also make its way into the array as you have it written.
Maybe that's what you want? Maybe not?
: The searcharea variable will change on each search so it can't be hard
: coded.
: Can someone please give me some advice on getting this to work, or
: possibly another solution?
Sounds like it should work fine the way you have described.
Are you having some kind of problem with implementing it?
I don't really see any problem or question to be answered here...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 30 Jan 1998 02:42:56 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: regex with variables?
Message-Id: <6areng$l0i$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tad McClellan
<tadmc@flash.net>],
who wrote in article <0mmqa6.7o8.ln@localhost>:
> : $searchaarea = "http:\/\/webserver\/home\/usr1";
>
>
> $searchaarea = 'http://webserver/home/usr1';
>
> That gets exactly the same string into the variable, but is easier
> to understand. Slashes are not "special" in strings, they do not
> need to be escaped.
Slashes are not "special" anywhere. On the other hand, they can be
made special in strings as well:
$searchaarea = qq/http:\/\/webserver\/home\/usr1/;
This is just the corrolary of the used delimiter.
It is not very fortunate that the m-less form /blah/ (and - gasp -
?blah?) is accepted as tolerable...
Ilya
------------------------------
Date: Thu, 29 Jan 1998 21:20:21 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: regexes: fun with /x
Message-Id: <34D138E5.B2D5C8A6@coos.dartmouth.edu>
Okay, let me try one more time:
We know that /x allows the programmer to add whitespace
and comments to a regex.
So, let's say we have a regex, call it Rx, that has
unescaped whitespace and/or comments embedded in it.
Now, take that regex, drop the /x modifier, and remove
all the unescaped whitespace and comments, resulting in
regex R.
Gnerally, Rx and R may be used interchangeably, as /x does
not change the meaning of the regex.
However, there are some choices for Rx that will result in
an R which cannot be used in a Perl program.
I have such an Rx in mind. Can anyone else come up with one?
Chipmunk
------------------------------
Date: 30 Jan 1998 02:45:42 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: regexes: fun with /x
Message-Id: <6aresm$l0i$2@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Chipmunk
<rjk@coos.dartmouth.edu>],
who wrote in article <34D138E5.B2D5C8A6@coos.dartmouth.edu>:
> So, let's say we have a regex, call it Rx, that has
> unescaped whitespace and/or comments embedded in it.
>
> Now, take that regex, drop the /x modifier, and remove
> all the unescaped whitespace and comments, resulting in
> regex R.
>
> Gnerally, Rx and R may be used interchangeably, as /x does
> not change the meaning of the regex.
>
> However, there are some choices for Rx that will result in
> an R which cannot be used in a Perl program.
>
> I have such an Rx in mind. Can anyone else come up with one?
I repeat that if you know such, please repost it as a bug. How much
more of our time you are ready to spend?
Ilya
------------------------------
Date: Thu, 29 Jan 1998 22:23:29 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: regexes: fun with /x
Message-Id: <comdog-ya02408000R2901982223290001@news.panix.com>
Keywords: from just another new york perl hacker
In article <34D138E5.B2D5C8A6@coos.dartmouth.edu>, rjk@coos.dartmouth.edu posted:
>So, let's say we have a regex, call it Rx, that has
>unescaped whitespace and/or comments embedded in it.
>Now, take that regex, drop the /x modifier, and remove
>all the unescaped whitespace and comments, resulting in
>regex R.
basically do the x processing manually?
>Gnerally, Rx and R may be used interchangeably, as /x does
>not change the meaning of the regex.
the regex method that i demonstrated will behave differently
if the x modifier is not set. are you assuming that you
know the pattern at compile time?
>However, there are some choices for Rx that will result in
>an R which cannot be used in a Perl program.
do you mean that the R regex will lead to a syntax error?
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Thu, 29 Jan 1998 22:24:23 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: regexes: fun with /x
Message-Id: <34D147E7.FA3E7965@coos.dartmouth.edu>
brian d foy wrote:
>
> In article <34D138E5.B2D5C8A6@coos.dartmouth.edu>, rjk@coos.dartmouth.edu posted:
>
> >So, let's say we have a regex, call it Rx, that has
> >unescaped whitespace and/or comments embedded in it.
>
> >Now, take that regex, drop the /x modifier, and remove
> >all the unescaped whitespace and comments, resulting in
> >regex R.
>
> basically do the x processing manually?
Yes.
> >Gnerally, Rx and R may be used interchangeably, as /x does
> >not change the meaning of the regex.
>
> the regex method that i demonstrated will behave differently
> if the x modifier is not set. are you assuming that you
> know the pattern at compile time?
It will behave differently because it still has the whitespace
and comments in it. Therefore, it does not fit the definitions
of Rx and R I supplied above, which specify that you should
remove the whitespace and comments. :-)
> >However, there are some choices for Rx that will result in
> >an R which cannot be used in a Perl program.
>
> do you mean that the R regex will lead to a syntax error?
I was trying not to make it so obvious. :-)
Chipmunk
------------------------------
Date: Thu, 29 Jan 1998 21:54:00 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Retrieving remote page using CGI Script
Message-Id: <comdog-ya02408000R2901982154000001@news.panix.com>
Keywords: from just another new york perl hacker
In article <886115193.1961033729@dejanews.com>, marlontan@netasia.net posted:
> Good day! My question is: How do you retrieve (save to local drive) a
>remote homepage to the local hardrive without using the save menu of your
>browser (by using program code)?
use LWP;
> If the page I want to save is just generated by a CGI Script, it means
>that the page is "physically" not there (am I right?), and I want to
>retrieve that file, how do we do that?
the concept of "page" or "file" or "physically" is kinda wierd.
you shouldn't have to worry about howthe data comes into being if
you just do what HTTP tells you to do. and, since you have decided
to use LWP, you don't even have to worry about that.
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Thu, 29 Jan 1998 22:04:18 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Seeking Search Engine Code
Message-Id: <comdog-ya02408000R2901982204180001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6aqbfq$eij@news1.infinet.com>, badger@infinet.com (Steven Savage) posted:
>I am seeking out free, pre-existing PERL code for a simple CGi search
>engine. Any sources/advice are appreciated - please email
>badger@infinet.com.
see the previous responses [1] to this same question.
[1] use a search engine like <URL:http://www.dejanews.com> to find
out how to use a search engine to find a search engine.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Thu, 29 Jan 1998 22:09:43 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Some possible bugs
Message-Id: <comdog-ya02408000R2901982209430001@news.panix.com>
Keywords: from just another new york perl hacker
In article <34D0B5A0.52FF@mail.delcoelect.com>, "V. Chandrasekhar" <vchandra@mail.delcoelect.com> posted:
>1. I am working with the following version of perl:
>
>Version 4.0 Patch Level 36 1993/02/05
>
>2. I noticed some problems - these are described below.
>I am not sure whether I should try and get perl version
>upgraded rather than worrying about the problems of this
>version.
you can't complain about bugs if you refuse to upgrade. to
something modern. :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Thu, 29 Jan 1998 21:40:37 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: Split
Message-Id: <34D13DA5.47F53893@coos.dartmouth.edu>
Zachary Brown wrote:
>
> In article <34D01E38.734AE2A1@coos.dartmouth.edu>,
> Chipmunk <rjk@coos.dartmouth.edu> wrote:
> >Zachary Brown wrote:
> >> Moshe Aaron Allen <moshea@jen.co.il> wrote:
>
> >> > I'm need to split() a pararaph after every five words. Can anyone help?
> >>
> >> $paragraph =~ s/(\s.*?\s.*?\s.*?\s.*?\s.*?)/$1\n\n/g;
> >
> >Non-greedy quantifiers are definitely not what you want to use here.
> >In particular, that last .*? will *never* match anything.
> >The other .*?'s will be happy to match nothing, allowing the entire regexp
> >to match something as simple as " " (five spaces).
>
> I have to agree. The line I poseted is flawed in that way. But I tested
> it before I posted it, and it worked! I used the following program:
>
> $paragraph = "Now is the time for all good men to come to the aid of their party. [snipped]";
> $paragraph =~ s/(\s.*?\s.*?\s.*?\s.*?\s.*?)/$1\n\n/g;
> print $paragraph;
>
> Well? What's going on?
It worked for the one string you tested it on. In particular, you didn't test
it on
a string with runs of multiple spaces. It would not work correctly in that case.
Essentially, what your code does is insert two newlines after every five
*whitespace characters*, not words.
And although you can use '.*?' to match non-whitespace characters, it's faster and
easier to use '\S*'.
Chipmunk
------------------------------
Date: 30 Jan 1998 00:41:42 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Where are all the scripts?
Message-Id: <slrn6d2856.9h3.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Ray Schultz <ray@uh.edu> wrote :
# I would think, given the 3free2 atmosphire around perl, that there would
# be a place where one could go and get already written perl scripts. You
# know, 3Why reinvent the wheel2, if it has already been written why write
# it again. So the question is where is that place? FTP? WEB? Or what?
www.perl.com/CPAN/
gabor.
--
I've heard that there is a shell (bourne or csh) to perl filter, does
anyone know of this or where I can get it?
Yeah, you filter it through Tom Christiansen. :-)
-- Larry Wall
------------------------------
Date: Thu, 29 Jan 1998 22:10:39 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Where are all the scripts?
Message-Id: <comdog-ya02408000R2901982210390001@news.panix.com>
Keywords: from just another new york perl hacker
In article <ray-2901981107120001@mathkit1.coe.uh.edu>, ray@uh.edu (Ray Schultz) posted:
>I would think, given the 3free2 atmosphire around perl, that there would
>be a place where one could go and get already written perl scripts. You
>know, 3Why reinvent the wheel2, if it has already been written why write
>it again. So the question is where is that place? FTP? WEB? Or what?
i've answered this question so many times that i now answer it in
every post by the inclusion of my .sig
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
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 1766
**************************************