[6910] in Perl-Users-Digest
Perl-Users Digest, Issue: 535 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 28 20:07:17 1997
Date: Wed, 28 May 97 17:00:21 -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 Wed, 28 May 1997 Volume: 8 Number: 535
Today's topics:
Re: A perl routine to fetch an url (silent-warrior)
Re: Applying patch for the compiler <rootbeer@teleport.com>
Re: Associate This! <rootbeer@teleport.com>
Re: ATTENTION -- NEED A SCRIPT <westmj@esvax.dnet.dupont.com>
books <pmerle@corp.sun.com>
catch-all logfile processor? <jong@pernet.com>
Re: Code Snippet Wanted <rootbeer@teleport.com>
Re: Detailed File Searching and Retreval <petri.backstrom@icl.fi>
FTP::ls() <dmead@btg.com>
Re: hash or array in perl 4? <rootbeer@teleport.com>
Re: Help w/ associative arrays <hansm@icgned.nl>
Inheritance help <umgroner@cc.umanitoba.ca>
Re: Linux issues with 5.004. <felicity@eclectic.kluge.net>
Re: Magical Auto-increment operator <robp@electriciti.com>
Re: Magical Auto-increment operator <robp@electriciti.com>
Re: Magical Auto-increment operator (Chipmunk)
Re: NcFTP, Perl, CGI - Permission Denied <rootbeer@teleport.com>
Re: OS/2: Locales / I18N problem: What to do? (Ilya Zakharevich)
Perl 5.004 failing posix.t test (Solaris 2.4) (Russell Steinthal)
Re: PERL_BADLANG (Ilya Zakharevich)
reading hashes from a file <rswillco@acs.ucalgary.ca>
Re: regexp solver (Tushar Samant)
Re: regexp solver (Hope this helps!)
sort algorithms <pmerle@corp.sun.com>
Re: subroutine call as lvalue (was: Re: questions about (Ilya Zakharevich)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 28 May 1997 23:33:14 GMT
From: silent-warrior@msn.com (silent-warrior)
Subject: Re: A perl routine to fetch an url
Message-Id: <338cc094.664945498@nntp.ne.highway1.com>
could you repost the original question and the answers. or email me
at david@mindbendr.com
thanks
On 22 May 1997 18:10:51 GMT, mara@cc.hut.fi (Martti Rahkila) wrote:
>Thanks everyone for your help. The 'HEAD' method was indeed what I wanted.
>
>My reply address in my previous articles was wrong due to misconfiguration of my
>news client. Hopefully this is now fixed.
>--
>
>/Mara
> Internet: Martti.Rahkila@hut.fi
> X.400: G=Martti;S=Rahkila;O=hut;PRMD=inet;ADMD=fumail;C=fi
> URL http://www.hut.fi/~mara/index.html
------------------------------
Date: Wed, 28 May 1997 16:43:17 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Joseph M. Scott" <jmscott@ainet.com>
Subject: Re: Applying patch for the compiler
Message-Id: <Pine.GSO.3.96.970528164117.3306E-100000@kelly.teleport.com>
On Wed, 28 May 1997, Joseph M. Scott wrote:
> I've been reading through the info on the perl compiler that Malcom
> Beattie has been working on. For the most part things look pretty
> straight forward, however I'm not familiar with applying patches to
> perl. ( Never had a problem compiling it on a couple of different
> systems in the past :-) )
Then you probably won't have a problem using patch. It's simple. Since
this isn't really a Perl question, though, I'll direct you to wherever you
go to get answers about using Unix utilities, although you'll probably
find everything you need from the manpage for patch.
Good luck with it!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Wed, 28 May 1997 16:27:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Steven T. Zydek" <stzydek@rs6000.cmp.ilstu.edu>
Subject: Re: Associate This!
Message-Id: <Pine.GSO.3.96.970528162011.3306B-100000@kelly.teleport.com>
On 28 May 1997, Steven T. Zydek wrote:
> I just wanted to know what the most efficient way to "clean" out the
> existing elements of an associative array. Here's my dilemma:
> $FriendsHeight("Greg") = "6 ft 7";
How about using curly braces instead of parens there, since you want a
hash.
> $FriendsHeight("Pete") = "7 ft 1";
> $FriendsHeight("Joe") = "5 ft 3";
> $FriendsHeight("Jack") = "6 ft 7";
>
> delete ($FriendsHeight("Joe");
There's an extra paren there, or one too few, dependin on how you look at
things. :-)
> # Now how would I list the existing friend's height's in a way
> # that I could also count how many friend's heights I have left
> # in the array?
Huh? You can always count the number of elements in a hash.
$friends = keys %FriendsHeight;
And you can print the information in a nifty table something like this.
print map { sprintf "%8s: %s\n", $_, $FriendsHeight{$_} }
keys %FriendsHeight;
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 27 May 1997 19:37:25 GMT
From: Mike West <westmj@esvax.dnet.dupont.com>
Subject: Re: ATTENTION -- NEED A SCRIPT
Message-Id: <5mfd5l$d7d@topgun.es.dupont.com>
N1Graphics (n1graphics@aol.com) wrote:
: Hi There!
:
: I need a Perl script for Perl 5.003 that is able to take some submitted
: data and repost it as a confirmation. I would also like if you would
: leave a place for me to add in some HTML that will be displayed on the
the
:
: confirmation page. Then the submit button should activate mail.pl.
E-mail
: me
: at ABergs@juno.com if you need more info. I need this fast.
:
: E-mail me at ABergs@juno.com
Posted from aol, answer to juno...
Funny thing, I get a lot of spam from juno.com on my aol account.
Coincidence, or something more?
------------------------------
Date: Wed, 28 May 1997 16:17:06 -0700
From: Pierre Merle <pmerle@corp.sun.com>
Subject: books
Message-Id: <338CBCF2.2156@corp.sun.com>
I think this as already been asked ...
I writing html/perl pages and I need a book.
Which is better ? I don't need a book with cdrom
and tons of unusefull PC oriented stuff. I need a book to explain perl
AND html in details. To complement brilliant net resources I've found.
Maybe two separates books are better, I use perl by exemple by
Ellie Quipley and HTML for fun and profit.
First is good but only perl, second is old and too simple.
What about Oreilly books ?
THanks for advices.
Pierre
------------------------------
Date: Wed, 28 May 1997 18:53:46 -0400
From: Jonathan Gilbert <jong@pernet.com>
Subject: catch-all logfile processor?
Message-Id: <338CB77A.A17@pernet.com>
does such a thing exist?
something that could do http, nntp, smtp, etc,
all at once and produce a general log report?
Does it exist, or di I have to invent the wheel?
jong out.
-------------------------
Jonathan Gilbert,
DataMart Computer Systems
http://www.pernet.com/
------------------------------
Date: Wed, 28 May 1997 16:40:51 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jim McCullars <jim@info.uah.edu>
Subject: Re: Code Snippet Wanted
Message-Id: <Pine.GSO.3.96.970528163315.3306D-100000@kelly.teleport.com>
On 28 May 1997, Jim McCullars wrote:
> find a line that may contain any of the following:
>
> <img src="uah_bar.gif"> or
> <img src="/uah_bar.gif"> or
> <img src="../uah_bar.gif"> or
> <img src="../../uah_bar.gif"> or even
> <img src="http://www.uah.edu/uah_bar.gif">
>
> and change that line so that only the part in quotes would be changed to:
>
> /images/uah_bar.gif
This might be what you want. (Then again, it may merely be what you asked
for. :-) Hope this helps!
s { <img\x20src="(http://www.uah.edu/|\.\./(\.\./)?|/?)uah_bar.gif"> }
{ <img src="/images/uah_bar.gif"> }gx;
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Thu, 22 May 1997 23:01:48 +0200
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Detailed File Searching and Retreval
Message-Id: <3384B43C.3D94@icl.fi>
Daniel Cody wrote:
>
> Just a quick question about a perl search script...
> Would it be possible to search a text file in a dir for a name and
> then return only *that* name as results of the query? I have been
> trying alot of things, but usually when I enter a name, it finds the
> name, but returns the entire text file. Thanks for the help in
> advance :)
That would depend on what you search, and how; your description
does not really explain what, exactly, it is that you are after.
>From your description... if you are looking for "name", then
why would you want it returned from anywhere (I should think
that it is enough to know if "name" is found or not - the
search returns true or false - as you already have "name").
However, if you come back with practical examples (of what
searches you've tried, and what was in the Perl script),
someone might be able to be more helpful (or maybe it is
just I that don't understand the question ;-).
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: Tue, 27 May 1997 16:46:36 -0400
From: Dave Mead <dmead@btg.com>
Subject: FTP::ls()
Message-Id: <338B482B.9764D465@btg.com>
Do you use a hyphen when specifying arguments to the FTP Package's ls( )
function?
i.e., is it $ftp -> ls(t)
or
$ftp -> ls(-t);
?????
------------------------------
Date: Wed, 28 May 1997 16:32:12 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Matthew Ho <mho@array.ca>
Subject: Re: hash or array in perl 4?
Message-Id: <Pine.GSO.3.96.970528162857.3306C-100000@kelly.teleport.com>
On Wed, 28 May 1997, Matthew Ho wrote:
> How can I use hash of array in perl 4?
exec 'perl5'; # :-)
Although there are some amazing hacks that people came up with to make
things like that "possible" in early versions of Perl, there's no
substitute for installing version 5. Since non-beta versions have been
available since late 1994 (and beta versions before that) there's no
reason to develop new programs for version 4.
Installing the new 5.004 is easier than you might think. Good luck!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 28 May 1997 23:41:48 GMT
From: Hans Mulder <hansm@icgned.nl>
Subject: Re: Help w/ associative arrays
Message-Id: <5mifrs$1a1@news.euro.net>
tadmc@flash.net (Tad McClellan) wrote:
>: > '01' is interpreted in decimal
>It is a string.
>If a number is needed, then perl converts the string using the
>atoi() C function.
>I looked around a little in the *.pods. Couldn't really find anything
>that says this. Maybe I just remember if from the Camel or Llama,
>I didn't check those.
It's in perlfaq4.pod:
=head2 Why isn't my octal data interpreted correctly?
Perl only understands octal and hex numbers as such when they occur
as literals in your program. If they are read in from somewhere and
assigned, no automatic conversion takes place. You must explicitly
use oct() or hex() if you want the values converted. oct() interprets
both hex ("0x350") numbers and octal ones ("0350" or even without the
leading "0", like "377"), while hex() only converts hexadecimal ones,
with or without a leading "0x", like "0x255", "3A", "ff", or "deadbeef".
-- HansM
------------------------------
Date: 28 May 97 20:38:02 GMT
From: Tim Groner <umgroner@cc.umanitoba.ca>
Subject: Inheritance help
Message-Id: <umgroner.864851882@bova>
I'm familiar with OOP, and Perl4 in general, but I'm new to Perl5.
I want to add some functionality to CGI.pm and I wanted to do that
through inheritance.
When I run a script that uses "MY_CGI" I get the error,
"Can't locate object method "new" via package "MY_CGI" at test.pl line 2."
The beginning of MY_CGI.pm has:
package MY_CGI;
@ISA = qw(CGI);
<some new methods and an overridden method>
The script test.pl begins with:
use MY_CGI;
$q = new MY_CGI;
Why can't the inherited "new" be found? There are no problems when I use
CGI.pm directly (except for the fact it doesn't have my new methods).
Does CGI::new need to be modified? I noticed that it only blesses $self
and not $self, $class - but that doesn't seem to be the problem (yet)
since it didn't make a differece in the error message when I fixed that.
Any help would be greatly appreciated.
--
Tim Groner
e-mail: Tim_Groner@Umanitoba.ca
http://home.cc.umanitoba.ca/~umgroner
------------------------------
Date: 28 May 1997 19:54:30 GMT
From: Theo Van Dinter <felicity@eclectic.kluge.net>
Subject: Re: Linux issues with 5.004.
Message-Id: <5mi2hm$jql$1@bigboote.WPI.EDU>
Tom Phoenix <rootbeer@teleport.com> wrote:
> Linux does not allow setuid scripts, and from what I hear, Linus says that
> it never will. :-) On Linux, Perl should normally be compiled to have
> setuid emulation.
Personally, I use a small C wrapper program to get the s[ug]id, and then
run the script. Perl is pretty much completely left out of the picture
with the uid/gid stuff ...
----
main(argc,argv)
int argc;
char **argv;
{
execv("/local/bin/script.pl",argv);
}
----
------------------------------
Date: Wed, 28 May 1997 15:45:18 -0700
From: Rob Perelman <robp@electriciti.com>
Subject: Re: Magical Auto-increment operator
Message-Id: <338CB57E.5C0A@electriciti.com>
Tushar Samant wrote:
Thanks for your followup -- you have some valid points which I shall
pick apart now. :)
> [a-zA-Z]*[0-9]* words are manifestly not numbers when they
> contain non-numerics.
OK, then explain why '3/9' and '9z' are treated as numbers. According
to Perl, it's a number. But it contains non-numerics.
> 1.1 and 1e1, on the other hand, ARE numbers. You like to
> increment them to 1.2 and 1e2; I think that's absurd. Perl's
> answers (2.1 and 11) are far better.
Like I said to Tom, my subroutine was/is not perfect. I want Perl to
handle the increment for numeric strings.
> How will you extend the behaviour even to \w*? What does "9z"
> increment to? You say "00a"--well, why? That's not intuitive
> to me. If you say "10a", it's as intuitive as "9aa". Magic
> should be far more boring and humdrum, it should be almost
> nauseatingly predictable.
Well, my program did say "00a". I didn't realize this was case and so I
changed the logic. Now it becomes "10a". True, "9aa" is just as valid,
but in my logic, I say a character gets added at the leftmost part of
the string if anything needs to be added.
> The point is: one would use automagical increment to do some-
> thing like...maybe make up filenames for a "csplit" kind of
> utility. It's enough to stay within "ab12" type strings. If
> I did want to increase my domain, I might split on (\W+), do
> something obvious to the segments and join them up again. Or
> do something else.
Well, I guess I'm just too lazy to split apart 'cs2#09', increment the
latter part, and then join it back together. Besides, the entire reason
I am bringing this issue up is because I want to say:
@lines = ('cs2#09' .. 'cs2#16');
And it just won't work. For now, I say:
@lines = map("cs2#$_", '09' .. '16');
But that is grossly inefficient and ugly.
------------------------------
Date: Wed, 28 May 1997 15:33:44 -0700
From: Rob Perelman <robp@electriciti.com>
Subject: Re: Magical Auto-increment operator
Message-Id: <338CB2C8.A98@electriciti.com>
Tom Phoenix wrote:
> > My proposal was to skip over non-alphanumeric characters. So your
> > example of '3/9' would increment to '4/0', and then '4/1' ... '4/9',
> > '5/0'.
>
> So, you'd increment just the alphanumeric characters found in the string?
> Hmmm... Would you increment '-7' to '-8'? :-) Would you turn "3.14159"
> into "3.14160"? (If you used that value as a number and then incremented
> it again, you would get "3.1417".)
True, this was incorrect on my part. I have changed my sample code a
bit to allow for this. But I believe you are missing my underlying
point. I hate to say this because I feel like I am disrespecting my
religion in arguing with you, but here is what I was trying to
illustrate in my program:
1. If the argument is numeric, Perl would increment it normally
2. If the argument was not numeric, the rules would be applied and the
string would be incremented
A co-worker and I looked at the Perl source and saw the section where
this occurs. It was in lines 2763-2792 in sv.c. On line 2766, it says
"Punt" in the comments -- atof() will always give you zero for a string.
> Part of the design of the current magic ensures that unexpected magic
> won't do anything harmful. That is, if you magically increment the string
> '123', you get the same result as if you incremented the number 123. But
> if you increment "123\n", you should get 124, not "124\n", since that's
> what somebody ignorant of the magic might be expecting.
Right...I am not disagreeing with this. I _want_ Perl/C to handle the
incrementing if the string is a number. If it is not, though, I want it
to handle whatever I have in there. It should skip over the
non-alphanumeric characters and leave them alone, doing it's normal
incremental operations on the rest. My original problematic string,
'cs2#09', fails the ++ operation. I want it to come back as 'cs2#10'.
I personally think this is highly logical.
> Well, Perl sees '3/9' as a number; it's not a string eligible for magical
> incrementing. So the number it sees is three, and it increments that to
> get four.
But why does it see it as a number? I would think the / would
disqualify the string as a number...
> The magical autoincrement doesn't do much, but I think it's more useful as
> it is. Of course, you could easily make a module that would let you easily
> implement your own autoincrement.
True, I could make my own module. I just like to see things handled
internally if they can be. I don't see how it would break any current
code -- surely nobody is sending over 'cs#09' to ++ and expecting back
1, and if they are, they deserve to get back 'cs#10' if they upgrade to
Perl w/my extended handling. :) OK, OK...
For you reference, I am including examples of the cases where Perl and I
disagree...and below, I have attached the slightly modified subroutine
to show that it lets Perl handle the increment if the string is a
number. Thanks for your time.
Testing 'cs2#09' I say cs2#10 Perl says 1 Matches?
No
Testing 'cs2#99' I say cs3#00 Perl says 1 Matches?
No
Testing 'a1z9' I say a2a0 Perl says 1 Matches?
No
Testing '3/9' I say 4/0 Perl says 4 Matches?
No
Testing '9z' I say 10a Perl says 10 Matches?
No
sub plusplus {
my($arg, $pos, $last) = (shift, length($arg));
# This is a _horrible_ regex -- I am just illustrating
# that a normal + 1 suffices for a number
return $arg + 1 if ($arg =~ /^[-\d\.e]+$/);
while ($pos--) {
substr($arg, $pos, 1) = chr(ord($last) + 1), return $arg
unless (($last = substr($arg, $pos, 1)) eq '9' or lc $last eq 'z'
or
$last !~ /^\w$/);
substr($arg, $pos, 1) = $last = chr(ord($last) - ($last eq '9' ? 9 :
25))
if ($last =~ /^\w$/);
}
return (($last =~ /\D/ ? $last : '1') . $arg);
}
------------------------------
Date: 28 May 1997 19:45:20 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Magical Auto-increment operator
Message-Id: <5mi20g$c42$2@dartvax.dartmouth.edu>
In article <338B6882.5BED@electriciti.com>
Rob Perelman <robp@electriciti.com> writes:
> > But if any old character can appear in a string, what do you get by
> > incrementing '3/9'? I think you would get '300' - oops! No more magic!
> >
> > Unless I've misunderstood your idea... :-)
>
> You did not understand the question, but you may have missed part of my
> "standards" in the code I showed. My proposal was to skip over
> non-alphanumeric characters. So your example of '3/9' would increment
> to '4/0', and then '4/1' ... '4/9', '5/0'. Perl's answer to '3/9' is
> 4. I _really_ don't understand that.
"3/9" does not match /^[a-zA-Z]*[0-9]*$/, so ++ treats it as a number.
The value of "3/9" as a number is 3. 3+1 is 4. Therefore, if $foo =
"3/9", $foo++ is "4".
Chipmunk
------------------------------
Date: Wed, 28 May 1997 16:16:58 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Dwayne Kruk <dkruk@ilos.net>
Subject: Re: NcFTP, Perl, CGI - Permission Denied
Message-Id: <Pine.GSO.3.96.970528161521.3306A-100000@kelly.teleport.com>
On 28 May 1997, Dwayne Kruk wrote:
> When I execute ncftp in one of my lines of code, I'm getting permission
> denied errors.
Do you mean that your script doesn't have permission to run ncftp, or that
it runs but gets a "permission denied" error from the remote site?
And did you know that there is a module to do FTP from within Perl? It's
called Net::FTP, if my memory is correct. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 27 May 1997 20:11:17 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: OS/2: Locales / I18N problem: What to do?
Message-Id: <5mff55$j0$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Koos Pol
<koos_pol@compuware.com.NO_JUNK_MAIL>],
who wrote in article <5mbbbt$dbm@news.nl.compuware.com>:
> >> On my OS/2 Warp box, I get the following diagnostics on running programs. Who
> >> can tell me what to do?
> >As usual, if everything else fails, try to read the docs (at last!).
I wonder why the binary installer did not put the corresponding
variable (PERL_BADLANG) into your config.sys... Did you mangle the
results of the installation, or did you change your LANG after you
installed perl?
Ilya
------------------------------
Date: 27 May 1997 21:56:08 -0400
From: steintr@intac.com (Russell Steinthal)
Subject: Perl 5.004 failing posix.t test (Solaris 2.4)
Message-Id: <5mg3bo$kha@nile.intac.com>
Well, the subject lines pretty much says it all. I'm attempting to
install Perl 5.004 under Solaris 2.4, and while the compilation goes
smoothly, make test indicates a failure on test 12 of posix.t
(reproduced below). All the other tests checked out. Since I can't
think of any of the scripts which I use which actually use POSIX
support, I installed the new binary; however, I'd greatly appreciate
any help on fixing this last problem (since it's inevitable that some
script I need will die because of this problem if I leave it unfixed).
The problem test is:
print &_POSIX_OPEN_MAX > $fds[1] ? "ok 12\n" : "not ok 12\n";
For the record, I have installed the patch which was posted to
comp.lang.perl.announce, although the same problem occurs with and
without the patch.
Thanks in advance.
--
Russell Steinthal | Temporarily posting from steintr@intac.com
rms39@columbia.edu | E-mail to either address will work
------------------------------
Date: 28 May 1997 23:08:15 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: PERL_BADLANG
Message-Id: <5midsv$pu6$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Koos Pol
<koos_pol@nl.compuware.com.NO_JUNK_MAIL>],
who wrote in article <5mgj5h$5fs@news.nl.compuware.com>:
> >
> >I wonder why the binary installer did not put the corresponding
> >variable (PERL_BADLANG) into your config.sys... Did you mangle the
> >results of the installation, or did you change your LANG after you
> >installed perl?
> >
> >Ilya
> >
>
> Thanks Ilya for yet another response! You seem to be the only guy around
> with interest in Perl/2. Well, with me you have at least 1 very happy customer!
>
> The installer did indeed add PERL_BADLANG. As I couldn't repair the I18N issues,
> I set PERL_BADLANG=0 to get rid off the messages.
> Btw, I didn't mangle anything. My installation is a fresh one. Nevertheless,
> maybe I should re-install to double check the installer queries and my responses.
Sorry, this is probably the known bug/feature of PERL_BADLANG. It was
documented you need to set it to 1 to disable warnings, but in newer
Perl it is correctly documented that you need to set it to 0.
Thus the installer is indeed buggy: I think it puts PERL_BADLANG=1 if
it finds a strange LANG...
Ilya
------------------------------
Date: Tue, 27 May 1997 12:28:53 -0600
From: "Randall S. Willcox" <rswillco@acs.ucalgary.ca>
Subject: reading hashes from a file
Message-Id: <338B27E5.2677@acs.ucalgary.ca>
Hello,
First, thanks to all who answered my previous question about associative
arrays. Very helpful.
Here's my problem:
I've a cgi perl script for on-line quizzes, I use a hidden field to
identify the quiz name like this: <input type=hidden name="QUIZ_NUM"
value="01">. Now let's say I've 10 different quizzes & I want to store
all of the answers to them in hashes within a text file called "foo.txt"
So we have a text file that looks like %01 = ('01', 'a', '02', 'b'); and
so on up to up %10. Now I want read "foo.txt", grab an individual hash
from it & plug it into my script.
Here's what I mean:
This is a wonderful little bit of script given me by Chipmunk on this
newsgroup for comparing my incoming hashes to the correct answers:
%answers = ('01', 'a', '02', 'b'); # correct answers
%input = ('01', 'a', '02', 'c'); # user's answers
$correct = 0;
@keys = keys %answers;
$total = $#keys + 1;
foreach $key (@keys) {
$correct++ if ($answers{$key} eq $input{$key});
}
print "You scored $correct out of $total.\n";
QUESTION:
How can I assign an individual hash from "foo.txt" to %answers?
I was hoping it would be something as simple as getting the correct
hidden field value & then doing something like this:
open (INFILE, "foo.txt");
%01 = %answers;
but it appears to be a little more complicated.
any ideas?
thanks,
rswillco
------------------------------
Date: 27 May 1997 15:34:23 -0500
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: regexp solver
Message-Id: <5mfggf$82q@shoga.wwa.com>
In article <5mf557$51v@info.abdn.ac.uk>, Kyzer <kyzer@hotmail.com> wrote:
>I'm wondering, is there a program to solve perl regexps?
>(That is, print out all possible matches, using * to represent 'this could
>match anything, and I'm not going to print that all out)
I have one in late, late beta. Alas, I still need to add some more
intelligence for the "match anything" part...
#!/usr/local/bin/perl
$pat = shift;
while () {
($r, $_) = ($i, "");
while ($r) {
$_ .= chr($r & 127);
$r >>= 7;
}
print "$_\n" if m{$pat};
$i++;
}
------------------------------
Date: 28 May 1997 18:32:05 -0500
From: scribble@shoga.wwa.com (Hope this helps!)
Subject: Re: regexp solver
Message-Id: <5mif9l$4cs@shoga.wwa.com>
In article <5mi1oj$c42$1@dartvax.dartmouth.edu>,
Chipmunk <Ronald.J.Kimball@dartmouth.edu> wrote:
>In article <5mfggf$82q@shoga.wwa.com>
>scribble@shoga.wwa.com (Tushar Samant) writes:
>
>> I have one in late, late beta. Alas, I still need to add some more
>> intelligence for the "match anything" part...
>
>Actually, I think it would be much easier to write such a program if
>you didn't use * to represent 'this could match anything...'.
Well said!
>$regexp = "whatever";
>
>@chars = ("", "\000" .. "\177");
>
>print "The following strings match /$regexp/\n";
>
>while (1) {
> $_ = '';
>
> for ($i = $#str; $i >= 0; --$i) {
> $_ .= $chars[$str[$i]];
> }
> if (/$regexp/) {
> print "\t\"$_\"\n";
> }
>
> $str[0]++;
> $i = 0;
> while ($str[$i] > $#chars) {
> $str[$i] = 1;
> $str[++$i]++;
> }
>}
>
>
>Chipmunk
------------------------------
Date: Wed, 28 May 1997 16:22:07 -0700
From: Pierre Merle <pmerle@corp.sun.com>
Subject: sort algorithms
Message-Id: <338CBE1F.78E8@corp.sun.com>
Hi,
I need to sort datas.
I used to make chained list in C language.
What about it in perl ?
Any suggestion welcome.
Pierre
------------------------------
Date: 28 May 1997 23:14:49 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: subroutine call as lvalue (was: Re: questions about chop)
Message-Id: <5mie99$pu6$2@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Jesse Glick
<jesse@ginger.sig.bsh.com>],
who wrote in article <4on2pfux9p.fsf@ginger.sig.bsh.com>:
>
> > Randal Schwartz <merlyn@stonehenge.com> writes:
> >
> > > The Perl development team (aka, the P5P) have been looking into making
> > > it possible to write user subroutines that can perform similarly.
> > > Such a feature did not make it into 5.004, but perhaps 5.005 or 5.006
> > > will include such capability.
>
> Why not:
>
> foo()="bar"
>
> ===>
>
> ${foo()}="bar"
>
> and similarly for other ref types, according to the ref actually returned by
> the routine at runtime, if any (else error). If you need some special logic
> built into that, tie. E.g.:
>
> sub my_substr {
> tie my $foo, MY_SUBSTR, @_;
> \$foo;
> }
> package MY_SUBSTR;
> sub FETCH {...substr(...)...}
> sub STORE {...substr(...)=...}
>
> This would require very little extra logic in the Perl core, and it would be
> simple to write modules to make things more convenient.
Why do you think so? We know that doing this in DWIM way requires very
little extra logic in the Perl core. But why do you think that your
change is also simple to code?
Ilya
------------------------------
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 535
*************************************