[6453] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 78 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 9 14:07:10 1997

Date: Sun, 9 Mar 97 11:00:29 -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           Sun, 9 Mar 1997     Volume: 8 Number: 78

Today's topics:
     Re: 10 commandments (was re: Which one is the best (pat <tmh@possibility.com>
     Another troll (Re: Who makes more $$ ) <vlad_imip@uniserve.com>
     Re: Calling a Perl Program from within HTML <perry@netplaza.com>
     Enterprise 2.0 & perl's system() (Christopher Ryan)
     Re: Help! Simple Question: Error 501: "Not Supported" (Andrew M. Langmead)
     Re: Help! Simple Question: Error 501: "Not Supported" (Tad McClellan)
     Re: Help! Simple Question: Error 501: "Not Supported" (---)
     Re: How to spam - legitimately (Terry Carroll)
     Re: Is there a less clumsy looking way to do this? (Andrew M. Langmead)
     Re: mathematically correct? <rootbeer@teleport.com>
     Re: need some help here <Webmaster@tarrcity.demon.co.uk>
     Re: Newbie: Help With " (Dave Thomas)
     Q: order of switches -i.bak -w (Bernhard Wagner)
     Re: RAND/SRAND query <grozny@patriot.net>
     random access db for cgi script ? <102646.1641@CompuServe.COM>
     Search Engine in Perl... (Bruno Dickhoff)
     Re: Strange but True (Eric Harley)
     Re: uc without explicit argument inside map. Bug? <roderick@argon.org>
     Re: What is true?  was: simple new question! <tchrist@mox.perl.com>
     Re: Where do I find OLE.PM documentation? <kramsey@worldnet.att.net>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 09 Mar 1997 06:35:54 -0800
From: Todd Hoff <tmh@possibility.com>
Subject: Re: 10 commandments (was re: Which one is the best (pattern matching))
Message-Id: <3322CACA.480F@possibility.com>

Zenin wrote:
> : Nope, code usually works the first time. Not much debugging
> : needed.
> 
>         So can we assume then you don't write perl programs that are larger
>         then a couple hundred lines?
> 
>         IMHO, when they get past ~200 it's almost mandatory, and if you go
>         over ~1k it would be death without it...

Actually i work on perl systems with dozens of classes and thousands
of lines of code. It was a joke. And it's not even remotely
manditory. Reference the endless disucssions between smalltalk and
c++ programmers.

---------------------------------------------------------------------
tmh@possibility.com        | I have no interest in any ship that does
http://www.possibility.com | not sail fast, for I plan to go in 
                           | harm's way. -- J.P. Jones


------------------------------

Date: Sun, 09 Mar 1997 10:23:38 -0800
From: Da Borg <vlad_imip@uniserve.com>
Subject: Another troll (Re: Who makes more $$ )
Message-Id: <3323002A.6B6D2712@uniserve.com>

Future Programmer wrote:
> 
> Subject says it all. Based on your personal experience and statistics,
> where a good programmer can make more money - in Windows or Unix arena?
> Unix appeals more to me and is more advanced technically, but I am
> afraid that it is losing the market share to Windows 95. I want to be in
> the consulting field.
> 
> I am a recent college graduate in NYC and have offers to work in
> both fields.  Please do not start Windows vs. Unix OS flamewar.
> Your insighful observations are appreciated. Please followup.

This is the same piece of crap (aka troll) who last fall posted
"visual basic programmers - ni***rs of computing" to a great
number of newsgroups and the flame thread was continuing for 
several months. Do not believe the asshole and do not reply.

Followups to /dev/null.

-- 
When sending private email, please remove underscores in "vladi_mip".
#include <disclaimer.h>  |   *Good pings come in small packets*
vladimip @ uniserve.com  | Ceterum censeo Microsoftam delendam esse
Vancouver, B.C.     86 108 97 100 32 80 101 116 101 114 115 101 110


------------------------------

Date: Tue, 04 Mar 1997 20:29:40 -0400
From: perry <perry@netplaza.com>
Subject: Re: Calling a Perl Program from within HTML
Message-Id: <331CBE74.5FDC@netplaza.com>

> I need to include about 50 lines of html code into 10 sites.  I also
> need to pass a parameter to the cgi code so I know which 50 lines of
> code that is needed.  There are 4 different snippets of code each 
>with a different graphic.
 
I think you're on the right track, you can use server side includes.

Netscape server allows server side includes to be turned on for
all files, not just shtml, but there is a performance penalty.  You
probably want to turn on exec on certain directories.

For passing parameters, the environment variables are passed to your
included perl scripts, so the following works:

<a Href="http://www.somewhere.com/page.html?parameter1="data1">
link label</a>

(I love passing parameters to static pages )

parameter1="data1" gets passed into the perl script that is exec'd
inside the page.

This has gotten me out of some serious jams.

Perry

( Just a wannabe perl hacker)


------------------------------

Date: 9 Mar 1997 14:09:30 GMT
From: cryan@acclaim.com (Christopher Ryan)
Subject: Enterprise 2.0 & perl's system()
Message-Id: <cryan-0803970622100001@dial9.netwiz.net>


 Hello!

  Has anyone encountered a problem using the system() under
Enterprise 2.0 in the Solaris OS?

 I have a script that works fine in the Netscape Communcator Server but
when I port it over to the Enterprise it's unable to function.

 When I test the script from the command line it works like 
it should but when I try to run it in Netscape or Lynx the system()
is skipped and the URL, the only other thing in the file, is changed.
I also found this to be true for exec and the open ("|") commands too.

 Has anyone encountered this problem and what did they do to fix it?

 I have other CGI that perform other functions, create file, read post
data, etc... and everything works fine. Their is no error that is appears
in the error logs. Using perl -w doesn't help since the program runs as
it is supposed to do in the command line just fine...

 Any thoughts?

 -Christopher
 cryan@netwizards.net


------------------------------

Date: Sun, 9 Mar 1997 14:50:25 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Help! Simple Question: Error 501: "Not Supported"
Message-Id: <E6s6K2.8F9@world.std.com>

[ a courtesy copy of this message was sent to the appropriate party]

bailey766@aol.com (---) writes:

>I posted to the Perl newsgroup because (being a newbie to CGI/Perl) I
>have absolutely no way of knowing where an error message is coming
>from, or whether the error message is the result of a wrongly
>configured Perl installation, etc.  Since a Perl script was the
>primary subject of the message, not servers or browsers, (at least I
>thought it was at the time), it seems to make sense to post that
>message here.

I can understand your frustration. When you have more than one system
interacting, its can be hard to determine which system is causing the
problem. Espcecially when first learning both at once. I have a couple
of suggestions that might help you in the future.

1. Break the two interacting systems into two separate systems. 

>From what I've looked at http servers, (not very much) I've seen
sample CGI scripts. If you replaced your script with one of the
samples, you could see if the sample (which you could assume functions
correctly) does indeed function correctly.

Run the perl script directly instead of having it be run by the http
server. From what I've seen of cgi libraries (not very much) the
CGI.pm library makes it very easy to test scripts on the command line
(which is the first step to being able to run a script under the perl
debugger.)

2. Read the documentation that comes with each system.

The perldiag man page contains every single error message that can be
emitted by the perl interpreter. (And a few like "Error 501" which
aren't coming from perl but easily mistakable by new users as perl
errors.) Find the explaination for the error you are getting.

-- 
Andrew Langmead


------------------------------

Date: Sun, 9 Mar 1997 10:00:14 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Help! Simple Question: Error 501: "Not Supported"
Message-Id: <eqmuf5.3s.ln@localhost>


[ emailed, posted ]

[

It is normal Usenet practice when you are posting *and* emailing
it say so (as above).

Had I decided to answer your email, I would have needed to recreate
the whole message again when I later found out that it had been 
posted too.

I decided _not_ to answer your email because I really can't give
individual help to everybody that asks. I answer in the newsgroup
because I can help thousands of people at a time. Answering in
the newsgroup also helps people _in the future_ who have the same
problem, because they will be able search the archives via
Dejanews (see below).

]



--- (bailey766@aol.com) wrote:
: tadmc@flash.net (Tad McClellan) wrote:

: >--- (bailey766@aol.com) wrote:
: >: I have the Perl interpreter installed on my NT 4.0 server running IIS
: >: 3.0.  I wrote a simple Perl script that simply writes a string to a
: >: file when it is run (so that I know it was executed).  I put together
: >: a simple HTML file with a submit button that runs the Perl program
: >: using the syntax:

: >: <FORM METHOD=POST ACTION="filetest.pl">
: >: <INPUT TYPE="SUBMIT">
: >: </FORM>

: >: etc etc.

: >: When I load this page from my CLIENT machine, a Win95 box with
: >: Internet Explorer 3.0, I get "Error 501- Not Supported".  If I load it
: >                               ^^^^^^^^^^^^^^^^^^^^^^^^
: >That is not a perl error message.

: >Looks like some kind of HTTP message or something...

: >: using IE3.0 locally, from the SERVER, it thinks I want to download the
: >: file.

: >: these error messages myself?  I waded through much of the online docs
: >: and could not find the error codes listed.  Is this an IE3.0 error or
: >: a Server error?

: >We wouldn't know. 
: >IE and servers are not perl. 
: >This is the perl newsgroup ya know  ;-)

: I posted to the Perl newsgroup because (being a newbie to CGI/Perl) I
: have absolutely no way of knowing where an error message is coming
: from, or whether the error message is the result of a wrongly
: configured Perl installation, etc.  


But you are _still_ expected to make some effort to try and answer
your question yourself (or at least find out what newsgroup you
should ask/search in) before posting.

See below for a few ways that you can help yourself (you will generally
get the answer *faster* than by posting and waiting too).


: Since a Perl script was the
: primary subject of the message, not servers or browsers, (at least I
  ^^^^^^^^^^^^^^^
: thought it was at the time), it seems to make sense to post that
: message here.  


But there was not one stitch of perl in your post!

The primary subject of the message was a "Error 501" error message...


: It could have been worse, I could have spammed it
: across every www-related group I could find :)


