[16926] in Perl-Users-Digest
Perl-Users Digest, Issue: 4338 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 15 18:11:18 2000
Date: Fri, 15 Sep 2000 15:10:24 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <969055824-v9-i4338@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 15 Sep 2000 Volume: 9 Number: 4338
Today's topics:
Re: Qualifications for new Perl programmer????? (Tim Hammerquist)
Re: Qualifications for new Perl programmer????? <bart.lateur@skynet.be>
Question to the Wise - Writing Spaces desertedge@my-deja.com
Re: Question to the Wise - Writing Spaces <eric.kort@vai.org>
Re: Question to the Wise - Writing Spaces (Clinton Pierce)
Re: Question to the Wise - Writing Spaces <notkmetcalf@notlighthousemarketingnot.com>
Question: windows system() crash detection <hooper@research.att.com>
Re: Recursion and prototypes (Abigail)
Re: Recursion and prototypes (Abigail)
Regexp: matching '|' <mayers@bmc.com>
Re: Regexp: matching '|' <lr@hpl.hp.com>
Re: Regexp: matching '|' <jeffp@crusoe.net>
Re: Regexp: matching '|' <lr@hpl.hp.com>
Re: Regexp: matching '|' (Abigail)
Segmentation Fault <Bob.Jones@wku.edu>
Re: Shortest code for Fibonacci? (Tramm Hudson)
Re: Shortest code for Fibonacci? (Abigail)
Re: Shortest code for Fibonacci? (Randal L. Schwartz)
Re: Shortest code for Fibonacci? <jcook@strobedata.com>
Re: sprintf() rounding problem (Abigail)
Re: sprintf() rounding problem (Chris Fedde)
strange warning <thoren@southern-division.com>
Re: strange warning <lr@hpl.hp.com>
Re: strange warning <thoren@southern-division.com>
Re: strange warning <lr@hpl.hp.com>
Re: Text manipulation: translating several token at onc <lr@hpl.hp.com>
to Eric: web server is running.. <csc4aal@erols.com>
Re: to Eric: web server is running.. <eric.kort@vai.org>
Re: to Eric: web server is running.. <christopher_j@uswest.net>
uninitialized variables <mdeggers@earthlink.net>
Re: uninitialized variables <lr@hpl.hp.com>
Re: uninitialized variables <hartleh1@westat.com>
Which book/site should I use? I really can't choose. <lemsgaard@hotmailERASETHIS.com>
Re: Which book/site should I use? I really can't choose <anders@wall.alweb.dk>
Why does * in a string glob? <dji@myriad.com>
Re: Why does * in a string glob? <anders@wall.alweb.dk>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 15 Sep 2000 17:57:36 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <slrn8s4pgn.jp.tim@degree.ath.cx>
Chris Fedde <cfedde@u.i.sl3d.com> wrote:
> >In article <Eccw5.17275$a5.244729@news1.rdc1.mb.home.com>,
> >if you start teaching a beginner in perl.....would would he,
> >say....know of sorting routines, lists, trees, graphs...
>
> Why is it important to learn this stuff as a begining programmer?
> Surely we do not teach sentance structure to childeren learning to
> talk. Nether do we start first grade math students with Principia
> Mathematica.
(Spelling, however, _is_ taught in elementary school.)
At a college level, many of these things are taught before the students
even learn the beginning of a language; that's part of what makes
"Computer Science." And these are the reasons that 12 credits of
Calculus are required to complete a CS degree at the university I
attended. Programming is _not_ just dinking around and doing cool
little tricks.
Listen to Randy Schwartz on the subject:
From merlyn@stonehenge.com Thu Jul 27 16:44:58 2000
}} Programming is a weird art. The money to be made programming has
}} attracted a lot of people who really don't belong in the biz. It's ok
}} to tinker on your own time, but I see people come through my classes
}} every week that just really shouldn't be paid as programmers. They
}} string together things with cut-n-paste at random. They seem to lack
}} the ability to take a concrete example and abstract the essence from
}} it. And yet they've been placed into jobs requiring such skills,
}} either because the employers are so desperate, or they're really good
}} at BS'ing themselves or their future bosses.
}}
}} My rule of thumb - anyone who thinks that the act of programming is
}} worth less than $50/hr should leave the industry. :)
}}
}} (OK, I'll get flamed on that, but it would sure help me distinguish
}} what I *can* do in an hour from what most people *attempt* to do in an
}} hour. :)
> Make programming interesting and give the student tools to solve a problem
> that is real to them. Then if they are interested enough they will start
> finding out about all that other neat stuff like linked lists, graphs and
> such.
I've seen people in the situation you describe. One in particular was a
"professional" web designer. His tools? A hacked-up version of
HomeSite working entirely in Design (WYSIWYG) mode, and javascript
compliments of dynamicdrive.com. He couldn't debug HTML, much less
JavaScript, and during the few months we worked together my job was
primarily to decipher what he was _trying_ to do and actually get it to
work. He's what Randy described above. The assumption that an
interested "student" will _develop_ an interest in more advanced
practices and algorithms (much less learn what an algorithm _is_) is
a much bigger leap than my experience will let me take.
--
-Tim Hammerquist <timmy@cpan.org>
Dozens of people spontaneously combust each year,
it's just not really widely reported.
-- David St. Hubbins, "This is Spinal Tap"
------------------------------
Date: Fri, 15 Sep 2000 19:37:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <iju4ssor6ngd7rh6qvm9d0utn2h0a8d0cl@4ax.com>
Brendon Caligari wrote:
>No
>strict types and checking, no real pointers, the richness of the
>language all risk the beginner become lazier and not appreciate the
>underlying foundations.
Hmmm... it appears to me as if you don't have any (self-) discipline,
you won't get any working code either.
--
Bart.
------------------------------
Date: Fri, 15 Sep 2000 18:59:20 GMT
From: desertedge@my-deja.com
Subject: Question to the Wise - Writing Spaces
Message-Id: <8ptrht$ej8$1@nnrp1.deja.com>
This is a Perl/HTML question.
I am reading from a field within a database which has visually
important fixed width font, with spaces to separate fields...example:
Account Your Name Your Social Your Your
233333 Me 39393939 Hello
These are all spaces separating the visual fields, and their would be
many lines of this data all within one string.
My question is:
I need to read this data, and print it to an HTML file "as is". To save
the VB programmer days, or months, of re-formating the data to html
tables, is there a way that I can tell the browser to print the spaces
encountered instead of crunching them.
Instead of "I like spaces" I'd like to see "I LIKE Spaces"
Thank you,
Justin
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 15 Sep 2000 15:17:02 -0400
From: "Eric" <eric.kort@vai.org>
Subject: Re: Question to the Wise - Writing Spaces
Message-Id: <8ptsg1$thu$1@msunews.cl.msu.edu>
<desertedge@my-deja.com> wrote in message
news:8ptrht$ej8$1@nnrp1.deja.com...
<<snip>>
> is there a way that I can tell the browser to print the spaces
> encountered instead of crunching them.
>
> Instead of "I like spaces" I'd like to see "I LIKE Spaces"
HTML recognizes   as a "hard" space--you can put as many as you like,
and it will print them all. So have your script replace each space with
 . As for capitalizing like to LIKE that's a different matter =)
