[8494] in Perl-Users-Digest
Perl-Users Digest, Issue: 2111 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 16 18:17:29 1998
Date: Mon, 16 Mar 98 15:00:37 -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 Mon, 16 Mar 1998 Volume: 8 Number: 2111
Today's topics:
/URGENT/ Problems w/ PERL for IIS 4.0 <JDB@animalwelfare.com>
Appending into the middle (Scott Nipp)
Re: Are There Any Snazzy Perl Editors for Windows? <Rosie@dozyrosy.demon.co.uk>
Re: Are There Any Snazzy Perl Editors for Windows? (Alan Schwartz)
Are there translated user messages available? <aviTAKEOUTne@TAKEOUTeng.sun.com>
Re: calculating distance between strings (fortune cooki (Simon Oosthoek)
Re: contexts: is there such a thing as array? (M.J.T. Guy)
Currency in HTML output <norman.bunn@mci.com>
Re: Currency in HTML output <egwong@netcom.com>
Re: Currency in HTML output (Craig Berry)
Re: exact match <sowmaster@juicepigs.com>
Re: Help with perl, immediate answers wanted! <ben@nilenet.com>
Re: Help with perl, immediate answers wanted! <sowmaster@juicepigs.com>
how to assign unix command options in perl (Lalit Jairath)
Illegal octal digit error? (Stan Horwitz)
Re: Illegal octal digit error? <kapur@cbl.ncsu.edu>
Re: Illegal octal digit error? <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: Illegal octal digit error? <mfeit@pop.net>
Re: Illegal octal digit error? <cmargoli@world.northgrum.com>
Re: Illegal octal digit error? <jstern@world.northgrum.com>
Re: Large programs: is Perl up to it? <zenin@archive.rhps.org>
Re: Multiple substitues (Jason Gloudon)
Re: Perl and passwd <khera@kciLink.com>
Re: Perl Interface to SSH? (Ton Hospel)
Re: precedence problem (Jason Gloudon)
Re: precedence problem (Jim Allenspach)
Re: Splitting a string to make keys to a hash <dboorstein@shopcfn.com>
Re: Unloading subs? (Ilya Zakharevich)
Re: User-interface Quandary <keithmur@mindspring.com>
warn handler gets SEGV <shea@gtsdesign.com>
Re: webserver configuration/cgi.pm/nt anne_lee@mailexcite.com
Re: Win32 registry functions - docs (Steven M. Glassman)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 16 Mar 1998 17:23:19 -0500
From: "J.D. Beary" <JDB@animalwelfare.com>
Subject: /URGENT/ Problems w/ PERL for IIS 4.0
Message-Id: <350DA656.2F193ED6@animalwelfare.com>
Hello,
I am currently attempting to install Perl build 316 from Active
State and have it run on IIS 4.0 on NT 4.0. I downloaded both perl and
perl for isapi and installed them both without a hitch. I followed all
the instructions and can run perl scripts from the command line. When I
attempt to run them through IIS, they return "document contains no
data". I have checked permissions, the script map in the registry, read
all the FAQ's and did everything I could possibly think of.
please help,
TIA,
JD
JDB@animalwelfare.com
------------------------------
Date: 16 Mar 1998 21:58:46 GMT
From: snipp@spd.dsccc.com (Scott Nipp)
Subject: Appending into the middle
Message-Id: <6ek7am$e4c@sun001.spd.dsccc.com>
I am creating a subroutine to insert data into the middle of an
existing report. I am not a perl guru, I am running into a few problems. Here
is a bit of the code that I am working with.
print "Please enter end user name: "; chop($uname = <STDIN>);
&report;
sub report {
open (REPORT,"/homes/snipp/reports/report");
open (REPORT1,">>/homes/snipp/reports/report.tmp");
while ($lines = <REPORT>) {
if ($lines eq "TkTrack Activities\n") {
print REPORT1 $lines;
print REPORT1 "test $uname ";
} else {
print REPORT1 $lines;
}
}
}
Unfortunately this does not work out very well. I am kind of at a loss
for ideas at the moment. This portion of the script should ideally take a
line of formatted data and stick it in after a heading type category in the
report. Here is the portion of the report where I am trying to insert this
text.
Upgrade User New Sys Old Sys Office Old New
---- ------- ------- ------ --- ---
Thanks in advance for the help. Please reply via e-mail.
--
Scott Nipp DSC Workstation Service Sprint Paranet Technical Analyst
Phone: 477-9645 Work: snipp@spd.dsccc.com Home: nipp@swbell.net
------------------------------
Date: Sun, 15 Mar 1998 20:47:24 +0000
From: Rosemary I H Powell <Rosie@dozyrosy.demon.co.uk>
Subject: Re: Are There Any Snazzy Perl Editors for Windows?
Message-Id: <pwodkHAc5DD1Ewjv@dozyrosy.demon.co.uk>
In article <6ebq1b$3iq@bgtnsc02.worldnet.att.net>, Creede Lambard
<$_=qq!fearless@?.com!> writes
>
>dk smith wrote in message ...
>>In article <3508D591.3546EF56@technologist.com>, Tommy
>><tkho@technologist.com> wrote:
>>
>>> I have seen the question on Win95 Perl Editor many times.
>
><snip>
>
>>Please include Mac OS editors too.
>
>If you're including Mac editors you have to include Alpha. Not only does it
>support keyword and comment coloring but you can run your Perl script
>directly from Alpha.
>
>I've missed most of this discussion so I don't know if anyone has mentioned
>Programmer's File Editor (PFE) for Windows yet. It doesn't support keyword
>coloring but its ability to show line numbers and multiple documents beats
>Notepad all hollow (and on Win95 its ability to handle long text files that
>Notepad chokes on makes it even better). Plus, it has the best price of all
>(free).
>
>--- Creede Lambard
>
Yes, I use and love PFE; it revolutionized testing and debugging for me,
as I can test run my script in a DOS window opened from PFE. It has a
log window for you to view the output in too.
Rosemary
PS And - it's British!!
-------------------------------------------------------------------
| Rosemary I.H.Powell EMail: Home: rosemary@dozyrosy.demon.co.uk |
| Work: r.i.h.powell@rl.ac.uk |
| http://www.netlink.co.uk/users/dozyrosy/ |
| http://www.dozyrosy.demon.co.uk/ |
-------------------------------------------------------------------
------------------------------
Date: 16 Mar 1998 22:04:08 GMT
From: alansz@araw.mede.uic.edu (Alan Schwartz)
Subject: Re: Are There Any Snazzy Perl Editors for Windows?
Message-Id: <6ek7ko$4pne$1@piglet.cc.uic.edu>
Rosemary I H Powell <Postmaster@dozyrosy.demon.co.uk> writes:
>In article <6ebq1b$3iq@bgtnsc02.worldnet.att.net>, Creede Lambard
><$_=qq!fearless@?.com!> writes
>>I've missed most of this discussion so I don't know if anyone has mentioned
>>Programmer's File Editor (PFE) for Windows yet. It doesn't support keyword
>>coloring but its ability to show line numbers and multiple documents beats
>>Notepad all hollow (and on Win95 its ability to handle long text files that
>>Notepad chokes on makes it even better). Plus, it has the best price of all
>>(free).
>>
>>--- Creede Lambard
>>
>Yes, I use and love PFE; it revolutionized testing and debugging for me,
>as I can test run my script in a DOS window opened from PFE. It has a
>log window for you to view the output in too.
>
>Rosemary
I also love PFE. When using it with Perl, a handy thing is to tell
it that the "compile" command is "perl -cw". You can then
hit compile and watch another window pop up containing all your warnings,
etc., so you can fix up the code.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Alan Schwartz | Disclaimer: I represent no one
<alansz@uic.edu> |
Asst. Prof. of Clinical Decision Making | Life is what happens to you while
University of Illinois at Chicago | you're busy making other plans
Department of Medical Education | - J. Lennon
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Mon, 16 Mar 1998 13:00:22 -0800
From: "A. V." <aviTAKEOUTne@TAKEOUTeng.sun.com>
Subject: Are there translated user messages available?
Message-Id: <350D92E6.C21ED9FC@TAKEOUTeng.sun.com>
I've been trying to get any sort of information on Perl library user messages. Can anyone
give me a pointer? I need to know:
1. where they are stored (if there is a standard location),
2. whether there are publicly available localizations of the user messages,
3. whether it would be legal to localize any of the user message catalogs.
Thanks,
Andrea
aviTAKEOUTne@TAKEOUTeng.sun.com
To email me, please take out the word TAKEOUT in my email address.
--
--------------------
bite the wax tadpole
------------------------------
Date: 16 Mar 1998 22:05:16 GMT
From: s.oosthoek@student.utwente.nl (Simon Oosthoek)
Subject: Re: calculating distance between strings (fortune cookies)
Message-Id: <6ek7ms$7p8$1@pandora.cs.utwente.nl>
In a previous article Frank@but_dont_use_this.address
<Frank@but_dont_use_this.address> says...
>
>Ronald J Kimball <rjk@coos.dartmouth.edu> writes:
>>
>>Simon Oosthoek wrote:
>>>
>>> I'm looking for a program/script/whatever that can calculate the
>>> distance between two text-strings. By distance I mean that I want
>>> to find strings that human beings can identify as "the same", but a
>>> computer would not directly consider equal in the sense: ($StrX eq
>>> $StrY)
>> This sounds interesting. Could you be more specific about what you
>> mean by "distance"? In particular, what ideas do you have for
>> calculating the distance? You could do something with the lengths
>> of the strings and the number of non-matching characters. But you'd
>> also have to allow for offets, such as "bar" and " bar"...
>I read a while ago (here?) that someone produced a thing to transform
>a string into some form of phonetic representation. Perhaps this
>transformed input is more robust to this kind of offsets & normal
>spelling errors.
Well, I've thought some more about this problem and tried some small code
experiments to sort some metrics combined into a string.
So far, I've tried metrics like
- number of lines
- number of capitals
- number of lowercase
- number of wordbounderies
- number of digits
- number of characters
of course I want to combine them, but the way I did it by combining them into
a string is highly error prone (for one thing I didn't format the substrings
right justified, so it was a wonder that I got any results.
I'll include the rather messy code below to give a hint of my attempts.
The idea of "distance" came to me from the mathematical world of vectors
and the comparison of them. I thought that if one of the coordinates of a
complex "string space" would differ, but most of the others were the same, it
ought to be a similar string. I fear now that this may only apply to longer
strings (250 characters or more).
To improve on this idea, I think a more complete canonicalisation is
necessary. So first remove any trailing and leading newlines, superfluous
spaces and tabs, internal double newlines and comparing the string without
case. Of course, some of the things removed there, could be used as minor
metric in the comparison (the number of capitals and lowercase characters
appears to be quite meaningful)
The phonetic comparison is a nice idea, but a problem with that is (I think)
that it will consume much processing time and not all fortune cookies are
meant to be pronounced anyway.
Another option (this is going very far) would be to create a conceptual
graph[1] for each cookie and comparing them to other graphs. One problem
(aside from the practical implementation ones), is that this assumes that a
meaning can be attributed to cookies ;-)
Thanks for all the ideas so far, and I hope this posting will spawn a few new
ones....
Simon.
[1] A conceptual graph is a combination of word-graphs, which consist of a
limited set of relations and elements. This is an area of theoretical
mathematics that is being developed at the University of Twente in the
Netherlands and I once attended a course on this subject.
--------
sample code
(this doesn't work (anymore, for me), no time now to find the bug, I'm a bit
out of practice with Perl)
#!/usr/bin/perl -w
open(FILE, "<$ARGV[0]");
@infile = <FILE>;
close(FILE);
$allinone = join("", @infile);
@cookies = split(/%/, $allinone);
foreach $cookie (@cookies)
{
# $cookie =~ s/\n\n/\n/g;
$newlines = ($cookie =~ s/\n/\n/g);
$chars = ($cookie =~ s/(\S)/$1/g);
$bounds = ($cookie =~ s/\b//g);
$capitals = ($cookie =~ s/([A-Z])/$1/g);
$lower = ($cookie =~ s/([a-z])/$1/g);
$digits = ($cookie =~ s/(\d)/$1/g);
push (@hashlist, [ ($capitals, $lower, '0'.$digits, $chars, $bounds,
$newlines) ]);
}
$i = 0;
foreach $entry (@hashlist)
{
my $tmp = packthem(@{$hashlist[$i]});
push (@packedlist, $tmp);
$backref{$tmp} = $i;
$i++;
}
foreach $entry (sort @packedlist)
{
my $index = $backref{$entry};
print join("\t", @{$hashlist[$index]}) . "\n";
print $cookies[$index];
}
sub packthem {
my $tmp = '';
foreach (@_)
{
my $ln = length($tmp);
$tmp .= '0' x ( 6 - $ln ) . $_;
}
return $tmp
}
------------------------------
Date: 16 Mar 1998 22:33:02 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: contexts: is there such a thing as array?
Message-Id: <6ek9au$6u$1@lyra.csx.cam.ac.uk>
In article <x71zwjyyjc.fsf@sysarch.com>, Uri Guttman <uri@sysarch.com> wrote:
>kcohen@julius.ling.ohio-state.edu (Kevin B Cohen) writes:
>> different behavior with the array @stuff versus with the list ("one",
>> "two", "three"), so let's call bread bread and wine wine and conclude
>> that these are different contexts.
>
>wrong. an array variable evaluated in a scalar context gives the number
>of elements in an array. a list evaluated in an scalar context give the
>last element of the list.
Sorry, but wrong again. You can never have "a list evaluated in an
scalar context". The ONLY way you can get a list in Perl is by
evaluating some expression in list context. So the well known line
in the Camel and in perlfunc
THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR!
is actually rather misleading. This situation can NEVER OCCUR, so
there is no question of a rule, general or particular.
Mike Guy
------------------------------
Date: Mon, 16 Mar 1998 21:30:31 GMT
From: "Norman Bunn" <norman.bunn@mci.com>
Subject: Currency in HTML output
Message-Id: <XRgP.71$%%2.111984@news.internetMCI.com>
I'm trying to output currency ($xxx.xx) to HTML using a PERL program. I can
get the proper number of decimal places, but don't see anything in the doc
about $-signs and commas (when > $999.99). How is this done?
Norman
------------------------------
Date: Mon, 16 Mar 1998 22:29:09 GMT
From: Eric Wong <egwong@netcom.com>
Subject: Re: Currency in HTML output
Message-Id: <egwongEpxnsL.B5s@netcom.com>
Norman Bunn <norman.bunn@mci.com> wrote:
: I'm trying to output currency ($xxx.xx) to HTML using a PERL program. I can
: get the proper number of decimal places, but don't see anything in the doc
: about $-signs and commas (when > $999.99). How is this done?
I don't understand what you mean about $-signs. Is it a problem
with escaping? (i.e. use print("\$100"); *not* print("$100");)
For the comma question, it's
man perlfaq5
faq> How can I output my numbers with commas added?
faq>
faq> This one will do it for you:
faq>
faq> sub commify {
faq> local $_ = shift;
faq> 1 while s/^(-?\d+)(\d{3})/$1,$2/;
faq> return $_;
faq> }
faq>
faq> $n = 23659019423.2331;
faq> print "GOT: ", commify($n), "\n";
faq>
faq> GOT: 23,659,019,423.2331
faq>
faq> You can't just:
faq>
faq> s/^(-?\d+)(\d{3})/$1,$2/g;
faq>
faq> because you have to put the comma in and then recalculate your position.
faq>
[cc'd]
------------------------------
Date: 16 Mar 1998 22:31:50 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Currency in HTML output
Message-Id: <6ek98n$mmm$1@marina.cinenet.net>
Norman Bunn (norman.bunn@mci.com) wrote:
: I'm trying to output currency ($xxx.xx) to HTML using a PERL program. I can
: get the proper number of decimal places, but don't see anything in the doc
: about $-signs and commas (when > $999.99). How is this done?
$ may be specified using $ in a single-quoted string, or \$ in a
double-quoted string. There's a FAQ item on how to do comma grouping.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Mon, 16 Mar 1998 17:47:58 -0500
From: Bob Trieger <sowmaster@juicepigs.com>
To: Farid Hamjavar <hamjavar@unm.edu>
Subject: Re: exact match
Message-Id: <350D9191.1B86@juicepigs.com>
Farid Hamjavar wrote:
>
> Greetings,
>
> I use the following to know if ARGV[1]
> is all digit characters. I tried several
> other variations but they did not work.
> How can I compare $item against
> something like /^[0-9].*[0-9]$/ and
> know that it's all digits?
> Saying it in other words, I don't
> want to accomplish this by "negative comparison",
> meaning that here (below) I know it's not all
> digits because it's not all alpha characters.
I'm not sure what you are asking but try:
m/^\d*$/;
that is what I use to test a variable to see if it is all digits. The
example you have just checks the first and last character of the
variable.
HTH
Bob Trieger
sowmaster@juicepigs.com
------------------------------
Date: Mon, 16 Mar 1998 19:06:47 +0000
From: Ben Bergen <ben@nilenet.com>
Subject: Re: Help with perl, immediate answers wanted!
Message-Id: <350D7847.73437071@nilenet.com>
It seems like windows users area always demanding answers. I have some
advice for them:
step 1: Get a real fucking OS!!!
step 2: RTFM!!!
--
Ben Bergen I/O Green Mountain, Inc.
ben@gmg.com Boulder, CO 80303
------------------------------
Date: Mon, 16 Mar 1998 17:01:51 -0500
From: Bob Trieger <sowmaster@juicepigs.com>
To: Ben Bergen <ben@nilenet.com>
Subject: Re: Help with perl, immediate answers wanted!
Message-Id: <350DA14F.2F6C@juicepigs.com>
Ben Bergen wrote:
>
> It seems like windows users area always demanding answers. I have some
> advice for them:
>
> step 1: Get a real fucking OS!!!
> step 2: RTFM!!!
>
Granted, the original poster was a moron and perhaps typical, don't
lump all POBs together. And if you are going to try and fit the bill as
a "better than thou" Linux dweeb, you really should not use a web
browser to read and post to USENET.
Bob Trieger
sowmaster@juicepigs.com
------------------------------
Date: 16 Mar 1998 21:29:33 GMT
From: ljairath@wright.aps.uoguelph.ca (Lalit Jairath)
Subject: how to assign unix command options in perl
Message-Id: <6ek5jt$17g@ccshst05.uoguelph.ca>
Hi all,
how can i assign unix command options in perl?
i do the following:
$_ = `date -u +%B`;
print;
it does not work. it just prints B.
any ideas?
TThanx in advance.
Lalit
~~~~~
--
*=========================================================================*
| Dr. Lalit Jairath, Ph.D. | E-mail: |
| Genetic Evaluation Analyst | ljairath@aps.uoguelph.ca |
| Centre for Genetic Improvement of Livestock | |
| Animal & Poultry Science | |
| University of Guelph, Ontario, CANADA | Tel: (519)824-4120 x3696 |
| N1G 2W1 | Fax: (519) 767-0573 |
|-------------------------------------------------------------------------|
| WWW: http://www.aps.uoguelph.ca/~ljairath/ |
*=========================================================================*
------------------------------
Date: 16 Mar 1998 21:13:59 GMT
From: stan@thunder.temple.edu (Stan Horwitz)
Subject: Illegal octal digit error?
Message-Id: <6ek4mn$fb3$1@cronkite.ocis.temple.edu>
Could someone please tell me what an "illegal octal digit" error message
means in Perl5 on HP Unix? I have a sequence of 12 "if" statements, all of
which are identical in format. Those 12 statements are:
if ($in_month eq "Jan") { $trans_month = 01; }
if ($in_month eq "Feb") { $trans_month = 02; }
if ($in_month eq "Mar") { $trans_month = 03; }
if ($in_month eq "Apr") { $trans_month = 04; }
if ($in_month eq "May") { $trans_month = 05; }
if ($in_month eq "Jun") { $trans_month = 06; }
if ($in_month eq "Jul") { $trans_month = 07; }
if ($in_month eq "Aug") { $trans_month = 08; }
if ($in_month eq "Sep") { $trans_month = 09; }
if ($in_month eq "Oct") { $trans_month = 10; }
if ($in_month eq "Nov") { $trans_month = 11; }
if ($in_month eq "Dec") { $trans_month = 12; }
The statements involving "Aug" and "Sep" get flagged with the following
error messages:
Illegal octal digit at convert.pl line 121, at end of line
Illegal octal digit at convert.pl line 122, at end of line
I have no idea why Perl's complaining about just those two lines. All I
want to do is test a field to see if its equal to the abbreviation for a
particular month of the year and set another variable called $trans_month
to the numerical value of that month. I am stumped! If I remove those
statements from the program, it runs fine. If anyone can shed some light
on this strange error, please let me know.
Thanks
------------------------------
Date: 16 Mar 1998 16:47:24 -0500
From: Nevin Kapur <kapur@cbl.ncsu.edu>
To: stan@thunder.temple.edu (Stan Horwitz)
Subject: Re: Illegal octal digit error?
Message-Id: <tyogz6s3yr.fsf@cbl.ncsu.edu>
[posted and mailed]
>From the perldata(1) man page:
Scalar value constructors
Numeric literals are specified in any of the customary
floating point or integer formats:
12345
12345.67
.23E-10
0xffff # hex
0377 # octal
^ ^^^^^^^
4_294_967_296 # underline for legibility
You should quote each of assignments in this case:
.... { trans_month = '01'; }
etc. Perl is treating each of them as an octal and of course, 08 is
not legal octal.
stan@thunder.temple.edu (Stan Horwitz) writes:
> Could someone please tell me what an "illegal octal digit" error message
> means in Perl5 on HP Unix? I have a sequence of 12 "if" statements, all of
> which are identical in format. Those 12 statements are:
[snip]
> if ($in_month eq "Aug") { $trans_month = 08; }
> if ($in_month eq "Sep") { $trans_month = 09; }
[snip]
>
> The statements involving "Aug" and "Sep" get flagged with the following
> error messages:
>
> Illegal octal digit at convert.pl line 121, at end of line
> Illegal octal digit at convert.pl line 122, at end of line
--
Nevin
------------------------------
Date: 16 Mar 1998 23:02:27 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
To: stan@thunder.temple.edu
Subject: Re: Illegal octal digit error?
Message-Id: <7x4t0y2t1o.fsf@beavis.vcpc.univie.ac.at>
Re: Illegal octal digit error?, Stan
<stan@thunder.temple.edu> said:
Stan> Could someone please tell me what an "illegal octal
Stan> digit" error message means in Perl5 on HP Unix? I have
Stan> a sequence of 12 "if" statements, all of which are
Stan> identical in format. Those 12 statements are:
Stan> if ($in_month eq "Jan") { $trans_month = 01; }
Bleagh, sequences of if's are nasty, use elsif cascade, or
Date::Manip or Date::DateCalc to simplify lookups.
Stan> ($in_month eq "Aug") { $trans_month = 08; } if
Stan> The statements involving "Aug" and "Sep" get flagged
Stan> with the following error messages:
If you prefix a numerical value with `0' perl will treat it
as octal (which is quite normal in computing things).
Therefore `8' and `9' are not legal octal digits.
Instead of `08' you mean just `8'. Formatting into a 2
digit string (perldoc -f sprintf) @ISA different
kettle{fish} altogether.
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/
"Everything I am, I learned on the back of cereal boxes" ~ RJ, "Over the Hedge"
------------------------------
Date: Mon, 16 Mar 1998 17:03:49 -0500
From: Mark Feit <mfeit@pop.net>
Subject: Re: Illegal octal digit error?
Message-Id: <350DA1C5.18AD@pop.net>
Stan Horwitz wrote:
>
> Could someone please tell me what an "illegal octal digit" error message
> means in Perl5 on HP Unix? I have a sequence of 12 "if" statements, all of
> which are identical in format. Those 12 statements are:
> ...
> if ($in_month eq "Aug") { $trans_month = 08; }
> if ($in_month eq "Sep") { $trans_month = 09; }
Numbers which begin with a zero are evaluated octally (base eight).
Since a base eight system only has eight digits (0-7), 08 and 09 are
invalid.
You also might consider putting your month values into a hash and
looking them up that way. Might be faster and make your code easier to
read.
-- Mark
------------------------------
Date: Mon, 16 Mar 1998 21:58:41 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: Illegal octal digit error?
Message-Id: <350DA091.4BB@world.northgrum.com>
Stan Horwitz wrote:
...
> if ($in_month eq "Jul") { $trans_month = 07; }
> if ($in_month eq "Aug") { $trans_month = 08; }
> if ($in_month eq "Sep") { $trans_month = 09; }
...
> The statements involving "Aug" and "Sep" get flagged with the following
> error messages:
>
> Illegal octal digit at convert.pl line 121, at end of line
> Illegal octal digit at convert.pl line 122, at end of line
>
Numeric literals beginning with a zero are assumed to be octal,
so they can only contain digits 0-7. If you want to preserve
leading zeroes, use string literals like '08' (with quotes).
This is documented on the perldata man page.
--
Charles G. Margolin DSSD Internal Information Services
cmargoli@world.northgrum.com Northrop Grumman Corp. 0624/23
margolin@acm.org Hawthorne, California 90250-3277
------------------------------
Date: Mon, 16 Mar 1998 21:57:29 GMT
From: Jim Stern <jstern@world.northgrum.com>
Subject: Re: Illegal octal digit error?
Message-Id: <350DA049.BB7ACA6E@world.northgrum.com>
Stan Horwitz wrote:
>
> Could someone please tell me what an "illegal octal digit" error message
> means in Perl5 on HP Unix? I have a sequence of 12 "if" statements, all of
> which are identical in format. Those 12 statements are:
>
> if ($in_month eq "Jan") { $trans_month = 01; }
> if ($in_month eq "Feb") { $trans_month = 02; }
> if ($in_month eq "Mar") { $trans_month = 03; }
> if ($in_month eq "Apr") { $trans_month = 04; }
> if ($in_month eq "May") { $trans_month = 05; }
> if ($in_month eq "Jun") { $trans_month = 06; }
> if ($in_month eq "Jul") { $trans_month = 07; }
> if ($in_month eq "Aug") { $trans_month = 08; }
> if ($in_month eq "Sep") { $trans_month = 09; }
> if ($in_month eq "Oct") { $trans_month = 10; }
> if ($in_month eq "Nov") { $trans_month = 11; }
> if ($in_month eq "Dec") { $trans_month = 12; }
>
> The statements involving "Aug" and "Sep" get flagged with the following
> error messages:
>
> Illegal octal digit at convert.pl line 121, at end of line
> Illegal octal digit at convert.pl line 122, at end of line
> [...]
In Perl, as in C, an integer literal that begins with '0' represents
an octal number. Viz:
perl -we 'print 12," ", 012,"\n"'
prints 12 and 10. The only legal octal digits are 0..7 so the
assignments
to '08' and '09' above are illegal.
You need to eliminate the leading zeroes from those two statements.
You probably should eliminate the other seven leading zeroes as well,
lest they confuse experienced Perl programmers. ("Why did he have to
specify octal there?")
See perldata's "Scalar value constructors" section and search perldiag
for 'octal'.
--
Jim Stern -- Views here are my own, not my employer's. (Hawthorne, CA)
------------------------------
Date: 16 Mar 1998 22:37:03 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Large programs: is Perl up to it?
Message-Id: <890088189.526968@thrush.omix.com>
Jean-Louis Leroy <jll@skynet.be> wrote:
>snip<
: <G> I should have said 10,000s lines of equivalent C++ code...
From my experience, most Perl code tends to be about 1/5 to
1/10 the size of similar C/C++ code for a given task. This is
vary general of course, but then you're asking a pretty general
question. Given these estimates however, you would only have
1k to 2k lines of Perl code. I've got a few apps I've writen
that are in the 3k to 6k range once you count all the classes and
libs build just for them.
These are server apps mostly so startup costs where not considered.
However, I'm still amazed at how fast some load. Our WebStats
application (an super detailed web log parser) weighs in at just
under 3k lines of code, and it starts up on my machine in 1 to 3
seconds. -A p5/200mhz w/64 megs running FreeBSD, a couple databases,
web servers, news proxy, and some other junk.
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: Mon, 16 Mar 1998 20:58:02 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: Multiple substitues
Message-Id: <slrn6gr4gb.ril.jgloudon@manitoba.bbn.com>
In article <6ek09l$pa7$1@nnrp1.dejanews.com>, dfrench@aig.vialink.com wrote:
>In article <isogz67kjd.fsf@godzilla.kiere.ericsson.se>,
> Calle Dybedahl <qdtcall@esb.ericsson.se> wrote:
>open(F, "somefile");
>@result = <F>;
>close(F);
>for (@result) {s/A/a/g;s/B/b/g;s/C/c/g;}
If you want to do multiple multicharacter search and replaces and there are
so many that it is tedious to type them all in then you want to have your
program write the code for you. You can see something similar to what you
want in `man perlfaq6` under :
"How do I efficiently match many regular expressions at once?"
Perl 5 introduced the map function to give you another way to write this:
@result = map { s/A/a/g;s/B/b/g;s/C/c/g; $_;} @result;
Now if you want to combine multiple "single" character substitutions you can
use a single tr or y operator to do the above 3 substitutions:
@result = map { tr[A-Z][a-z]; $_; } @result;
`man perlop` has more and better examples and explanations than I could give.
Jason Gloudon
------------------------------
Date: 16 Mar 1998 17:49:10 -0500
From: Vivek Khera <khera@kciLink.com>
Subject: Re: Perl and passwd
Message-Id: <x73egiqmjd.fsf@kci.kciLink.com>
>>>>> "S" == Santi <santi@gallet.udg.es> writes:
S> Ther question is on Perl 5.004, Solaris and password change.
S> I'm root (of course) and want to change user passwords from a file.
S> I think that the best way was via passwd, to avoid locking trouble and
S> shadow sync.
S> I've tried openenig a pipe, but...
Instead of using the 'passwd' program, write your code such that it
reads the password file as a file name argument given to it, modifies
what you need, and writes back the file of the same name and exits.
Now, set your VISUAL environment variable to your script, and run
"vipw". All locking and shadow passwords things are taken care of for
you. I assume here that Solaris didn't change how this works from
SunOS 4, which is my last experience administering a Sun system.
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D. Khera Communications, Inc.
Internet: khera@kciLink.com Rockville, MD +1-301-258-8292
PGP/MIME spoken here http://www.kciLink.com/home/khera/
------------------------------
Date: 16 Mar 1998 15:33:14 GMT
From: thospel@mail.dma.be (Ton Hospel)
Subject: Re: Perl Interface to SSH?
Message-Id: <6ejgnq$2j4$1@post.lunix.org>
In article <6dq532$i1l@news.hawaii.edu>,
ehagen@Hawaii.Edu (Eric Hagen) writes:
>
> Hello all.
>
> Has anyone put together scripts for perl to interact with ssh for remote
> commands and file transfer? I would really like to move some of my telnet
> and ftp scripts over to a ssh setup.
>
> Any pointers?
>
> Thank you.
>
> --
> Eric Hagen "Sometimes we get lost in the darkness,
> ehagen@Hawaii.Edu the dreamers learn to steer by the stars..."
> "You fight for something because it is good.
> Not because it stands to succeed."
Sure. I have for example a script that syncs directory hierarchies over ssh.
The ssh core part is:
sub ssh {
my ($pid, $fh);
local(*IN, *IN0, *OUT, *OUT0);
pipe(*IN0, *IN) || die "Could not create input pipe: $!";
pipe(*OUT, *OUT0) || die "Could not create output pipe: $!";
defined($pid = fork()) || die "Could not fork: $!";
if ($pid) { # parent
close(*IN0);
close(*OUT0);
$fh = select(IN);
$| = 1;
select($fh);
return (*OUT, *IN);
} else { # child
close(*IN);
close(*OUT);
unless (open(STDOUT, ">&OUT0")) {
print STDERR "Could not dup OUT0 to STDOUT\n";
exit 1;
}
unless (open(STDIN, "<&IN0")) {
print STDERR "Could not dup IN0 to STDIN\n";
exit 1;
}
close(*IN0);
close(*OUT0);
# Turns of use of authentication agent
delete $ENV{"SSH_AUTH_SOCK"};
exec($::ssh, @_);
# Just some general paranoia
die "Exec failed: $!";
}
}
Or some variation thereof (e.g. you might not want to turn of
the authentication agent, or you want to also send STDERR of ssh into the
pipe.
You might also want to add entries in your .ssh/config like:
Host ssh-perl
BatchMode yes
EscapeChar none
FallBackToRsh no
ForwardAgent no
ForwardX11 no
HostName some.host
User someone
Port 1234
IdentityFile /home/someone/.ssh/ssh-perl_identity
PasswordAuthentication no
RhostsAuthentication no
StrictHostKeyChecking yes
On the site doing the connection generate (with ssh-keygen) an identity
used to connect to some.host in /home/someone/.ssh/ssh-perl_identity, and add
the public part (/home/someone/.ssh/ssh-perl_identity.pub) to the authorized
keys for user someone on some.host with a prefix like this:
from="origin.host",command="/home/someone/libexec/SomeProg",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty 1024 37 123456789012345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678913 sender@origin.host
Then sender@origin.host can login as someone@some.host by just doing
ssh("perl-ssh), where only the program SomeProg gets executed (You can get the
args from an ssh environment variable). This gives you a way to securely
(an attacker must (seem to) come from origin.host, must know your key and
can only execute SomeProg, nor will you by accident connect to a faked client,
unless the hacker stole the host key) execute a controlled remote command with
a binary channel in between the two, without having to give a password.
You just have to be a bit carefull with deadlock though (much like IPC::Open2)
--
I wouldn't quite call it "mark-and-sweep", it's more like "nuke-and-pave"
garbage collection :-)
Matthias Neeracher <neeri@iis.ee.ethz.ch> in
comp.lang.perl about perl garbage collection
------------------------------
Date: Mon, 16 Mar 1998 21:00:28 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: precedence problem
Message-Id: <slrn6gr4ks.ril.jgloudon@manitoba.bbn.com>
In article <350D8A07.D541672F@bellsouth.net>, Michael Lepine wrote:
>I am using the following line of code in a script that I wrote ( it is a
>very trivial line ):
>
>`mv $Temp_File $Update_File` or die "Cannot
>move\n$Temp_File\n\tTO\n$Update_File\n";
You should try printing the return value of a `mv something somewhere`.
Jason Gloudon
------------------------------
Date: 16 Mar 1998 15:08:23 -0600
From: jima@MCS.COM (Jim Allenspach)
Subject: Re: precedence problem
Message-Id: <6ek4c7$o31@Mercury.mcs.net>
Michael Lepine <mlepine@bellsouth.net> writes:
>`mv $Temp_File $Update_File` or die "Cannot
>move\n$Temp_File\n\tTO\n$Update_File\n";
>For some reason, both commands are being executed ( i.e. the file gets
>moved and then the program dies printing the specified message ). I can
>not figure it out.
The results of your backtick operation will be any output produced
(to stdout) by the mv program. Usually, when mv succeeds, it doesn't
produce any output; i.e., the value will be an empty string. This is
interpreted as a false value, and your die is called.
>Does anyone have any
>suggestions???
You can try using the $? variable, which will contain the error
code returned from your last backtick operator:
`mv $old $new`; die "och!" if $?;
Or you can also look into a module solution (File::Copy w/an unlink(),
prehaps?), which would be portable and be more aesthetically pleasing. Hope
this helps.
jma
--
Jim Allenspach Hacking Perl since 1994.
jima at mcs dot com Perl: Live free or die $!;
Chicago IL
------------------------------
Date: Mon, 16 Mar 1998 16:29:50 -0500
From: Dan Boorstein <dboorstein@shopcfn.com>
To: Matthew Cravit <mcravit@shell3.ba.best.com>
Subject: Re: Splitting a string to make keys to a hash
Message-Id: <350D99CE.A3FF3489@shopcfn.com>
Matthew Cravit wrote:
>
> I'm trying to split a string, and use the elements of the split as keys
> to a hash. That is, if I have, for example, the string
>
> "foo:bar:baz=99"
>
[SNIP]
> Can anyone suggest an elegant way of handling this?
how about:
my ($keys, $value) = split '=', 'foo:bar:baz=99';
$keys =~ s/:/}{/g;
eval "\$hash{$keys} = \$value";
--
# dan boorstien <dboorstein@shopcfn.com>
seek DATA,0,0;print scalar<DATA>,__END__
Just another Perl hacker,
------------------------------
Date: 16 Mar 1998 20:49:43 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Unloading subs?
Message-Id: <6ek397$nv2$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Jean-Louis Leroy
<jll@skynet.be>],
who wrote in article <VA.00000007.00ea910a@enterprise>:
> Ok, Perl allows me to AUTOLOAD code on demand. Is there a way to unload
> the code (and reclaim memory) when it's not needed any longer?
There are some problems with closures, but otherwise code is
refcounted. If your subroutine was not initially a closure, just
remove the last link to it.
Something like this
*package::subname = \&undefined;
should work, and may even trigger the autoload. Just make sure there
is no subroutine named undefined!
Ilya
------------------------------
Date: Mon, 16 Mar 1998 16:03:53 -0600
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: User-interface Quandary
Message-Id: <350DA1C8.B3DC09B5@mindspring.com>
This is a trick, right? We'll try to answer, get it wrong, and you'll
flame us all for not reading the FAQ... Sorry. :0)
I'm not 100% sure I understand the 1st two cases. If you try to search
specifying more than 1 word, does it try to match all the words in
order, or match all of the words, or match *any* of the words? Anyway,
assuming that the match is for all the words in order:
Match String (or Match String in Record)
Match Phrase (or Match Phrase in Record)
Match Whole Record
would seem fairly clear, assuming it's not too wordy.
Tom Christiansen wrote:
>
> I have a challenge that I've wracked my head over for a long time now,
> and still I find no solution to it. It's quite simple to explain: I have
> a very simple point-and-drool database frontend for people who are afraid
> of the keyboard or parentheses. The problem is that I can't for the life
> of me figure out how to talk about a complete/exact/entire/everything
> match, like fgrep -x.
>
> Imagine this phrase:
>
> "My name is Fred"
>
> I provide three choices:
>
> Anywhere
> Whole Words Only
> Entire Field
>
> Now, with `Anywhere', a search for "red" will pull up the phrase
> but with `Whole Words Only', it would not. But if they search
> for "Fred", both will match.
>
> Now imagine two phrases:
>
> "My name is Fred"
> "My name is Fred and his is Barney"
>
> If they search for "My name is Fred", both of those will match, whether using
> `Anywhere' or `Whole Words'. However, with `Entire Field', only the first
> one works.
>
> In short, they compile into this, searching for "Fred"
>
> Anywhere /Fred/
> Whole Words Only /\bFred\b/
> Entire Field /^Fred$/
>
> My problem is that I have not in several years come up with anything
> conveys the /^Fred$/ case. I've tried `Entire', but the users always
> think that it means search the entire field, which of course is what
> `Anywhere' does. I've tried `Exact' as in fgrep -x, but because I also
> sometimes have a `Fuzzy' option for agrep style mistakes, they think that
> `Exact' is merely intolerate of spelling errors.
>
> Is there some obvious word or phrase I could use for the /^Fred$/ case?
> I have tried a long time, and nothing seems to work. Users never ever
> understand this.
>
> For an example of all this, see
>
> http://mox.perl.com/cgi-bin/MxScreen
>
> and select the Text query button.
>
> Any insights would be *greatly* appreciated.
>
> --tom
> --
> Tom Christiansen tchrist@jhereg.perl.com
> Sorry. My testing organization is either too small, or too large, depending
> on how you look at it. :-)
> --Larry Wall in <1991Apr22.175438.8564@jpl-devvax.jpl.nasa.gov>
------------------------------
Date: Mon, 16 Mar 1998 14:52:39 -0700
From: Gary Shea <shea@gtsdesign.com>
Subject: warn handler gets SEGV
Message-Id: <350D9F27.59575778@gtsdesign.com>
I have __WARN__ and __DIE__ handlers that log to a file
and send mail. They are functionally about the same, except that the
__DIE__ handler also spews out a web page.
The __DIE__ handler works fine; the __WARN__ handler (which of course
is the only one that returns!) causes all kinds of problems. Some-
times the connection to the web server goes away leaving the process
thrashing; sometimes the process will catch a SEGV during global
destruction.
I've hesitated to dive into the perl source until I'm sure that
noone has already solved this problem or knows what I might be
doing wrong.
-----------------------------------------------------------------
Gary Shea shea@xmission.com
Salt Lake City http://www.xmission.com/~shea
------------------------------
Date: Mon, 16 Mar 1998 15:31:47 -0600
From: anne_lee@mailexcite.com
Subject: Re: webserver configuration/cgi.pm/nt
Message-Id: <6ek5kg$vhv$1@nnrp1.dejanews.com>
backup a little bit, I am currently having problem using CGI.pm (or just
calling CGI) - forget about the cgi-lib. I have a script that works on
command line using CGI.pm, but does not work my EMWAC webserver (got a 404).
If I comment out use CGI; (and other lines that use CGI.pm) it will work.
CGI.pm is under my c:\perl\lib and other cgi.pm's .pm are under
c:\perl\lib\cgi. In c:\perl\lib, I also has cwd.pm, which I used in my script
and works via browser.
Any idea?
In article <34fc7041.8621882@news.alt.net>,
someguy@knick-knack.com (Curtis) wrote:
>
> Using Sarathay's Win32 port I had many problems with scripts that used
cgi-lib.
> I sat down with the perldocs and learned to use CGI.pm and all of my
problems
> went away. Not sure what the problem was, but cgi-lib seems to be the root
of
> it...
>
> --Curtis
>
> On Tue, 03 Mar 1998 15:57:11 GMT, Bill Jones
<webmaster@fccjmail.fccj.cc.fl.us>
> wrote:
>
> >See! I told you I was wrong before :-)
> >
> >Anyways, sometimes you just have to rewrite code...
> >
> >Sorry :-(
> >
> >
> >
> >anne_lee@mailexcite.com wrote:
> >
> >> NT SP 3 did not solve the problem
> >> The script was written for cgi-lib.pl under unix, I am porting it to NT
by
> >> trying to do as little change as possible and narrow down the problem by
doing
> >> simple task.
> >>
> >> In article <34F78276.1226EB25@fccjmail.fccj.cc.fl.us>,
> >> bill@astro.fccj.cc.fl.us wrote:
> >> >
> >> > Service Pack 3 is available and highly recommended.
> >> > Why are you mimicing cgi-lib functionality?
> >> >
> >> > CGI.pm allows html output, headers and all.
> >> >
> >> > I say the problem is - service Pack 3 required...
> >> > (I've been wrong before :-)
> >> >
> >> > HTH,
> >> > Bill
> >>
> >> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> >> http://www.dejanews.com/ Now offering spam-free web-based newsreading
> >
> >
>
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 16 Mar 1998 22:04:33 GMT
From: sglassman@highground.com (Steven M. Glassman)
Subject: Re: Win32 registry functions - docs
Message-Id: <350ea12e.371349372@news.connactivity.com>
"Rigel Vega" <rvega@hotmail.com> wrote:
>With a little help from some web pages, especially
>http://www.inforoute.cgs.fr/leberre1/main.htm, i was able to do a few
>things i needed to do with the Win95 registry. Said page points out that,
>for example, to query a registry value, one must use the
>Win32::RegQueryValueEx function instead of the function QueryValue from
>Win32::registry. The page also states that, for this and other functions
>used as alternatives to those in the Win32::registry module, "the arguments
>are the same as those in the original API."
>
>My question: Where can i find these functions documented? "Real"
>documentation would be best, but i'd be content just to read the code -- if
>i could find it. I searched around through the code in the Perl for Win32
>package but didn't find it. I'd like to know the full description not of
>the functions i've discovered so far, but also what other reigistry-related
>functions may be available.
You can find the Perl registry functions documented in the few pages
of chapter 16 of "Learning Perl on Win32 Systems" by O'Reilley &
Assoc. However, if you are doing windows development under NT, the
"original API" is documented in the Microsoft V/C++ IDE.
------------------------------
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 2111
**************************************