That wouldn't really have bothered _me_. Because my killfile would
have eliminated the question, and I would never have known about
it    ;-) [ hint: massive cross-posting is likely killfiled by anybody
            who has been around a while. So crossposting may prove to
            be counter productive anyway...
          ]



: But really, with all the bulk e-mailers and other internet scum out
: there, couldn't your badgering energy be spent more effectively on one
: of them instead of a well-meaning Perl newbie such as moi?  :)


No, because they don't/won't listen anyway (I've spent a lot of time
trying). And I'm disinclined to try and help _them_ anyway.

I *was* trying to help. Finding out where the experts are who could
help you with your problem (ie. which newsgroup) goes a long way 
toward getting an answer.

As Nathan pointed out in another follow-up, seeing the same question
over and over again occasionally wears down my resistance, and
I finally follow-up to them (when my resistance doesn't were down
I simply ignore the question. There are plenty of other questions
to spend time answering where the poster has made some effort
themselves before asking for help).

[ hint: Answerers have limited time to spend answering questions.
        Your question is in _competition_ with all the other
        questions. Don't do things that let someone _else's_
        question get the time...
]

When I search only my own postings to c.l.p.m at http://www.dejanews.com,
I find 94 hits for "man pages", 142 hits for "FAQ". And that's only
*one* of the newsgroups that I participate in. Think you might get
worn down after several hundred of 'em?