hth
Eric
------------------------------
Date: Fri, 15 Sep 2000 19:38:55 GMT
From: clintp@geeksalad.org (Clinton Pierce)
Subject: Re: Question to the Wise - Writing Spaces
Message-Id: <jVuw5.48646$QW4.553504@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <8ptrht$ej8$1@nnrp1.deja.com>,
desertedge@my-deja.com writes:
> This is a Perl/HTML question.
Well, no. It's really just HTML.
> I need to read this data, and print it to an HTML file "as is". To save
> the VB programmer days, or months, of re-formating the data to html
> tables, is there a way that I can tell the browser to print the spaces
> encountered instead of crunching them.
is one way to get a space that won't be "crunched". But you'll wind up
with other issues like proportional fonts that will cause your column alignment
to go spastic.
This is what the <PRE> tag was invented for. Give it a try.
PS: That was &nbsp; and <PRE> in case your browser mis-renders
that. I've never put HTML in a Usenet posting before... I wonder if
the browser-that-is-also-a-newsreader does the Right Thing.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: 15 Sep 2000 20:14:43 GMT
From: Kevin Metcalf <notkmetcalf@notlighthousemarketingnot.com>
Subject: Re: Question to the Wise - Writing Spaces
Message-Id: <39C283A0.24BF4390@notlighthousemarketingnot.com>
While it is true that you could use to force the issue, it would
probably be easier to use the <pre> tag before your data, and the </pre>
tag after it. This forces a FIXED WIDTH font, without which any of your
that add won't look all that great.
Kevin
desertedge@my-deja.com wrote:
> This is a Perl/HTML question.
>
> I am reading from a field within a database which has visually
> important fixed width font, with spaces to separate fields...example:
>
> Account Your Name Your Social Your Your
> 233333 Me 39393939 Hello
>
> These are all spaces separating the visual fields, and their would be
> many lines of this data all within one string.
>
> My question is:
> I need to read this data, and print it to an HTML file "as is". To save
> the VB programmer days, or months, of re-formating the data to html
> tables, is there a way that I can tell the browser to print the spaces
> encountered instead of crunching them.
>
> Instead of "I like spaces" I'd like to see "I LIKE Spaces"
>
> Thank you,
>
> Justin
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Fri, 15 Sep 2000 21:27:31 GMT
From: Robert Hooper <hooper@research.att.com>
Subject: Question: windows system() crash detection
Message-Id: <39C29443.BC978BC1@research.att.com>
Here's my problem, I'm running a perl script on a Win98 machine and using system() to
call another program, repeatedly. Sometimes the other program crashes and a
window comes up with a details and cancel button ( we've all seen this window before ;) )
Anyway I don't care that it died, but I do care that its stopped on this window
until I click cancel, I just want it to end and the perl script to continue without my
intervention. Is there anyway to have perl catch this event and keep going?
------------------------------
Date: 15 Sep 2000 21:39:24 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Recursion and prototypes
Message-Id: <slrn8s55ma.4mc.abigail@alexandra.foad.org>
Marco Natoni (foo@bar.va) wrote on MMDLXXII September MCMXCIII in
<URL:news:39C24306.91C31DEB@bar.va>:
!! Hi,
!!
!! The tiredness make me blind when searching the cause of the warning:
!!
!! > Prototype mismatch: sub main::search ($$) vs none at
--------------------- ----
!! > tree.pl line 30. | |
!! | |
!! running the script: | |
!! | |
!! 12. sub search ($$); | |
!! ----------- | |
!! . | |
!! /|\ | |
!! | | |
!! `---------------------' |
!! 13. |
!! 14. sub search { |
!! ------ |
!! . |
!! /|\ |
!! | |
!! `-----------------------------------------'
Abigail
--
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-
# A nesting swallow.
# No ducks swim towards a temple.
# A singing thrush.
------------------------------
Date: 15 Sep 2000 21:40:19 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Recursion and prototypes
Message-Id: <slrn8s55o1.4mc.abigail@alexandra.foad.org>
Marco Natoni (foo@bar.va) wrote on MMDLXXII September MCMXCIII in
<URL:news:39C24902.A5F5CE51@bar.va>:
&& John,
&&
&& "John J. Trammell" wrote:
&& >> The tiredness make me blind when searching the cause of the
&& >> warning:
&& >> > Prototype mismatch: sub main::search ($$) vs none at
&& >> > tree.pl line 30.
&& >>
&& >> <snip>
&& >>12. sub search ($$);
&& > OK.
&& >>14. sub search {
&& > Should read "sub search ($$) {".
&&
&& Thank you. Meanwhile, I have experimented that, without prototype,
&& the good old syntax:
&&
&& &search ($level+1,$key);
&&
&& works as well as the newest form: Can you see any potential danger in
&& this syntax?
Then you won't get a warning if you have to few or to many arguments.
Abigail
--
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
------------------------------
Date: Fri, 15 Sep 2000 11:17:01 -0700
From: Mike Ayers <mayers@bmc.com>
Subject: Regexp: matching '|'
Message-Id: <39C2679D.269CB@bmc.com>
Consider the following:
===========8<--------SNIP--------------------
DB<17> $tp='abc|def'
DB<18> p $tp
abc|def
DB<19> if ( $tp =~ m|^([^\|]*)[\|]([^\|]*)| ){print('Matched
',$1,",",$2);}else{print('No match');}
Matched abc,def
DB<20> if ( $tp =~ m|^([^\|]*)\x7c([^\|]*)| ){print('Matched
',$1,",",$2);}else{print('No match');}
Matched abc,def
DB<21> if ( $tp =~ m|^([^\|]*)\|([^\|]*)| ){print('Matched
',$1,",",$2);}else{print('No match');}
Matched abc,
DB<22>
===========8<--------SNIP--------------------
I am content to use '[\|]' to match the literal bar. However, I would
like to understand what the standalone '\|' is attempting (and failing)
to match. Would someone kindly enlighten me?
TiA,
/|/|ike
------------------------------
Date: Fri, 15 Sep 2000 11:52:00 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regexp: matching '|'
Message-Id: <MPG.142c0fabc7522c0598ad77@nntp.hpl.hp.com>
In article <39C2679D.269CB@bmc.com> on Fri, 15 Sep 2000 11:17:01 -0700,
Mike Ayers <mayers@bmc.com> says...
+
+ Consider the following:
+
+ ===========8<--------SNIP--------------------
+ DB<17> $tp='abc|def'
+
+ DB<18> p $tp
+ abc|def
+ DB<19> if ( $tp =~ m|^([^\|]*)[\|]([^\|]*)| ){print('Matched
+ ',$1,",",$2);}else{print('No match');}
+ Matched abc,def
+ DB<20> if ( $tp =~ m|^([^\|]*)\x7c([^\|]*)| ){print('Matched
+ ',$1,",",$2);}else{print('No match');}
+ Matched abc,def
+ DB<21> if ( $tp =~ m|^([^\|]*)\|([^\|]*)| ){print('Matched
+ ',$1,",",$2);}else{print('No match');}
+ Matched abc,
+ DB<22>
+ ===========8<--------SNIP--------------------
+
+ I am content to use '[\|]' to match the literal bar. However, I
+ would like to understand what the standalone '\|' is attempting (and
+ failing) to match. Would someone kindly enlighten me?
It isn't trying to match anything. It is acting as the regex
metacharacter '|', signifying alternation. The left part matches, the
right part doesn't match, so the regex matches but $2 is undefined.
(Turn warnings on next time!).
The problem goes away if you use a different character to delimit the
regex. So I can only presume that the escaped '|' is recognized as not
terminating the regex, but not further as an escaped literal '|'.
Why are you causing yourself this pain with an inappropriate choice of
regex delimiters, when there are so many to choose from (including
matched pairs of brackets)? Note that if '|' isn't the regex delimiter,
then 'not |' can be written as [^|] with no escape needed.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 15 Sep 2000 16:20:37 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Regexp: matching '|'
Message-Id: <Pine.GSO.4.21.0009151619001.12100-100000@crusoe.crusoe.net>
[posted & mailed]
On Sep 15, Mike Ayers said:
> DB<17> $tp='abc|def'
> DB<21> if ( $tp =~ m|^([^\|]*)\|([^\|]*)| ){print('Matched
>',$1,",",$2);}else{print('No match');}
>Matched abc,
> I am content to use '[\|]' to match the literal bar. However, I would
>like to understand what the standalone '\|' is attempting (and failing)
>to match. Would someone kindly enlighten me?
Since you are using | as your m// delimiter, any | in the regex that is
NOT meant to be the closing delimiter must be backslashed. But this
backslashing just tells Perl that it's NOT the delimiter, that it's a
|. And a | in a regex is alternation. Try using a different m//
delimiter, or doing
m!foo\\\|bar!
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Fri, 15 Sep 2000 13:46:40 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regexp: matching '|'
Message-Id: <MPG.142c2a8d8a326d8498ad7b@nntp.hpl.hp.com>
In article <Pine.GSO.4.21.0009151619001.12100-100000@crusoe.crusoe.net>
on Fri, 15 Sep 2000 16:20:37 -0400, Jeff Pinyan <jeffp@crusoe.net>
says...
> On Sep 15, Mike Ayers said:
>
> > DB<17> $tp='abc|def'
> > DB<21> if ( $tp =~ m|^([^\|]*)\|([^\|]*)| ){print('Matched
> >',$1,",",$2);}else{print('No match');}
> >Matched abc,
>
> > I am content to use '[\|]' to match the literal bar. However, I would
> >like to understand what the standalone '\|' is attempting (and failing)
> >to match. Would someone kindly enlighten me?
>
> Since you are using | as your m// delimiter, any | in the regex that is
> NOT meant to be the closing delimiter must be backslashed. But this
> backslashing just tells Perl that it's NOT the delimiter, that it's a
> |. And a | in a regex is alternation. Try using a different m//
> delimiter, or doing
>
> m!foo\\\|bar!
That would match against 'foo\\|bar' (one backslash in the string
there). Presumably you meant:
m|foo\\\|bar|
But unfortunately that doesn't match 'foo|bar' either. The regex
vertical bar still means alternation.
I'm beginning to think that you simply cannot match against an escaped
literal regex metacharacter that is also the regex delimiter. Not as if
one *needs* to!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 15 Sep 2000 21:47:45 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Regexp: matching '|'
Message-Id: <slrn8s565v.4mc.abigail@alexandra.foad.org>
Mike Ayers (mayers@bmc.com) wrote on MMDLXXII September MCMXCIII in
<URL:news:39C2679D.269CB@bmc.com>:
``
`` Consider the following:
``
`` ===========8<--------SNIP--------------------
`` DB<17> $tp='abc|def'
``
`` DB<18> p $tp
`` abc|def
`` DB<19> if ( $tp =~ m|^([^\|]*)[\|]([^\|]*)| ){print('Matched
`` ',$1,",",$2);}else{print('No match');}
`` Matched abc,def
`` DB<20> if ( $tp =~ m|^([^\|]*)\x7c([^\|]*)| ){print('Matched
`` ',$1,",",$2);}else{print('No match');}
`` Matched abc,def
`` DB<21> if ( $tp =~ m|^([^\|]*)\|([^\|]*)| ){print('Matched
`` ',$1,",",$2);}else{print('No match');}
`` Matched abc,
`` DB<22>
`` ===========8<--------SNIP--------------------
``
`` I am content to use '[\|]' to match the literal bar. However, I would
`` like to understand what the standalone '\|' is attempting (and failing)
`` to match. Would someone kindly enlighten me?
Because | is special in regexes. Normally, you'd be able to escape that
by backwacking it, but you spend your backwack already by escaping it
from being it seen as a delimiter. You can't reuse the backwack.
Perhaps it's better not to use a regex meta-character as delimiter if
you intend to use that meta-character in the regex as well.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: Fri, 15 Sep 2000 13:59:41 -0500
From: Bob Jones <Bob.Jones@wku.edu>
Subject: Segmentation Fault
Message-Id: <39C2719D.2F74903C@wku.edu>
Ok, I'm having a problem here that I hope you all can help me out with.
I'm trying to authenticate against an LDAP database using the Mozilla C
SDK. I have included my program at the bottom for you to check out.
Whenever I try to use it I'm getting a Segmentation Fault (core dumped)
error. I have no idea what could be causing this and would appreciate
any help.
Thanks in advance
Bob Jones
Bob.Jones@WKU.EDU
#!/usr/local/bin/perl5
use Mozilla::LDAP::Conn;
#
# Configuration part, change this
#
$BASE = "dc=ldap,dc=wku,dc=edu";
$EMAIL = $ARGV[0];
$PASS = $ARGV[1];
# Get User Name from E-mail Address
($USER,$tmp) = split(/@/,$EMAIL,2);
$conn = new Mozilla::LDAP::Conn({ "host" => "localhost",
"port" => "389"} );
die "Can't get an LDAP connection" unless $conn;
#
# Try to find the user using the UID, CN and last MAIL attributes.
#
$entry = $conn->search($BASE, "SUB", "(uid=$USER)", 0, ("1.1"));
if (!$entry || $conn->nextEntry()) {
$entry = $conn->search($BASE, "SUB", "(cn=$USER)", 0, ("1.1"));
if (!$entry || $conn->nextEntry()) {
$entry = $conn->search($BASE, "SUB", "(mail=$USER)", 0, ("1.1"));
$dn = $entry->getDN() if ($entry && ! $conn->nextEntry());
} else {
$dn = $entry->getDN();
}
} else {
$dn = $entry->getDN();
}
#
# Now let's verify the authentication credentials, by rebinding with the
# users DN and password. Note that this leaves the connection bound
# as the user, do another simpleAuth() to rebind as anonymous again.
#
$authenticated = 0;
if (($PASS ne "") && ($dn ne "") && ($conn->simpleAuth($dn, $PASS))) {
print("It worked.");
$authenticated = 1;
}
if ($authenticated == 0) {
print("It failed.");
}
------------------------------
Date: 15 Sep 2000 18:07:55 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Shortest code for Fibonacci?
Message-Id: <8ptohr$din$1@sloth.swcp.com>
[posted and cc'd to cited author, even though he should start a new thread]
Clint Mario Cleetus <cmc77@pantheon.yale.edu> wrote:
>I am looking for a concise and elegant way to calculate the Fibonacci
>Number corresponding to a given number. But it should also avoid recursion
>in order to be efficient. I wrote a standard subroutine for this:
What do you mean "to a given number"? From your code, it appears that
you want to write a function that produces the nth value of the
Fibonacci sequence.
[snip of typical C style code]
>But this seems to be like any other standard C subroutine. Please let me
>know if you have one-liners or atleast a much more elegant solution for
>this.
DANGER! Homework alert...
my @f = (0,1,1); sub fib { return $f[$_[0]] ||= fib($_[0]-1) + fib($_[0]-2) }
But it is still recursive. It does memoize the results in a good dynamic
programming manner and worst case runtime is linear with the value of its
first argument. Best case is O(1).
How about a solution that is always O(1)?
my ($Phi,$phi) = ( sqrt(5/4)-0.5, -sqrt(5/4)-0.5 );
sub fib2 { return abs int(($Phi**$_[0] - $phi**$_[0])/sqrt(5)) }
Yes, it is a constant time solution, but a proof of correctness is left
as an exercise to the "student".
Tramm
--
o hudson@swcp.com hudson@turbolabs.com O___|
/|\ http://www.swcp.com/~hudson/ H 505.323.38.81 /\ \_
<< KC5RNF @ N5YYF.NM.AMPR.ORG W 505.986.60.75 \ \/\_\
0 U \_ |
------------------------------
Date: 15 Sep 2000 19:01:06 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Shortest code for Fibonacci?
Message-Id: <slrn8s4sdh.4mc.abigail@alexandra.foad.org>
Tramm Hudson (hudson@swcp.com) wrote on MMDLXXII September MCMXCIII in
<URL:news:8ptohr$din$1@sloth.swcp.com>:
`'
`' How about a solution that is always O(1)?
`'
`' my ($Phi,$phi) = ( sqrt(5/4)-0.5, -sqrt(5/4)-0.5 );
`' sub fib2 { return abs int(($Phi**$_[0] - $phi**$_[0])/sqrt(5)) }
How do you raise powers in constant time?
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
------------------------------
Date: 15 Sep 2000 12:19:33 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Shortest code for Fibonacci?
Message-Id: <m1wvgd79a2.fsf@halfdome.holdit.com>
>>>>> "Abigail" == Abigail <abigail@foad.org> writes:
Abigail> Tramm Hudson (hudson@swcp.com) wrote on MMDLXXII September MCMXCIII in
Abigail> <URL:news:8ptohr$din$1@sloth.swcp.com>:
Abigail> `'
Abigail> `' How about a solution that is always O(1)?
Abigail> `'
Abigail> `' my ($Phi,$phi) = ( sqrt(5/4)-0.5, -sqrt(5/4)-0.5 );
Abigail> `' sub fib2 { return abs int(($Phi**$_[0] - $phi**$_[0])/sqrt(5)) }
Abigail> How do you raise powers in constant time?
use POSIX qw(pause);
{
local $SIG{ALARM} = sub { die };
alarm(5);
$result = $base ** $power;
pause;
}
:-)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 15 Sep 2000 12:28:38 -0700
From: Jim Cook <jcook@strobedata.com>
Subject: Re: Shortest code for Fibonacci?
Message-Id: <39C27866.5D6C4C8B@strobedata.com>
> `' How about a solution that is always O(1)?
> `'
> `' my ($Phi,$phi) = ( sqrt(5/4)-0.5, -sqrt(5/4)-0.5 );
> `' sub fib2 { return abs int(($Phi**$_[0] - $phi**$_[0])/sqrt(5)) }
>
> How do you raise powers in constant time?
How about exp(log(x)*y) for x**y? Granted, there might be some
optimizations which affect it slightly, but it's still O(1)
--
jcook@strobedata.com Live Honourably 4/1 - 4/3 + 4/5 - 4/7 + . . .
2000 Tuesdays: Feb/last 4/4 6/6 8/8/ 10/10 12/12 9/5 5/9 7/11 11/7 3/14
Strobe Data Inc. home page http://www.strobedata.com
My home page O- http://jcook.net
------------------------------
Date: 15 Sep 2000 18:57:58 GMT
From: abigail@foad.org (Abigail)
Subject: Re: sprintf() rounding problem
Message-Id: <slrn8s4s7k.4mc.abigail@alexandra.foad.org>
David Hugh-Jones (davidhj@mail.com) wrote on MMDLXXII September MCMXCIII
in <URL:news:969030633.490324812@news.uklinux.net>:
`'
`' The user input actually comes in the form of a text config file which gets
`' read. But, anyway, I don't think the multiply by 100 idea solves it: I
`' still have to add 17.5% Value Added Tax, which is going to give floating poin
`' results even with integer input.
I'm sure that if you buy something in the store that as 17.5% value tax,
you don't end up paying an amount that isn't expressable as an integer
number of pennies.
Why don't you apply the same rules?
Abigail
--
perl -wle'print"Êõóô áîïôèåò Ðåòì Èáãëåò"^"\x80"x24'
# A pair of old men
# under an elm. A kingfisher
# above a stream.
------------------------------
Date: Fri, 15 Sep 2000 21:23:45 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: sprintf() rounding problem
Message-Id: <Brww5.170$W3.171844608@news.frii.net>
In article <969030633.490324812@news.uklinux.net>,
David Hugh-Jones <davidhj@mail.com> wrote:
>
>The user input actually comes in the form of a text config file which gets
>read. But, anyway, I don't think the multiply by 100 idea solves it: I
>still have to add 17.5% Value Added Tax, which is going to give floating point
>results even with integer input.
>
>dave
It's possible to do fixed place math in Perl. One way is to use
Math::BigInt. Multiply incoming values by the right adjuster, Do
what you want, then stuff a decimal in on output. For rounding
money you need to pick a method that preserves pennies. One method
that is common is round up if thousandths is 5 or greater and down
otherwise. Since half of the transactions are credits and half
are debits the pennies will balance out.
#!/usr/bin/perl
use warnings;
use strict;
use Math::BigInt;
use constant Places=>3;
my $balance = Math::BigInt->new( '123456784'.'0'x Places );
my $rate = Math::BigInt->new( 17.5 * 10**Places );
my $newbal = $balance + $balance*$rate/12;
my $dist = $newbal/45;
my $other = $newbal/7;
print join(" ", $newbal, $dist, $other), "\n";
print join(" ", map {displaycents($_)} $newbal, $dist, $other), "\n";
sub displaycents
{
my $amt = shift;
$amt += substr($amt, -1, 1) < 5 ? 0 : 10;
$amt = $amt->bnorm;
substr($amt, -1*Places, 0) = ".";
substr($amt, -1, 1) = '';
return $amt;
}
chris
--
This space intentionally left blank
------------------------------
Date: Fri, 15 Sep 2000 21:29:34 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: strange warning
Message-Id: <8pttbr$2t5$12$1@news.t-online.com>
consider this programm:
#!/usr/local/bin/perl -w
use strict;
$_ = 'one';
for my $line (1..5) {
/one/../two/
? (print "$line : $_\n" and $_ = 'two')
: ($_ = 'one' and redo)
}
you get a warning:
Found = in conditional, should be == at /usr/home/thoren/test.pl line 9.
replacing the 'constants' with variables it works without warning:
#!/usr/local/bin/perl -w
use strict;
my $one = 'one';
my $two = 'two';
$_ = $one;
for my $line (1..5) {
/one/../two/
? (print "$line : $_\n" and $_ = $two)
: ($_ = $one and redo)
}
where's the problem?
gruß
thoren
8#X
--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com
------------------------------
Date: Fri, 15 Sep 2000 12:48:56 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: strange warning
Message-Id: <MPG.142c1d056c8cfc3298ad7a@nntp.hpl.hp.com>
In article <8pttbr$2t5$12$1@news.t-online.com> on Fri, 15 Sep 2000
21:29:34 +0200, Thoren Johne <thoren@southern-division.com> says...
...
> ? (print "$line : $_\n" and $_ = 'two')
> : ($_ = 'one' and redo)
> }
>
> you get a warning:
> Found = in conditional, should be == at /usr/home/thoren/test.pl line 9.
...
> where's the problem?
You are using a conditional operator ('and') instead of a sequencing
operator (','). Perl warns when it knows the result of the condition
regardless of the data.
? print("$line : $_\n"), $_ = 'two'
: ($_ = 'one', redo)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 15 Sep 2000 22:23:53 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: Re: strange warning
Message-Id: <8pu0g9$4dg$12$1@news.t-online.com>
Larry Rosler <lr@hpl.hp.com> wrote in message
news:MPG.142c1d056c8cfc3298ad7a@nntp.hpl.hp.com...
> In article <8pttbr$2t5$12$1@news.t-online.com> on Fri, 15 Sep 2000
> 21:29:34 +0200, Thoren Johne <thoren@southern-division.com> says...
>
> ...
>
> > ? (print "$line : $_\n" and $_ = 'two')
> > : ($_ = 'one' and redo)
> > }
> >
> > you get a warning:
> > Found = in conditional, should be == at /usr/home/thoren/test.pl line 9.
>
> ...
>
> > where's the problem?
>
> You are using a conditional operator ('and') instead of a sequencing
> operator (','). Perl warns when it knows the result of the condition
> regardless of the data.
>
> ? print("$line : $_\n"), $_ = 'two'
> : ($_ = 'one', redo)
a comma at this place? where did i missed that in the docu?
anyway - it only works for me if i keep the brackets around the if case:
? ( print("$line : $_\n"), $_ = 'two' )
: ($_ = 'one', redo)
gruß
thoren
8#X
--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com
------------------------------
Date: Fri, 15 Sep 2000 14:21:31 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: strange warning
Message-Id: <MPG.142c32ba9ca6261798ad7c@nntp.hpl.hp.com>
In article <8pu0g9$4dg$12$1@news.t-online.com> on Fri, 15 Sep 2000
22:23:53 +0200, Thoren Johne <thoren@southern-division.com> says...
> Larry Rosler <lr@hpl.hp.com> wrote in message
> news:MPG.142c1d056c8cfc3298ad7a@nntp.hpl.hp.com...
...
> > ? print("$line : $_\n"), $_ = 'two'
> > : ($_ = 'one', redo)
>
> a comma at this place? where did i missed that in the docu?
perlop:
Comma Operator
Binary ``,'' is the comma operator. In scalar context it evaluates its
left argument, throws that value away, then evaluates its right argument
and returns that value. This is just like C's comma operator.
> anyway - it only works for me if i keep the brackets around the if case:
>
> ? ( print("$line : $_\n"), $_ = 'two' )
> : ($_ = 'one', redo)
Sigh, yes. I took them out deliberately, but didn't retest it.
This is actually a difference in the Perl expression grammar from the C
grammar, whose purpose isn't clear to me.
Excerpting from the C grammar:
conditional-expression:
logical-OR-expression
logical-OR-expression ? expression : conditional-expression
assignment-expression:
conditional-expression
unary-expression assignment-operator assignment-expression
expression:
assignment-expression
expression, assignment-expression
So in C, any expression at all can appear between the '?' and the ':'.
The Perl grammar should be the same, though expressions exist with lower
precedence yet than the comma-expression called simply 'expression' in
the above grammar.
Perl accepts an assignment-expression between '?' and ':', but not a
comma-expression. Probably this has to do with the possibility of the
comma being part of a list operator:
1 ? unlink 'bar', 'baz' : 2
But this list-comma operator is disambiguated from the scalar-comma
operator in every other context. Why not here?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 15 Sep 2000 11:00:51 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Text manipulation: translating several token at once
Message-Id: <MPG.142c03aa35e7d2e798ad74@nntp.hpl.hp.com>
In article <slrn8s4n6i.4mc.abigail@alexandra.foad.org> on 15 Sep 2000
17:32:04 GMT, Abigail <abigail@foad.org> says...
+ Larry Rosler (lr@hpl.hp.com) wrote on MMDLXXII September MCMXCIII in
+ <URL:news:MPG.142b54664e549bde98ad6e@nntp.hpl.hp.com>:
+ .. In article <JRhw5.1682$jC4.274850@typhoon.southeast.rr.com>,
+ .. philipg@atl.mediaone.net says...
+ ..
+ .. > my %elements =
+ .. > ( H => 'Hydrogen', O => 'Oxygen', N => 'Nitrogen' );
+ .. > my $text = 'H O N';
+ .. >
+ .. > $text =~ s/(\w)/$elements{$1}/g;
+ .. > print "$text\n";
+ ..
+ .. my %elements = ( H => 'Hydrogen', O => 'Oxygen',
+ .. N => 'Nitrogen', Ne => 'Neon', );
+ .. my $text = 'H2O N Ne Foo';
+
+ Well, H2O isn't in the periodic chart.
That's a shock! But the problem definition doesn't say what to do with
it.
+ ..
+ .. $text =~ s/([A-Za-z]+)/$elements{$1} || $1/eg;
+ .. print "$text\n";
+
+ That would turn 'H2O' into 'Hydrogen2Oxygen'. Maybe that's wanted, but
+ then it wouldn't quite work for 'CH4'. Not to mention what happens to
+ 'CH2O'.
With the more elaborate regex and substitution that I posted this
morning (and adding "C => 'Carbon," to the hash),
CarbonHydrogen4 CarbonHydrogen2Oxygen
Looks pretty good to me! :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 15 Sep 2000 17:20:50 -0400
From: "Altaf A. Ladhani" <csc4aal@erols.com>
Subject: to Eric: web server is running..
Message-Id: <39C292B2.D88FD914@erols.com>
Hello Eric,
Yes, there is MS personal web server running. The index.html is residing under
c:\webshare\wwwroot\index.html
last year I had the same problem, and we had to go into "regedit" of winnt. I
did the same gizmo again. It just does not work. If you can think of something
else.
The script DOES work at DOS prompt.
thanks for the reply.
Altaf
Eric wrote:
> "Altaf A. Ladhani" <csc4aal@erols.com> wrote in message
> news:39C28128.F963CB74@erols.com...
> > Readers,
> >
> > I am facing a small problem. I have just installed Per 5.004 in my
> > win98 machine. An index.html if pointing at .pl file
> >
> <<snip>>
>
> There's your problem right there.
>
> You can not run cgi scripts (and that is what you are trying to do, even if
> it is a .pl file) locally. The script must be processed by a perl-aware web
> server and the resulting html code sent to the browser. So you must set up
> a web server (like personal web server--although I don't know if PWS
> supports cgi scripts, or Apache), or put your script on a web server
> somewhere. An example of a free web server that supports cgi is
> hypermart.com.
>
> From one newbie to another, it looks like you may want to read up on the
> basics of web programming and cgi. I might recommend "CGI programming with
> Perl 5" (from the "Teach yourself in a week" series). Others may have even
> better resources.
>
> hth,
> Eric
------------------------------
Date: Fri, 15 Sep 2000 17:29:36 -0400
From: "Eric" <eric.kort@vai.org>
Subject: Re: to Eric: web server is running..
Message-Id: <8pu48j$1e0h$1@msunews.cl.msu.edu>
"Altaf A. Ladhani" <csc4aal@erols.com> wrote in message
news:39C292B2.D88FD914@erols.com...
> Hello Eric,
>
> Yes, there is MS personal web server running. The index.html is residing
under
>
> c:\webshare\wwwroot\index.html
<<snip>
Ah...well then I guess I'm the only newbie here =) sorry for the assumption.
Check out http://dynamicnet.net/support/fp/perlwithPWS.htm for a good
overview of setting up PWS to run perl, just to double check your
configuration. You might also try changing your .pl to .cgi just to see if
it is a simple mime-type situation.
If that doesn't work, I can be of no further help. But I did notice there
are lots of discussion threads on this located by searching on "personal web
server perl" on altavista.
sorry I don't know more.
Eric
------------------------------
Date: Fri, 15 Sep 2000 15:02:52 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: to Eric: web server is running..
Message-Id: <e0xw5.646$eS1.296197@news.uswest.net>
"Altaf A. Ladhani" <csc4aal@erols.com> wrote:
> Yes, there is MS personal web server running. The index.html is residing
under
>
> c:\webshare\wwwroot\index.html
>
> last year I had the same problem, and we had to go into "regedit" of
winnt. I
> did the same gizmo again. It just does not work. If you can think of
something
> else.
> The script DOES work at DOS prompt.
It doesn't matter if your webserver is running or not, you're not
posting _through_ your webserver.
<FORM METHOD="post" ACTION="c:\winshare\wwwroot\cgi-bin\quote.pl">
This will post to a FILE!, which probably won't work. Also, the
action isn't a url (properly, it should be file:///....). You
need to send the POST request through a web-server.
What you wan't is something like
<form method="POST" action="http://localhost/cgi-bin/quote.pl">
That should do the trick.
------------------------------
Date: Fri, 15 Sep 2000 18:49:08 GMT
From: Mark Eggers <mdeggers@earthlink.net>
Subject: uninitialized variables
Message-Id: <Eauw5.12526$%p2.535946@newsread03.prod.itd.earthlink.net>
The following snippet of code produces a warning along with the correct
results in both Perl 5.005 and 5.6.0.
#!/usr/bin/perl -w
{
use diagnostics;
my @dirlist = ();
opendir(LDIR, ".");
#
# get only the Perl files
#
@dirlist = grep/$\.pl/, readdir(LDIR);
closedir(LDIR);
foreach my $file (@dirlist)
{
print "$file\n";
}
}
The error is in Perl 5.6.0
Use of uninitialized value in concatenation (.) at ./dirread.pl line 11 (#1)
I don't mind the error so much except that this script will be run by
people not familiar with the environment. Therefore the code should
be clean.
Any ideas as to how to get around this (I've tried various combinations
of my $file="foo"; and for $::file with no luck) would be greatly
appreciated.
Thanks - /mde/
------------------------------
Date: Fri, 15 Sep 2000 12:42:15 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: uninitialized variables
Message-Id: <MPG.142c1b71791299f798ad79@nntp.hpl.hp.com>
In article <Eauw5.12526$%p2.535946@newsread03.prod.itd.earthlink.net> on
Fri, 15 Sep 2000 18:49:08 GMT, Mark Eggers <mdeggers@earthlink.net>
says...
> The following snippet of code produces a warning along with the correct
> results in both Perl 5.005 and 5.6.0.
>
> #!/usr/bin/perl -w
> {
> use diagnostics;
Do you really want this in a 'production' program?
> my @dirlist = ();
I would just throuw the 'my' on the front of the assignment below.
> opendir(LDIR, ".");
Like all opens, this should have a diagnostic, including $!.
> #
> # get only the Perl files
> #
> @dirlist = grep/$\.pl/, readdir(LDIR);
What string matches an end-of-string at the beginning of the string? An
error like this indicates that you typed this in instead of copy-and-
pasting your real code, so everything else becomes suspicious.
> closedir(LDIR);
> foreach my $file (@dirlist)
Rather than keep an unnecessary array, I would just put the
grep...readdir in the loop-control ecpression. (I really would do it
all in one line, with map and the -l flag or local $| = "\n".)
> {
> print "$file\n";
> }
> }
>
> The error is in Perl 5.6.0
> Use of uninitialized value in concatenation (.) at ./dirread.pl line 11 (#1)
I tried your code with suitable adjustments, and got no such warning.
There should be no undefined values in @dirlist.
> I don't mind the error so much except that this script will be run by
> people not familiar with the environment. Therefore the code should
> be clean.
Indeed.
> Any ideas as to how to get around this (I've tried various combinations
> of my $file="foo"; and for $::file with no luck) would be greatly
> appreciated.
I don't understand what you tried. Showing the real code would be
helpful.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 15 Sep 2000 16:05:31 -0400
From: Henry Hartley <hartleh1@westat.com>
Subject: Re: uninitialized variables
Message-Id: <39C2810B.24A56402@westat.com>
Mark Eggers wrote:
>
> The following snippet of code produces a warning along with the correct
> results in both Perl 5.005 and 5.6.0.
>
> #!/usr/bin/perl -w
> {
> use diagnostics;
> my @dirlist = ();
> opendir(LDIR, ".");
> #
> # get only the Perl files
Assuming the files are named using that convention...
> @dirlist = grep/$\.pl/, readdir(LDIR);
> closedir(LDIR);
> foreach my $file (@dirlist)
> {
> print "$file\n";
> }
> }
>
How about this:
#!/usr/bin/perl -w
use strict ;
use diagnostics;
opendir(LDIR, ".");
print "$_\n" foreach (grep/.*\.pl/, readdir(LDIR)) ;
closedir(LDIR);
--
Henry Hartley
------------------------------
Date: Fri, 15 Sep 2000 22:10:23 +0200
From: "Lemsgaard" <lemsgaard@hotmailERASETHIS.com>
Subject: Which book/site should I use? I really can't choose.
Message-Id: <O0xilT1HAHA.307@net025s>
Hello there,
I just want to start programming, or scripting (or whatever) in Perl, (at
least learn the basics). Is there any book or site you would recommend? I
heard there is a slight difference between Perl use for Unix and for NT. Is
that right? And if that's right, I'd like to learn both. Can anybody help
me?
Lemsgaard
------------------------------
Date: Fri, 15 Sep 2000 21:56:51 GMT
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Which book/site should I use? I really can't choose.
Message-Id: <DWww5.2208$Oh1.41135@news000.worldonline.dk>
Lemsgaard wrote:
> Hello there,
>
> I just want to start programming, or scripting (or whatever) in Perl, (at
> least learn the basics). Is there any book or site you would recommend? I
> heard there is a slight difference between Perl use for Unix and for NT.
> Is that right? And if that's right, I'd like to learn both. Can anybody
> help me?
>
> Lemsgaard
>
>
>
>
http://www.perl.com
http://www.perl.org
http://www.pm.org
http://use.perl.org
http://www.perlmonks.org
http://www.perlfaq.com
http://www.perldoc.com
http://www.cpan.org
http://search.cpan.org
$perldoc perlman
(etc)
Learning Perl by Randolph Schwartz
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: Fri, 15 Sep 2000 14:48:47 -0600
From: David J Iannucci <dji@myriad.com>
Subject: Why does * in a string glob?
Message-Id: <39C28B2F.C6586C84@myriad.com>
I've got a weird problem... I've got a case where I'm
putting an SQL statement ("select * from tablename where [...]")
into a double-quoted Perl string, and Perl is treating the *
character as a glob, and replacing it in the string with a list
of all the files in my home directory! (I should say: I guess
Perl is the culprit -- I certainly can't imagine the database
doing this).
I can't find any reason why Perl should treat this as
a file glob. There are no funny < > characters around,
and certainly no reference to glob(). I did a little
test like:
print "select * from table";
But this fails to reproduce the problem. Can anyone think
of a reason why this would be happening?
Thanks in advance,
Dave Iannucci
Myriad Genetics, Inc.
Salt Lake City, Utah
dji@myriad.com
------------------------------
Date: Fri, 15 Sep 2000 21:58:44 GMT
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Why does * in a string glob?
Message-Id: <oYww5.2209$Oh1.41135@news000.worldonline.dk>
David J Iannucci wrote:
> I've got a weird problem... I've got a case where I'm
> putting an SQL statement ("select * from tablename where [...]")
> into a double-quoted Perl string, and Perl is treating the *
> character as a glob, and replacing it in the string with a list
> of all the files in my home directory! (I should say: I guess
> Perl is the culprit -- I certainly can't imagine the database
> doing this).
>
> I can't find any reason why Perl should treat this as
> a file glob. There are no funny < > characters around,
> and certainly no reference to glob(). I did a little
> test like:
>
> print "select * from table";
>
> But this fails to reproduce the problem. Can anyone think
> of a reason why this would be happening?
>
> Thanks in advance,
>
> Dave Iannucci
> Myriad Genetics, Inc.
> Salt Lake City, Utah
> dji@myriad.com
You forgot to do
$perl -w filename.pl
which would help you to find your typo.
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 4338
**************************************