[10627] in Perl-Users-Digest
Perl-Users Digest, Issue: 4219 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 14 11:07:12 1998
Date: Sat, 14 Nov 98 08:00:17 -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 Sat, 14 Nov 1998 Volume: 8 Number: 4219
Today's topics:
Re: bookpool: sale on o'reilly (SKotha)
BUILDING BLOWFISH IN PERL fantastic2@my-dejanews.com
Building IP packets socket() <lspitz@enteract.com>
can't build 5.005 with Threads on Solaris <rjberman@mindspring.com>
Re: Double pipe question <mkahn@vbe.com>
Help building "NewsWolf" w/MacPerl HTTP? (Jorn Barger)
Re: Help on use strict please <r28629@email.sps.mot.com>
Re: How to access a file within a perl program (Peter J. Kernan)
Re: Installing a Perl module to Active Perl (Damon Register)
Re: Installing a Perl module to Active Perl <perlguy@technologist.com>
Installing Perl modules ppp:vdkamp@inter.nl.net@inter.nl.net
need help with lex program <mbowron@atlis.com>
Re: OOP or not? (for a Perl module) (David Formosa)
Re: Perl equiv of java showDocument()? (Hywel Jenkins)
Re: pwd without backticks? (Ilya Zakharevich)
Re: Q: are symbolic refs really needed (was Re: Modific (Bart Lateur)
recursion puzzle <jaudall@students.wisc.edu>
Re: recursion puzzle <dgris@moiraine.dimensional.com>
Re: recursion puzzle <uri@sysarch.com>
SIMPLE BLOWFISH IN PERL? (Alex M)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Nov 1998 07:41:14 GMT
From: skotha@aol.commail (SKotha)
Subject: Re: bookpool: sale on o'reilly
Message-Id: <19981114024114.23063.00001659@ng13.aol.com>
Though I have reservations about endorsing a commercial venture in a news group
like this, I still going ahead and doing this because I have been very
impressed by book pool. I found it to be very good in its pricing or rather
discounting. And surprisingly their shipping and handling is the lowest I have
seen on the net.
>hey only do computer boks so they usually have a broader
> selection than the biggies.
That's a bit exaggerated ...
--Vasu
NB: Please use my email address after deleting the word 'mail' from it
--------------------------------------------------------------------------
--------
"Always complete your actions." --Deng Ming-Dao
------------------------------
Date: Sat, 14 Nov 1998 14:02:56 GMT
From: fantastic2@my-dejanews.com
Subject: BUILDING BLOWFISH IN PERL
Message-Id: <72k2ig$9g7$1@nnrp1.dejanews.com>
I am having an argument with a friend at work about using Blowfish decryption
with PERL.
He says that you need to download some stupid module to do it, and I say that
BLOWFISH could be built using basic PERL command without having to use a
separate module.
My reasoning is that decryption is much quicker than encryption (if you have
the key) and that it just boils down to some math functions that PERL can
handle all on its own.
Has anyone actually built the Blowfish decryption into a single script? I
checked CPAN and all I can find are modules.
Thanks in advance for your help. You can respond here or to me directly at
fantastic2@hotmail.com.
-- Alex
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sat, 14 Nov 1998 00:04:15 -0600
From: Lance Spitzner <lspitz@enteract.com>
Subject: Building IP packets socket()
Message-Id: <Pine.BSF.3.96.981113235940.21432A-100000@adam.enteract.com>
I am attempting to build my own IP packets
using socket(S, AF_INET, SOCK_RAW, $PROTO_RAW).
I would greatly appreciate if anyone could send
me come copies of their code on how to build
your own TCP/UDP/ICMP packets. I'm looking to
build IP packets that systems will respond to.
Thanks!
Lance
------------------------------
Date: Sat, 14 Nov 1998 09:41:38 -0500
From: Bob Berman <rjberman@mindspring.com>
Subject: can't build 5.005 with Threads on Solaris
Message-Id: <364D964B.7BA574E5@icehouse.com>
I have built Perl several dozen times, so I think I know what I'm doing, but
at least on my Solaris system, I can't get thread support to work. I read all
the READMEs, etc. with the 5.005 release and ran Configure with -Dusethreads.
All the Makefiles which are generated seem to have -DUSE_THREADS in them, which
is good. And the whole perl build works fine and creates a perl executable. The
make test step, of course seems to fail on several tests, but that looks like it
can't find some .pm modules like Data::Dumper, and IPC. I got the same errors in
make test during builds on HP-UX and Linux. It's probably a common problem.
Anyway, I installed what I built, and then tried to get the ext/Thread/create.t
test to run:
68-> cd ext/Thread/
69-> perl create.t
Can't locate loadable object for module Thread in @INC (@INC contains:
/opt/perl/lib/sun4-solaris/5.00502 /opt/perl/lib
/opt/perl/lib/site_perl/sun4-solaris /opt/perl/lib/site_perl .) at create.t line
1
BEGIN failed--compilation aborted at create.t line 1.
Well, I checked @INC myself and couldn't find Thread.pm either. So I tried to
build it manually in ext/Thread and got:
112-> perl -v
This is perl, version 5.005_02 built for sun4-solaris-thread
Copyright 1987-1998, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
113-> perl Makefile.PL
Writing Makefile for Thread
114-> make
gcc -c -O -DVERSION=\"1.0\" -DXS_VERSION=\"1.0\" -fpic -I../.. Thread.c
Thread.xs: In function `XS_Thread_yield':
Thread.xs:465: `YIELD' undeclared (first use in this function)
Thread.xs:465: (Each undeclared identifier is reported only once
Thread.xs:465: for each function it appears in.)
*** Error code 1
make: Fatal error: Command failed for target `Thread.o'
Can anyone help me?? What can I do?
------------------------------
Date: Sat, 14 Nov 1998 07:23:53 -0600
From: Mark Kahn <mkahn@vbe.com>
Subject: Re: Double pipe question
Message-Id: <364D8469.8ADCDABE@vbe.com>
Matt,
Please check the FAQ's. From perlfaq5:
=head2 How can I open a pipe both to and from a command?
The IPC::Open2 module (part of the standard perl distribution) is an
easy-to-use approach that internally uses pipe(), fork(), and exec() to
do
the job. Make sure you read the deadlock warnings in its documentation,
though (see L<IPC::Open2>). See L<perlipc/"Bidirectional Communication
with Another Process"> and L<perlipc/"Bidirectional Communication with
Yourself">
You may also use the IPC::Open3 module (part of the standard perl
distribution), but be warned that it has a different order of
arguments from IPC::Open2 (see L<IPC::Open3>).
(P.S.: Thanks for the great docs _again_ TC).
--
Mark Kahn
mkahn@vbe.com
------------------------------
Date: Sat, 14 Nov 1998 08:46:49 -0500
From: jorn@mcs.com (Jorn Barger)
Subject: Help building "NewsWolf" w/MacPerl HTTP?
Message-Id: <1dih4nw.1py5xgu1mquns8N@jorn.pr.mcs.net>
I need some help getting started with MacPerl, coding an app that can
build me a custom newspaper from items on many different sites.
Most users will probably run it once a day, but this shouldn't be
required-- more frequently will be fine, less frequently will be okay.
It will look over a list of news sites, detect new content, download it,
*reformat it*, save it, and generate a running table of contents.
It's the reformatting that I find most challenging/ interesting.
I want it to scan each html file for tags, and pattern-match these to
see if they (and/or their associated text) can be trimmed entirely, or
relocated, or renamed, or left as-is.
Articles broken up over several pages will be automatically re-knit into
a continuous page. Banner ads and other obnoxious clusters of links
will be quietly dropped. Multiple columns will be eliminated.
Footnotes will be moved into the body of the text, in square brackets.
To make this work smoothly, NewsWolf will need to build a database of
predictable patterns for a given site-- what do its 'Next' buttons look
like, for example.
When a site's format changes (or on first visiting a new site), NewsWolf
should offer some kind of form that guesses which patterns are which,
but makes it easy to correct bad guesses.
And eventually, it should learn to spot my favorite keywords. For
example, when it goes to www.newshub.com it could re-sort those zillion
headlines into categories (Iraq, Monica, somebody-killed-somebody-
somewhere, something-big-blew-up-or-crashed), and only pre-fetch the
ones I've pre-specified, maybe offering the rest in a checklist format.
I expect lots of people have wanted this, so it seems like an ideal
group project, I hope. And it will neatly bypass the XML-standards
bottleneck by looking elsewhere for its semantic cues.
I'm a newbie, to the point where I don't even know how to make the basic
http request in MacPerl. Can the pattern-matching start before the
download is complete? What modules do I need to get started? (I'm using
System 8.1 and Open Transport 1.3, and just downloaded MacPerl 5.2.0r4.)
I'd been planning to do this in Frontier, but I recently realised Larry
was the genius behind 'rn', which makes him much more trustworthy in my
book! ;^/
j
--
I edit the Net: <URL:http://www.mcs.net/~jorn/html/weblogs/weblog.html>
"The real gem among his musings is the weblog, a detailed daily account
of Jorn's travels around the web. Watch a highly observant and
thoughtful web surfer at work." -- UK Guardian, 21 October 1998
------------------------------
Date: Sat, 14 Nov 1998 07:59:52 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: Rusty Williamson <rwilliamson@uno.gers.com>
Subject: Re: Help on use strict please
Message-Id: <364D7EC6.7AA43D2B@email.sps.mot.com>
[posted to c.l.p.m and copy emailed]
Rusty Williamson wrote:
>
> I am stumped!
> Im trying to establish a variable (in the main routine) whose value will
> be readily available to any functions/subroutines that are called. I think I
> understand the distinctions between global, my, and local variable
> scope, but Im having trouble implementing it when the use strict pragma
> is enabled.
.., but are you clear about 'use strict'? please 'perldoc strict' again to
make sure.
> The code shown below works as I would expect so long as the use strict
> line is commented out. If I uncomment it, I get the following errors:
> Global symbol G requires explicit package name at
> /home/jeb/transfer/jeb.pl line 3.
> Global symbol L requires explicit package name at
> /home/jeb/transfer/jeb.pl line 5.
> Execution of /home/jeb/transfer/jeb.pl aborted due to compilation errors.
> Can either of you point me in the right direction?
> Rusty
>
> #!/usr/local/bin/perl
> #use strict;
> $G = __LINE__ ;
^^
my $G = __LINE__ ; # with 'use strict'
[snip]
-tk
------------------------------
Date: 14 Nov 1998 07:08:40 GMT
From: pete@localhost.localdomain (Peter J. Kernan)
Subject: Re: How to access a file within a perl program
Message-Id: <72ja9o$mnn$1@pale-rider.INS.CWRU.Edu>
In article <4M732.11507$C5.6274499@wrenphoon1>,
mkanaga@hotmail.com (Murali Kanaga) writes:
>
> Greetings!
>
> I am new to Perl. I have to write a perl program which will search
> through
> the /etc/group file. When I type a user name (jdoe), the script will go
> through
> /etc/group file & find out which group jode is in.
>
> In order to do this, how can I read the file /etc/group from my perl
> script.
>
> I would really apprecitae any idea or input on this.
here is one way to get jdoe's pgrp
print "${ \((getgrgid((getpwnam(jdoe))[3]))[0])}\n";
but maybe that is not what you are after, hard to tell.
(you might also try % perldoc -f open)
--
open SIG, "<$ENV{HOME}/.sig" or die "sigless! $!";
$sig = do {local $/; <SIG>}; close SIG && print<<"$sig SIG";
Pete Kernan CWRU Physics and Statistics Depts
http://theory2.phys.cwru.edu/~pete
$sig SIG
------------------------------
Date: Sat, 14 Nov 1998 12:02:43 GMT
From: dregiste@bellsouth.net (Damon Register)
Subject: Re: Installing a Perl module to Active Perl
Message-Id: <36516e7c.37191442@news.atl.bellsouth.net>
On Thu, 12 Nov 1998 12:06:45 GMT, Brent Michalski
<perlguy@technologist.com> wrote:
>Go to:
>http://www.activestate.com/activeperl/docs/ppm.html
>
>I found what you were looking for within a minute on thier site! I too
Thanks for the info. Like you, I also found this info at the site
you listed. There is one flaw with this though. The only kind of
proxy server we have available is something called an automatic proxy
such as is supported by Netscape 4+. Most things using a proxy
don't work with this kind of proxy. I will have to wait until Monday
to try this but I am almost certain this method will not work.
>They have LOADS of documentation on thier site. I'd recommend using
That was the first place I went after not being able to find what I
needed on my own hard drive. In the Active Perl local documentation
the Welcome page has this text:
Are you having trouble installing modules from behind a firewall
through a proxy? This document shows how. It also tells how to
download packages directly via HTTP to store them in a local
repository, so you can use them on a machine with no internet
connection, or on networked machines without having to download
the modules for each install.
It is the second part of this that really interests me. Using
Netscape I can do the download of the necessary files and then
install them locally. The above mentioned ppm.html does not
mention this at all and I have not been able to find this anywhere
on their site.
Damon Reigster
------------------------------
Date: Sat, 14 Nov 1998 09:43:07 -0600
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: Installing a Perl module to Active Perl
Message-Id: <364DA50B.F93CFE0@technologist.com>
Damon Register wrote:
>
> Are you having trouble installing modules from behind a firewall
> through a proxy? This document shows how. It also tells how to
> download packages directly via HTTP to store them in a local
> repository, so you can use them on a machine with no internet
> connection, or on networked machines without having to download
> the modules for each install.
>
> It is the second part of this that really interests me. Using
> Netscape I can do the download of the necessary files and then
> install them locally. The above mentioned ppm.html does not
> mention this at all and I have not been able to find this anywhere
> on their site.
>
> Damon Reigster
I was able to install the modules from behind a firewall. I had to use
PPM 0.9 because 0.9.1 didn't seem to get any files. I have not done it
from a local directory.
I have heard, but not tested, that 0.9.1 *will* install the modules IF
you know the name, it seems to have trouble getting the list of
available modules though.
Brent
--
Java? I've heard of it, it is what I drink while hacking Perl! -me
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: 14 Nov 1998 14:48:43 GMT
From: ppp:vdkamp@inter.nl.net@inter.nl.net
Subject: Installing Perl modules
Message-Id: <72k58b$muj$1@news.Eindhoven.NL.net>
Hello Perl community,
Although I have a long time experience with Perl, I have no experience
with installing modules. But now I have to.
I want to use ANSIColor and Perlmenu. I copied the ANSIColor.pm file to
the path mentioned in INC. Then I try to run my Perl script. But it
stopped with the message "Undefined subroutine &main::color at..".
I think this message indicates that I have to recompile Perl with the
new modules? Or are there other ways? I also have the vague feeling
that .pm files are OS specific. Or not?
I work with Perl 5.004_55 (binary distribution) for OS/2 Warp 4.0.
Any help is appreciated.
Peter van der Kamp
------------------------------
Date: Tue, 10 Nov 1998 15:55:49 -0500
From: Mark Bowron <mbowron@atlis.com>
Subject: need help with lex program
Message-Id: <3648A855.15C4@atlis.com>
Hello,
A friend at work wants me to add some code to a simple Delphi/Pascal
program that takes an SGML file as input and outputs a list of all the
SGML tags. All he wants is the count for each tag. The program has lex
code in it and I've never done anything with lex.
If someone can either point me to a good, comprehensive online lex
reference (the ones I've seen have been inadequate for my needs), or
better yet, just add the code for me :-) (the program appears below),
I'd be grateful.
Mark Bowron
(* lexical analyzer template (TP Lex V3.0), V1.0 3-2-91 AG *)
(* global definitions: *)
PROGRAM CCSTags;
(***> revision history <***)
(***> revision history <***)
USES
Objects,
LexLib;
CONST
(****keyword-flag*** '0.%v' *)
VersionString = '';
(****keyword-flag*** '%f' *)
VersionTimeStamp = '';
nl = #10; (* newline character *)
cr = #13;
VAR
taglist: PStringCollection;
function yylex : Integer;
procedure yyaction ( yyruleno : Integer );
(* local definitions: *)
begin
(* actions: *)
case yyruleno of
1:
taglist^.Insert(NewStr(copy(yytext, 2, yyleng - 2)));
2:
;
3:
begin
if (yylineno mod 100) = 0 then write('[', yylineno, '] ');
if (yylineno mod 500) = 0 then writeln;
end;
end;
end(*yyaction*);
(* DFA table: *)
type YYTRec = record
cc : set of Char;
s : Integer;
end;
const
yynmarks = 4;
yynmatches = 4;
yyntrans = 9;
yynstates = 7;
yyk : array [1..yynmarks] of Integer = (
{ 0: }
{ 1: }
{ 2: }
2,
{ 3: }
2,
{ 4: }
3,
{ 5: }
{ 6: }
1
);
yym : array [1..yynmatches] of Integer = (
{ 0: }
{ 1: }
{ 2: }
2,
{ 3: }
2,
{ 4: }
3,
{ 5: }
{ 6: }
1
);
yyt : array [1..yyntrans] of YYTrec = (
{ 0: }
( cc: [ #1..#9,#11..';','='..#255 ]; s: 3),
( cc: [ #10 ]; s: 4),
( cc: [ '<' ]; s: 2),
{ 1: }
( cc: [ #1..#9,#11..';','='..#255 ]; s: 3),
( cc: [ #10 ]; s: 4),
( cc: [ '<' ]; s: 2),
{ 2: }
( cc: [ #1..'=','?'..#255 ]; s: 5),
{ 3: }
{ 4: }
{ 5: }
( cc: [ #1..'=','?'..#255 ]; s: 5),
( cc: [ '>' ]; s: 6)
{ 6: }
);
yykl : array [0..yynstates-1] of Integer = (
{ 0: } 1,
{ 1: } 1,
{ 2: } 1,
{ 3: } 2,
{ 4: } 3,
{ 5: } 4,
{ 6: } 4
);
yykh : array [0..yynstates-1] of Integer = (
{ 0: } 0,
{ 1: } 0,
{ 2: } 1,
{ 3: } 2,
{ 4: } 3,
{ 5: } 3,
{ 6: } 4
);
yyml : array [0..yynstates-1] of Integer = (
{ 0: } 1,
{ 1: } 1,
{ 2: } 1,
{ 3: } 2,
{ 4: } 3,
{ 5: } 4,
{ 6: } 4
);
yymh : array [0..yynstates-1] of Integer = (
{ 0: } 0,
{ 1: } 0,
{ 2: } 1,
{ 3: } 2,
{ 4: } 3,
{ 5: } 3,
{ 6: } 4
);
yytl : array [0..yynstates-1] of Integer = (
{ 0: } 1,
{ 1: } 4,
{ 2: } 7,
{ 3: } 8,
{ 4: } 8,
{ 5: } 8,
{ 6: } 10
);
yyth : array [0..yynstates-1] of Integer = (
{ 0: } 3,
{ 1: } 6,
{ 2: } 7,
{ 3: } 7,
{ 4: } 7,
{ 5: } 9,
{ 6: } 9
);
var yyn : Integer;
label start, scan, action;
begin
start:
(* initialize: *)
yynew;
scan:
(* mark positions and matches: *)
for yyn := yykl[yystate] to yykh[yystate] do yymark(yyk[yyn]);
for yyn := yymh[yystate] downto yyml[yystate] do yymatch(yym[yyn]);
if yytl[yystate]>yyth[yystate] then goto action; (* dead state *)
(* get next character: *)
yyscan;
(* determine action: *)
yyn := yytl[yystate];
while (yyn<=yyth[yystate]) and not (yyactchar in yyt[yyn].cc) do
inc(yyn);
if yyn>yyth[yystate] then goto action;
(* no transition on yyactchar in this state *)
(* switch to new state: *)
yystate := yyt[yyn].s;
goto scan;
action:
(* execute action: *)
if yyfind(yyrule) then
begin
yyaction(yyrule);
if yyreject then goto action;
end
else if not yydefault and yywrap then
begin
yyclear;
return(0);
end;
if not yydone then goto start;
yylex := yyretval;
end(*yylex*);
CONST
MaxPushBack = 2048;
MaxInSize = 60 * 1024;
VAR
yyinput: FILE;
inNdx: WORD;
bSize: WORD;
pushLen: WORD;
bufPtr: PChar;
pushBuf: PChar;
FUNCTION wrap_get_char : CHAR; FAR;
(* obtain one character from the input file (null character at
end-of-file) *)
VAR
res: CHAR;
PROCEDURE ProcessNL;
BEGIN
res := bufPtr[inNdx];
IF bufPtr[inNdx] = nl THEN BEGIN
inc(yylineno);
yycolno := 0;
END ELSE BEGIN
INC(yycolno);
END;
INC(inNdx);
END;
BEGIN
IF pushLen > 0 THEN BEGIN
DEC(pushLen);
res := pushBuf[pushLen];
END ELSE BEGIN
WHILE (inNdx < bsize) AND (bufPtr[inNdx] = cr) DO INC(inNdx);
IF inNdx < bsize THEN BEGIN
ProcessNL;
END ELSE BEGIN
inNdx := 0;
BlockRead(yyinput, bufPtr^, MaxInSize, bsize);
IF bsize = 0 THEN
res := #0
ELSE
ProcessNL;
END; (* IF *)
END; (* IF *)
wrap_get_char := res;
END;
PROCEDURE wrap_unget_char ( c : CHAR ); FAR;
(* return one character to the input file to be reread in subsequent
calls to get_char *)
BEGIN
pushBuf[pushLen] := c;
INC(pushLen);
END;
PROCEDURE Help;
BEGIN
WriteLn('SGMLTags [input file] [output file]');
WriteLn(' Searches the input file for all the SGML style tags and
prints');
WriteLn(' out a sorted, deduped list of all the tags.');
WriteLn;
WriteLn('Notes: currently the attributes are considered part of the
tag.');
END;
PROCEDURE ProcessCommandLine;
BEGIN
IF ParamCount <> 2 THEN Help;
Assign(yyinput, ParamStr(1));
Reset(yyinput, 1);
GetMem(pushBuf, MaxPushBack);
GetMem(bufPtr, MaxInSize);
inNdx := 0;
bsize := 0;
pushLen := 0;
get_char := wrap_get_char;
unget_char := wrap_unget_char;
END;
PROCEDURE PrintResults;
VAR
count: INTEGER;
fOut: TEXT;
PROCEDURE PrintOne(p: PString); FAR;
BEGIN
inc(count);
WriteLn(fOut, p^);
END;
BEGIN
Assign(fOut, ParamStr(2));
ReWrite(fOut);
count := 0;
taglist^.ForEach(@PrintOne);
Close(fOut);
WriteLn(count, ' tags');
END;
BEGIN
WriteLn('SGMLTags, Version: ', VersionString, ' (', VersionTimeStamp,
')');
WriteLn;
ProcessCommandLine;
taglist := NEW(PStringCollection, Init(100, 50));
yylex;
PrintResults;
END.
------------------------------
Date: 14 Nov 1998 13:02:33 GMT
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: OOP or not? (for a Perl module)
Message-Id: <slrn74qvr9.b9h.dformosa@godzilla.zeta.org.au>
In article <72hipb$r3f$1@saltmine.radix.net>, Michael Houghton wrote:
>Howdy!
>
[...]
> >The only bummer about that is I can't see how to avoid having to type
> >"$current" a thousand times in one composition ... it would be nice to
> >be able to assume $current unless otherwise specified...
> >
>CGI.pm allows you to do something like this.
There is rumered to exist a "ubermethods" module that allows $_ to be
used as a defult object for umethods where the object isn't given.
--
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
------------------------------
Date: Sat, 14 Nov 1998 12:01:13 -0000
From: UseNet@Hywel.Demon.CO.UK.CutThis (Hywel Jenkins)
Subject: Re: Perl equiv of java showDocument()?
Message-Id: <MPG.10b771623137b014989797@news.demon.co.uk>
[This followup was posted to alt.html and a copy was sent to the cited
author.]
In article <364CC2B2.9E6F86D@best.com>, bchapman@best.com said...
> In Java, there is a routine where you can say "replace the current html
> file with another one right now". It is called
> AppletContext.showDocument(url), for example,
>
> AppletContext.showDocument(new URL("http://www.yahoo.com"))
>
> Means go to yahoo.com, without the user having to do anything.
You could do this in two ways client-side:
1) Use this in the <HEAD> section:
<META HTTP-EQUIV="REFRESH" CONTENT="0;url=http://www.yahoo.co.uk/">
Which redirects to Yahoo! after 0 seconds. This relies on the browser
supporting the REFRESH jobbie, though.
2) Use JavaScript:
<script language="JavaScript">
<!--
top.location.href="http://www.yahoo.co.uk/";
//-->
</script>
This, of course, relies on the browser supporting JavaScript, and having
it enabled.
If you use either (or both) of these solutions you ought to have
something like this, too
This site has moved
<a href="http://www.yahoo.co.uk/" target="_top">here</a>
--
Hywel Jenkins
UK: "Make synchronised swimming more interesting. Put sharks in the pool."
Rest: "Make synchronized swimming more interesting. Put sharks in the pool."
http://www.hywel.demon.co.uk/
http://www.hywel.demon.co.uk/Support/
[Remove ".CutThis" from address to mail reply]
------------------------------
Date: 14 Nov 1998 07:16:51 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: pwd without backticks?
Message-Id: <72jap3$mgk$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Uri Guttman
<uri@sysarch.com>],
who wrote in article <x7r9va9mob.fsf@sysarch.com>:
> >>>>> "T" == Thomas <nouser@nohost.nodomain> writes:
>
> T> If this kind of thing matters to a UNIX program, it should know how to
> T> deal with it. In modern versions of UNIX, in the presence of NFS
> T> automounts and symlinks, in fact, there are lots of other potential
> T> problems callers of "pwd" have to deal with anyway.
>
> thanx for the backup. i thought ilya was way off with the claim that pwd
> runs suid many places. as you said, historically it has never been an
> guaranteed operation. even perl's Cwd module has 3 methods which differ
> in how they attempt to do it. and your example of breaking even a suid
> pwd is good. as i said and you agree, "caveat programmer".
a) I was only repeating was told on p5p years ago;
b) There is a *great* difference with breaking when no valid answer is
possible (as when some directory is unlinked), and breaking when
there is a useful answer which is easy to find (as with unreadable
directories).
Ilya
------------------------------
Date: Sat, 14 Nov 1998 10:54:09 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: Q: are symbolic refs really needed (was Re: Modification of a read-only??)
Message-Id: <364d5863.150549@news.skynet.be>
Uri Guttman wrote:
> BL> Can't you do that using eval?
>
> BL> eval "\$$Packagename\::$VarName = \"Some Value\"";
>
>too slow! can't do that for all imports.
Are you guessing, or do you have evidence to back you up?
Since 'use' is based upon 'require' which is based upon 'do (file)'
which is based upon 'eval', it should compare very favorably to pulling
in a module of 160k (like CGI.pm), if you combine all your statements in
one string before evalling. My guess. :-)
This looks very safe to me:
eval join(";\n", map { "\$$Packagename\::$_ = \$assign{'$_'}" }
keys %assign);
where the %assign (may be 'my'-ed) contains al the imports you want, in
the format ( varname => $value ), and assuming $Packagename is the same
for all. Note the backslash in front of the hash value on the right,
which avoids quoting problems.
Tom Phoenix wrote:
>Symbolic references are generally merely troublesome. eval (of a string)
>is outright dangerous.
In really controlled situations, like this one, I can't see any danger.
Maybe I'm overlooking something. :-)
Besides, eval is less troublesome with regards to 'my' variables, than
symbolic refs. You can try out the next test script for yourself, if you
like.
#! perl
print "eval:\n";
$x = 'global';
print "Global x is $x\n";
{
my $x = 'local';
print "Before: my x is $x\n";
my $ref = 'x';
eval "\$$ref = 'updated'";
print "After: my x is $x\n";
}
print "Now, global x is $x\n";
print "\nSymbolic refs:\n";
$x = 'global';
print "Global x is $x\n";
{
my $x = 'local';
print "Before: my x is $x\n";
my $ref = 'x';
$$ref = 'updated';
print "After: my x is $x\n";
}
print "Now, global x is $x\n";
For the impatient and/or lazy people, here are the results that I got:
eval:
Global x is global
Before: my x is local
After: my x is updated
Now, global x is global
Symbolic refs:
Global x is global
Before: my x is local
After: my x is local
Now, global x is updated
Now, as I recall, the original question was: "do we really need symbolic
refs, or are there alternatives?". Not only IS there an alternative, but
sometimes it even behaves better. No, we don't really need symbolic
refs.
Unless I'm mistaking, symbolic refs were introduced as an extension for
the Perl4 idiom:
$SIG{'INT'} = 'interrupted';
sub interrupted { die "Got killed!" }
And for the sake of the holy backward compatibility...
Bart.
------------------------------
Date: Sat, 14 Nov 1998 07:06:52 +0000
From: Joshua Udall <jaudall@students.wisc.edu>
Subject: recursion puzzle
Message-Id: <364D2C0C.B7F004BB@students.wisc.edu>
I have an array with several numbers (could be 100's). I
want the index numbers of all the elements that have equal
values.
In essence, I want to end up with a multi-dimensional array
containing the index numbers of those that have an equal
value. Is there a better way to think of this?
For example:
@array = ( 23, 24, 25, 34, 67, 789, 45, 45, 34, 456, 653,
5634, 23, 34, 3456 )
The result for the array above would look like this:
(0, 12) # for number 23
(3, 8, 13) # for number 34
(6, 7) # for number 45
It turned out to be a bit more difficult than I thought.
But this can't be a new problem.
Josh
------------------------------
Date: 14 Nov 1998 00:50:11 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: recursion puzzle
Message-Id: <m3af1u1znw.fsf@moiraine.dimensional.com>
Joshua Udall <jaudall@students.wisc.edu> writes:
> In essence, I want to end up with a multi-dimensional array
> containing the index numbers of those that have an equal
> value. Is there a better way to think of this?
Yes, use a hash of array references.
> @array = ( 23, 24, 25, 34, 67, 789, 45, 45, 34, 456, 653,
> 5634, 23, 34, 3456 )
>
> The result for the array above would look like this:
>
> (0, 12) # for number 23
> (3, 8, 13) # for number 34
> (6, 7) # for number 45
#!perl
use strict;
my @array = ( 23, 24, 25, 34, 67, 789, 45, 45, 34, 456, 653,
5634, 23, 34, 3456, );
my %hash;
for (my $i = 0; $i < @array; $i++) {
push @{$hash{$array[$i]}}, $i;
}
for (sort keys %hash) {
print "$_ => ", join ' ', @{$hash{$_}}, "\n";
}
__END__
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
Supporter of grumpiness where grumpiness is due on clpm.
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 14 Nov 1998 03:21:21 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: recursion puzzle
Message-Id: <x74ss27khq.fsf@sysarch.com>
>>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:
DG> my @array = ( 23, 24, 25, 34, 67, 789, 45, 45, 34, 456, 653,
DG> 5634, 23, 34, 3456, );
DG> my %hash;
DG> for (my $i = 0; $i < @array; $i++) {
DG> push @{$hash{$array[$i]}}, $i;
DG> }
DG> for (sort keys %hash) {
DG> print "$_ => ", join ' ', @{$hash{$_}}, "\n";
DG> }
your algorithm is fine but IMO the coding can use a little cleaning up.
try this (tested to be the same as yours):
# i don't like indexing and IMO it is rarely needed in perl.
foreach ( @array ) {
push @{$hash{$_}}, $i++;
}
# the join was superfluous as interpolating the array would join it with
# ' ' anyway.
for (sort keys %hash) {
print "$_ => @{$hash{$_}}\n";
}
in 5.005 the loops could be redone like this (tested):
push @{ $hash{$_} }, $i++ foreach ( @array ) ;
print "$_ => @{ $hash{$_} }\n" foreach ( sort keys %hash ) ;
nice and neat!
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Sat, 14 Nov 1998 15:03:17 GMT
From: fantastic2@hotmail.com (Alex M)
Subject: SIMPLE BLOWFISH IN PERL?
Message-Id: <364d9a87.2994995@nntp.best.com>
I am having an argument with someone I work with about implementing an
8-bit Blowfish decryption scheme in PERL.
He says that you have to download and use a module like cryptix and I
say that you could write the decryption using basic PERL commands.
Has anyone come up with a single PERL script that will decrypt data
encrypted with Blowfish? I checked CPAN and couldn't find it, but
maybe someone has.
I hate to be wrong! You can respond here or to me directly at
fantastic2@hotmail.com.
-- Alex
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4219
**************************************