So it would appear that I have already helped a couple hundred folks
to get answers to their questions faster, and look good to their
boss to boot.

-----

Now to how to figure out problems:

1) check the perl man pages and FAQs.

   The perldiag man pages lists all of the error messages that perl
   might issue. So, when you get an error message, you search for
   it in perldiag. If it is not there, then the message didn't come
   from perl.


2) do some directed searches at Usenet archives, such as Dejanews.

   A search for +501 +"Not Supported" found:

      16 hits in comp.lang.perl.misc
      41 hits in comp.infosystems.www.*

   And searching for Error 501 found

      46 hits in comp.lang.perl.misc
      93 hits in comp.infosystems.www.*

   Reading some of those may have answered your question, or at least
   given you a clue as to where the experts for your problem hang out.


3) if your HTTP server runs on Unix, then you should get the Unix FAQs too.

   
4) especially for newbies: You don't really think that you are the
   first one to have your newbie problem, do you? So, your question
   has likely been asked and answered already. Just go find it...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


------------------------------

Date: Sun, 09 Mar 1997 20:24:06 GMT
From: bailey766@aol.com (---)
Subject: Re: Help! Simple Question: Error 501: "Not Supported"
Message-Id: <5furug$1a9@dfw-ixnews5.ix.netcom.com>

>4) especially for newbies: You don't really think that you are the
>   first one to have your newbie problem, do you? So, your question
>   has likely been asked and answered already. Just go find it...

Point well taken.  There were better ways to approach the problem that
for whatever reason I overlooked; I was looking for a quick answer and
my experience is that 9 times out of 10, when I can't find the answer
I am looking for in the subject line of all "current" messages in a
newsgroup, posting a question gets a fast response.  That other 1 out
of 10 times, a mild flame session is invoked in which any number of
folks post countless follow-ups telling me how I am wasting bandwidth
or other net resources. Oh the irony! :)

Someone else said it is "standard procedure" to read the newsgroup for
2 weeks before posting.  Does that mean EVERY single message?  I have
had this group in my reader for a few months, and I glance at it from
time to time, and I have seen LOTS of redundant newbie questions where
nobody got beat up as badly as I did over this issue.   What do you
want to bet it is because of the "aol.com" in my e-mail address?  Well
take a look at the message header, folks, I am posting through Free
Agent which I would not be able to do with aol (I dont think, anyway).
The aol.com is just a mailbox that I want mail to be directed to,
since my $9 a month for AOL gets me an excellent stock portfolio
manager and unlimited mailboxes.  It is also quite fast when accessed
through TCP/IP.  So to whoever mentioned the "two weeks" time frame,
(I know it wasn't you), your point does not hold up very well. 

But anyway thank you to you and everyone who has pointed me in the
right direction.  I will do better next time.



------------------------------

Date: Sun, 09 Mar 1997 18:06:11 GMT
From: carroll@tjc.com (Terry Carroll)
Subject: Re: How to spam - legitimately
Message-Id: <3322fa0d.470163687@news2.aimnet.com>

On 03 Mar 1997 15:51:41 -0700, Randal Schwartz <merlyn@stonehenge.com>
wrote:

>>>>>> "Terry" == Terry Carroll <carroll@tjc.com> writes:
>
>Terry> The example you're trying to give here is not of the same type.  "An
>Terry> email" fills a gap in the English language.  It provides a noun for a
>Terry> concept that otherwise wouldn't have one.
>
>Funny, I find "some email" or "a piece of email" to be satisfactory.

"Some email" doesn't refer to a particular piece of email.  "a piece of
email" is lengthy and unsatisfactory.

>"an email" sounds strange.  Very strange.  To my native ears.

And it sounds fine to my native ears, and to the native ears of a lot of
other people.  My point was that the "I've never heard a native speaker
use it" slam is more probative of the slammer's limited circle than
anything else.

>That's because I hear "email" as derived from "mail".  I've heard
>"some mail" and "a piece of mail", but never "a mail".  Ugh.  A native
>speaker of American english would *never* say that.

Agreed, but I addresses that already.  There's no basis for assuming that
the words that will be used to describe electronic communication should be
in lock step with the existing words to describe paper communication.
Whether "a mail" is awkward is pretty much immaterial to whether "an
email" is also awkward.

What I see you articulating is the unwarranted assumption that, since
"email" derives from "mail," the former inherits all of the attributes of
the latter.  But quite simply, that's not how language works.

The point is, well-educated native speakers of English are going around
saying "send me an email," and "I got your email," etc.  It's pretty much
standard, and it is an advancement, because it supplies a word where no
word previously existed.


--
Terry Carroll       | "Al Gore is doing for the federal government what
Santa Clara, CA     | he did for the Macarena.  He's removing all the
carroll@tjc.com     | unnecessary steps."
Modell delenda est  |                - Bill Clinton, September 20, 1996


------------------------------

Date: Sun, 9 Mar 1997 15:26:47 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Is there a less clumsy looking way to do this?
Message-Id: <E6s88o.I2C@world.std.com>

Charles Herold <cherold@pathfinder.com> writes:

>Hi,

>The code below works, but it's rather awkward, and I hate that.  What I
>need, of course, is a two-dimensional array, which I believe can be done
>in Perl5 but this is a large script someone wrote years ago in an
>earlier Perl so let's keep within the limits of that.  So, is there some
>nifty little Perl trick that will let me turn this into something a bit
>neater?

First of all, take a look at the perlref, perllol and perldsc man
pages. They should have everything that you need. As a starter though,
here is your code turned into one using a has of hashes data
structure. (With a few other gratuitous changes.)

sub Header {
%in = ("category", "clothing", "op", "showpage");

my %scheme = (default => {'bgcolor', '#003366', 'text', '#ffffff', 'link',
         '#ffcd31', 'vlink', '#006aff', 'alink', '#003366' },
   showcategory => {'bgcolor', '#003366', 'text', '#ffffff', 'link',
             '#006aff', 'vlink', '#ffcd31', 'alink', '#003366', 'background',
             "$fixed/categorybkg_$in{category}.gif"},
   showpage => {'bgcolor', '#ffffff', 'text', '#000000', 'link', '#ffcd31',
              'vlink', '#006aff', 'alink', '#003366', 'background',
              "$fixed/categorybkg_$in{category}.gif"},
   showbasket => {'bgcolor', '#ffffff', 'text', '#000000', 'link', '#ffcd31',
              'vlink', '#006aff', 'alink', '#003366'});


# make an empty scheme key point to the default scheme.

$scheme{''} = $scheme{default};

  print "<head><title>test</title></head>\n";

  print '<body';
  
  foreach $key (keys %{$scheme{$in{op}}}) {
        print " $key=\"$scheme{$in{op}}{$key}";
  }
  print '>';
}
-- 
Andrew Langmead


------------------------------

Date: Sat, 8 Mar 1997 17:09:47 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Thomas A. Loser" <tloser@valdemar.microserve.com>
Subject: Re: mathematically correct?
Message-Id: <Pine.GSO.3.95q.970308160651.11807F-100000@linda.teleport.com>

On Wed, 5 Mar 1997, Thomas A. Loser wrote:

>   The PERL (camel) book gives an example for selecting a random line
> from a file of unknown length with a single pass through the file:

>   srand;
>   rand($.) < 1 && ($it = $_) while <>;

As other posters have pointed out, this is mathematically correct in
general. It can fail, though, for very large files because of the way in
which rand() is implemented.

rand calls your system's random number generator (or whichever one was
compiled into your copy of Perl). For this discussion, I'll call that
generator RAND to distinguish it from rand, Perl's function. RAND produces
an integer from 0 to 2**randbits - 1, inclusive, where randbits is a small
integer. To see what it is in your perl, use the command 'perl
-V:randbits'. Common values are 15, 16, or 31.

When you call rand with an argument arg, perl takes that value as an
integer and calculates this value. 

                         arg * RAND
           rand(arg) = ---------------
                         2**randbits

This value will always fall in the range required.

           0  <=  rand(arg)  < arg

But as arg becomes large in comparison to 2**randbits, things become
problematic. Let's imagine a machine where randbits = 15, so RAND ranges
from 0..32767. That is, whenever we call RAND, we get one of 32768
possible values. Therefore, when we call rand(arg), we get one of 32768
possible values. 

If we want to pick a random digit, though, there's a small problem: 32768
isn't evenly divisible by 10, so some digits need to have higher
probability than others. That is, when we calculate int(rand(10)), there
are 3276 possible values of RAND which lead us to choose some digits, and
3277 possible values which lead to others. Since both 3276/32768 and
3277/32768 are very close to 1/10, this isn't usually a problem. 

But if arg = 1000, now there are either 32 or 33 possible values of RAND
for each possible value of int(rand(1000)). And 32/32768 and 33/32768
aren't especially close to 1/1000. Still, this might be suitable for some
purposes.

But suppose arg = 100_000? Now, there are 100_000 integer values which we
would like for int(rand(100_000)) to assume, but it can only reach 32768
different values! That value will be 0 about 1 time in 32768, but it'll
_never_ be 1. Or 2, even. Dang.

There are other aspects to this problem, too. On a machine with
randbits=15, rand(65536) will always be an even integer. You don't even
have to use int on it! And there are lots of machines with such small
randbits. 

If you have access to a fairly fast machine on which randbits is small
enough, try this test script to see how much "luck" it takes to hit one
chance in one billion. On a machine with randbits=15, you'll probably be
that lucky about 30 or 31 times, and if randbits=16, it'll be about half
that. Of course, if your randbits=31, you'll have to _really_ be lucky to
even get one!

     perl -e 'srand; $c = 0; for ($i=0; $i<1e6; $i++)' \
        -e '{ $c++ if rand(1e9) < 1 } print "$c\n"'

This means that on a machine with small randbits, you shouldn't expect
two-line script to choose each line of a large file with equal
probability. Later lines may be chosen with higher frequency than they
deserve. 

Hope this helps! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



------------------------------

Date: Sun, 9 Mar 1997 18:04:55 +0000
From: Webmaster <Webmaster@tarrcity.demon.co.uk>
Subject: Re: need some help here
Message-Id: <R0E$nRAHvvIzEwlV@tarrcity.demon.co.uk>

In article <5fkqbd$e9m@gein.ge.com>, jafar@finance.? writes
>try using:
>
>($lname,$fname,$location,$mailstop,$phone) = split(/\s+/);
>

Hang on a mo' look at the data, there's an irregular number of fields.
If only whitespace is going to be used its not going to work.

>: @<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<@<<<<<<<@<<<<<<<<<<
>: $lname,$fname,$location,$mailstop,$phone,$real
>: .
>: **********************
>
>: part of the list im using is below , all the list looks the same, each
>: item is seperated by a space or tab. 
                          ^^^^^^^^^^^^
 Here's your problem.

>
>: **********************
>: Abrams, Sandra                  Lib2123B L2211  6611
>: Academic Advising               Lib1401 L1401   6312
>: Academic Budgeting              Lib3234 L3234   6867
>: Academic Computing              Lib2409 L2408   6235

lname = Academic
fname = Computing
location = Lib2409      OK
etc

>: John Aikin Cushing              Lib2213 L2211   6234

lname = John
fname = Aikin
location = Cushing      NOT OK
etc

>: does any one have any suggestions?

Yes.  As some of your fields contain spaces (either "John Aiken" or
"Aiken Cushing") you need need to have something more specific (eg tab)
than space or whitespace to seperate them.  Then you can use 

        = split(/\t/);

In case thats not clear your *data* and your field seperator are not
consistent and need to be.

eg John Aiken\tCushing\tLib2213...
or John\tAiken Cushing\tLib2213...

Failing that you'd need to start testing each variable to know which one
was the one after the parts of the name, which'll be much trickier.

HTH
-- 
Wm ... 


------------------------------

Date: 9 Mar 1997 15:25:24 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Newbie: Help With "
Message-Id: <slrn5i5lcl.e5.dave@fast.thomases.com>

On 9 Mar 1997 03:24:50 GMT, G. Naik <gnaik@iname.com> wrote:
> I am trying to use the following command and am having problems with it:
> 
> :: print "<A HREF="mailto:myaddr@whatever.net">Mail</A>\n";

If there are no-substitutions in your string, you can use single quotes to
delimit it:

 print '<A HREF="mailto:myaddr@whatever.net">Mail</A>\n';

If there are single quotes in it, you could escape them (with a \), or use
the more general quoting mechanisms, q or qq. 'q' acts like a single quoted
string, qq like a double quoted one. However, you can use arbitrary
delimiters. So:

 print q!<A HREF=\"mailto:myaddr@whatever.net">Mail</A>\n!;

However, as of somewhere into Perl 5, you'll get a warning if you have a '@'
in an interpolated string (because it might be the start of an array name.
So if you go with the double quotes, you'd need:

 print qq!<A HREF=\"mailto:myaddr\@whatever.net">Mail</A>\n!;

So, in general, if you want a literal string, use single quotes or the 'q'
format. If you want interpolation, use double quotes or 'qq', but watch out
for characters with special meanings. If you string contains quotes itself,
favor the 'q/qq' format over ' and ".

Dave

-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


------------------------------

Date: 9 Mar 1997 14:33:22 GMT
From: bwagner@claude (Bernhard Wagner)
Subject: Q: order of switches -i.bak -w
Message-Id: <5fuhni$666@bioko.ifi.unizh.ch>

I use perl 5.003 and have this problem:
When I use the switch -i.bak, the following switches (e.g. -w) are
ignored by perl. When I use -w -i.bak in this order, I get the error:
Unrecognized switch: - -i.bak.
Am I doing sth. wrong or is it worth to invoke perlbug?

Thanks
Bernhard

--
  Bernhard Wagner, MultiMedia Laboratory              bwagner@ifi.unizh.ch
  University of Zurich                               VOICE +41-1-257 45 69
  Inst.f.Informatik, Winterthurerstr. 190            FAX   +41-1-363 00 35
  CH-8057 Zurich, Switzerland   http://www.ifi.unizh.ch/staff/bwagner.html


------------------------------

Date: Sat, 08 Mar 1997 03:25:04 -0500
From: Shane Sadler <grozny@patriot.net>
Subject: Re: RAND/SRAND query
Message-Id: <33212260.5FA6@patriot.net>

Ron & Mary Stephens wrote:
> 
> I'm writing a script which needs to generate several random
> integers.  Here's the problem which I hope someone will have
> an answer to.
> 
> The first random number works fine.  I call it using the standard
> srand time () seed.
> 
> srand;
> $numberone = int (rand ($range) + 1);
> 
> How then do I call a second random number that is truly random?  So far
> I've been using the first random number as the SRAND seed for the second
> call, the second number for the third SRAND seed and so on.  But this
> only results in a pattern that isn't truly random.  i.e. the first
> number determines the second etc.

You're doing the first seed from time() (the default for srand). Keep
that seed by not using srand() again. You're seeding the first time with
the time, but thereafter you're using a much smaller range of numbers to
set the seed than what time() gave you so you're narrowing the range of
your seed. And rand is completely deterministic; it does not run off the
clock or "randomize" anything. The same seed will always produce the
same result. 

If you're running this in a loop, try seeding just before the loop and
leaving it alone and you'll get a series that's as random as the
technology will allow. 

Try the following code (hard-coding some values for demo purposes):

srand;
$number = int(rand(100) + 1);
for($counter = 0; $counter < 10; $counter++) {
    srand($number);
    $number = int(rand(100) + 1);
    print($number);
    print("\n");
}

Running this program on my computer shows me that the first couple of
numbers are okay, but the sequence soon becomes a repeating sequence.
With each iteration, the range of the seed becomes smaller.

Now try this one:

srand;
for($counter = 0; $counter < 10; $counter++) {
    $number = int(rand(100) + 1);
    print($number);
    print("\n");
}

Hope this helps.

-- Shane
>>==================================================<<
S.M. Sadler
e-mail: grozny@patriot.net
WWW: http://adams.patriot.net/~grozny


------------------------------

Date: 9 Mar 1997 16:01:05 GMT
From: richard ferry <102646.1641@CompuServe.COM>
Subject: random access db for cgi script ?
Message-Id: <5fums1$h3u$1@mhafc.production.compuserve.com>

hi folks!

i would like to put our email directory on my intranet. it has 
about 1000 users and 70 bytes per title. i am not sure which 
would be the best way to post this. i would like the users to be 
able to type in a partial name and get a list of users with that
similar name. also be able to scroll back and forth.

i am thinking about a fixed-length random access db in unix, but 
dont know if that would give me the scrolling capabilities i 
need.

should i go this route or is there a cgi db out there that would 
help.

thanks in advance.


------------------------------

Date: Sat, 08 Mar 1997 21:55:53 GMT
From: bruno@dickhoff.d.eunet.de (Bruno Dickhoff)
Subject: Search Engine in Perl...
Message-Id: <3321df2a.11203440@PersonalNews.Germany.EU.net>

Hi...

I need a Perl-driven Full-Text-Retrieval system (CGI-Script), which
has to run under Win NT3.51, where our Web-Server is located.

We just need this search engine to let our site-visitors search all
html-files at our site for keywords, then they should get a list of
the html-files where the keyword was found in - URL-encoded, so that
the visitors just have to click the entrys to get to the part of the
document, where the keyword was found.

I have found a sample of perl-code, which does exactly this task, but
unfortunately it seems to be written for Unix-Systems and does not
work on the NT-Server...

Any hints?

greetings, Bruno
bruno@dickhoff.d.eunet.de


------------------------------

Date: Sun, 09 Mar 1997 07:36:12 -0800
From: erich@powerwareintl.com (Eric Harley)
Subject: Re: Strange but True
Message-Id: <erich-0903970736120001@ppp-207-104-16-88.snrf01.pacbell.net>

In article <E6rq8z.2wH@actcom.co.il>, syoung@actcom.co.il (Sara Young) wrote:

just like in C and C++, if you use the = operator instead of the ==
operator, you asign a value instead of comparing a value. This shouldn't
mess up your hash at all since you are pulling the values out and putting
them into a string.

> In a script of mine I have a loop like this:
> while (($key, $value) = each %hash) {
>    ...
>   if ($key=$something) {
>      last;
>   }
> }
> 
> This 'last' command seems to mess up the hash, because when it is accessed
> again it doesn't find any pairs.  If I access the hash a third time - then
> everything is fine.
> 
> Does this make sense to anybody?
> 
> Sara


------------------------------

Date: 9 Mar 1997 00:31:10 -0500
From: Roderick Schertler <roderick@argon.org>
To: Dave Peters <dave@nuance.com>
Subject: Re: uc without explicit argument inside map. Bug?
Message-Id: <pz7mjhws2s.fsf@eeyore.ibcinc.com>

On 24 Feb 1997 17:24:08 -0800, Dave Peters <dave@nuance.com> said:
> 
> I'd have hoped that uc would behave like most of the other functions,
> and employ $_ as its default argument! Is this fixed in the current
> version?

Yes, fixed in the developer sources, will be fixed in 5.004.

-- 
Roderick Schertler
roderick@argon.org


------------------------------

Date: 9 Mar 1997 16:41:36 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: What is true?  was: simple new question!
Message-Id: <5fup80$aes$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, webster@dozyrosy.demon.co.uk writes:
:But I think, in
:general, there are two different sorts of "true" and "false"?

Certainly.  That's why we have the defined() test, and why
we can undef variables.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "That which does not kill me makes me stranger." --Larry Wall


------------------------------

Date: 9 Mar 1997 14:21:31 GMT
From: "Kathleen Ramsey" <kramsey@worldnet.att.net>
Subject: Re: Where do I find OLE.PM documentation?
Message-Id: <01bc2c95$261e4b00$5f2b74cf@default>

I found what I was looking for in the Excel Visual Basic guide.


Kathleen Ramsey <kramsey@worldnet.att.net> wrote in article
<01bc26b8$ca86c880$366674cf@default>...
> I just installed Perl 5.003 "Build 303" for Win32 .
> I can't find a doc called ntole.cpp?  Any clues?
> BTW The few things I did figure out worked great.
> Kathy
> kramsey@worldnet.att.net
> 


------------------------------

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 78
************************************

home help back first fref pref prev next nref lref last post