[11998] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5598 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 7 16:07:40 1999

Date: Fri, 7 May 99 13:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 7 May 1999     Volume: 8 Number: 5598

Today's topics:
        does the result of chop go to $-something? sstarre@my-dejanews.com
    Re: does the result of chop go to $-something? <uri@sysarch.com>
    Re: Download script (Bart Lateur)
    Re: Download script (Matthew Bafford)
    Re: Emacs .info documentation for Perl? lvirden@cas.org
    Re: Find all files regardless of extension (Tad McClellan)
    Re: Function vs Object oriented <design@raincloud-studios.com>
    Re: Function vs Object oriented <uri@sysarch.com>
    Re: HASH references... <design@raincloud-studios.com>
        How to get current working directory? <kac@srsys.com>
    Re: How to match a variable in pattern - Help a newbie  (Brian Peisley)
        https help mjzanghi@my-dejanews.com
        https help mjzanghi@my-dejanews.com
        https help mjz01@health.state.ny.us
    Re: Increment a variable's name sstarre@my-dejanews.com
    Re: ODBC and Access memo fields <michaelw@palawnet.com>
    Re: Oops, here is the script (Matthew Bafford)
    Re: PERLFUNC: binmode - prepare binary files on old sys (Larry Rosler)
    Re: procedure to convert sec to HH:MM:SS format (Bart Lateur)
        running a file from unix shell <mikej@1185design.com>
    Re: simple way for several if ( eq ||) ? <ebohlman@netcom.com>
    Re: simple way for several if ( eq ||) ? (Larry Rosler)
    Re: simple way for several if ( eq ||) ? <emschwar@rmi.net>
    Re: Stupid FAQ question of the (day? month? year?) <design@raincloud-studios.com>
    Re: Stupid FAQ question of the (day? month? year?) (Bob Trieger)
        tcgrep not expanding command-line wildcards (Eric Pement)
    Re: Why my? <grichard@uci.edu>
    Re: Why my? <grichard@uci.edu>
    Re: Why my? <design@raincloud-studios.com>
    Re: Why my? <emschwar@rmi.net>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 07 May 1999 19:21:23 GMT
From: sstarre@my-dejanews.com
Subject: does the result of chop go to $-something?
Message-Id: <7gvefd$pql$1@nnrp1.deja.com>

I'd hoped it would pop up in $_ but no such luck. perlfunc says chop returns
the chopped char of course, which I can store in a variable, but is it in any
$ vars? I don't see any good candidates in Camel that look like

$(something) (LAST_RETURNED_VALUE)

Cheers, and have a Perlish weekend :)

-S

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 07 May 1999 15:58:49 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: does the result of chop go to $-something?
Message-Id: <x7k8uktzwm.fsf@home.sysarch.com>

>>>>> "s" == sstarre  <sstarre@my-dejanews.com> writes:

  s> I'd hoped it would pop up in $_ but no such luck. perlfunc says
  s> chop returns the chopped char of course, which I can store in a
  s> variable, but is it in any $ vars? I don't see any good candidates
  s> in Camel that look like

how could it pop up in $_ when $_ is the default argument it modifies?

:-)

so it just returns the chopped char itself and no need for a special
var.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Fri, 07 May 1999 19:22:05 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Download script
Message-Id: <37353c9f.2532152@news.skynet.be>

K-Nine wrote:

>I have no knowledge of Perl but am looking for a script that will monitor
>what people download form my site and report it. Can any1 help please?

First, you should check if you can access the site logs. If you can,
it's all in there. Perl can help you analyse the data, sure, by for
example counting the occurences for each item. There are scripts
available from various websites that can already do that for you. Check
the main page for your ISP, chances are that it contains a pointer to
just such a bunch of prewritten scripts.

If you don't have access to those logs, you're out of luck.

	Bart.


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

Date: Fri, 07 May 1999 19:36:22 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Download script
Message-Id: <slrn7j6e79.7mf.dragons@dragons.duesouth.net>

On Fri, 7 May 1999 19:25:24 -0500, K-Nine <dleach@bigfootNOSPAM.com>
lucked upon a computer, and thus typed in the following:
: Hi,
: 
: I have no knowledge of Perl but am looking for a script that will monitor
: what people download form my site and report it. Can any1 help please?

Insufficient data.

Perhaps your server logs such information.  Whatever your server is.

Perhaps you want to use the CGI to provide a proxy to the files, but
maybe your server doesn't support that.

Perhaps you don't want to write anything at all.  In that case, try a
 .jobs newsgroup.
 
: Thankyou

HTH,

: Dan

--Matthew


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

Date: 7 May 1999 18:54:26 GMT
From: lvirden@cas.org
Subject: Re: Emacs .info documentation for Perl?
Message-Id: <7gvct2$gd1$1@srv38s4u.cas.org>


According to Marek Rouchal <Marek.Rouchal@hl.siemens.de>:
:I've searched the Web and the Perl distribution and the Perl Home
:Page for information on Emacs .info documentation for Perl.

I just went to altavista and did a search on

+texinfo +perl +documentation 

and got back
<URL: http://ftp.sunet.se/pub/lang/perl/CPAN/doc/manual/texinfo/>
as well as 9300 additional urls...

See if that helps any.

:Is there any available or is there a convertor .pod -> .info?
Back in 1997, Krishna Sethuraman (krishna@mit.edu) wrote a 
pod2texinfo which had this edit history:

# Krishna Sethuraman (krishna@mit.edu) (originator)
# Ulrich Pfeifer <pfeifer@charly.informatik.uni-dortmund.de>
# psmith@baynetworks.com (Paul D. Smith)
# Chris Dean <ctdean@cogit.com> Wed May 21 21:02:46 PDT 1997
#

I don't know if further work occured on it.
-- 
<URL: mailto:lvirden@cas.org> Quote: Saving the world before bedtime.
<*> O- <URL: http://www.purl.org/NET/lvirden/>
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: Fri, 7 May 1999 09:47:26 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Find all files regardless of extension
Message-Id: <etqug7.dl8.ln@magna.metronet.com>

Clas (clas.karrlund@nospamemw.ericsson.se) wrote:

: I want to know if a file called  "filename.*", e.g "filename.txt" or
: "filename.exe", exists in a directory .

: I tried to serch for "filename.*" in the directory, but it din4t seem to
: work.


   Where is the code you wrote?
   

   Maybe this will help:

      perldoc -f glob


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 07 May 1999 19:10:25 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Function vs Object oriented
Message-Id: <BUGY2.211$vP2.139@news.rdc1.tn.home.com>

>On a different note, using CGI.pm to generate dynamic documents seems kinda
>cumbersome. I mean, isn't it easier and faster just to use a here document?
>What am I not thinking about?


As before, I'll skip the more technical questions for the others. :)

I agree on this latter note concerning dynamic documents in CGI.pm. I don't
really get it either and wouldn't mind having it explained to me. When I have
used it, I often end up with a hybrid of here documents and CGI.pm based HTML
output anyway. Inserting a form text element basically takes the same amount
of typing either way. With the module it seems you are just telling it to
print it for you. It's like telling someone how to sweep. It's a heck of alot
easier and faster to grab the broom and do it yourself.

It all seems rather silly especially considering people like to add things as
they come along... javascript, DHTML, Frames... where do you stop before it's
worn out is welcome to your system? It's a means to an end IMO.

If you don't want all the overhead of that particular module, you might look
into CGI_Lite which strips out all that gunk and just encodes/decodes CGI and
handles file uploads. I think there are thinner versions than that which
eliminate the upload functionality as well.

Go to CPAN and look at the CGI modules to see what's available in that arena.
According to your posts, you seem to be just getting into this. You might
investigate the basics of the language before you jump too far into the module
pool. It's really easy to get ahead of yourself trying out all the neat
gizmos.

CT




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

Date: 07 May 1999 15:44:37 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Function vs Object oriented
Message-Id: <x7n1zgu0ka.fsf@home.sysarch.com>

>>>>> "CRT" == Charles R Thompson <design@raincloud-studios.com> writes:

  >> On a different note, using CGI.pm to generate dynamic documents
  >> seems kinda cumbersome. I mean, isn't it easier and faster just to
  >> use a here document?  What am I not thinking about?

  CRT> As before, I'll skip the more technical questions for the
  CRT> others. :)

  CRT> I agree on this latter note concerning dynamic documents in
  CRT> CGI.pm. I don't really get it either and wouldn't mind having it
  CRT> explained to me. When I have used it, I often end up with a
  CRT> hybrid of here documents and CGI.pm based HTML output
  CRT> anyway. Inserting a form text element basically takes the same
  CRT> amount of typing either way. With the module it seems you are
  CRT> just telling it to print it for you. It's like telling someone
  CRT> how to sweep. It's a heck of alot easier and faster to grab the
  CRT> broom and do it yourself.

if you are building lists, menus, tables, etc. it is much nicer having
the routines do it for you. they also can factor in common attributes
which are more of a pain to type for each element. the html subs are
also correct and you won't accidentally leave a tag open or have some
flaky html errors like we see all the time.

i have even used cgi.pm to generate html offline since the subs do some
extra work for me and are cleaner.

regarding the object vs. sub calling styles, it originally only
supported object form and the imported subs were added recently. i
prefer the sub form as it saves typing and is clearer to me but you have
to be careful of some case problems with tag names that match perl ops
like Tr vs. tr! lincoln had to dance quickly fixing those.

the object form is most useful when you have multiple cgi object, one
from the form and others from saved files. then you need seperate
objects to manage them. the import sub versions actually use a builtin
default object i believe.

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Fri, 07 May 1999 19:11:55 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: HASH references...
Message-Id: <%VGY2.215$vP2.173@news.rdc1.tn.home.com>

>%hash=qw/a 1 b 2 c 3 d 4 e 5/;


I've never seen that before. Interesting.

(going to open a book)

CT




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

Date: Fri, 07 May 1999 12:45:01 -0700
From: "Kevin A. Collins" <kac@srsys.com>
Subject: How to get current working directory?
Message-Id: <373342BD.6A0BDB4E@srsys.com>

Hi there,

I was just wondering if there is a standard way to get the path of the
current working directory. I've looked through a lot of the Perl
documentation, but haven't found an easy solution. I'm using Perl for
Win32 right now and there is a Win32::GetCwd() function, but I just
thought there might be a more portable solution.

Thanks in advance!

Kevin




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

Date: Fri, 07 May 1999 19:17:52 GMT
From: brian@helka.mutagenic.org (Brian Peisley)
Subject: Re: How to match a variable in pattern - Help a newbie !
Message-Id: <slrn7j6f6k.s3.brian@helka.mutagenic.org>

In Anton V. Antich <antich@quantum.che.nsk.su> writes:
>
>Hello!
>
>I've got a following problem. There is a formatted text file, something
>like:
>
> O1  1  S    1   ......... 
> O1  2  S    2   .........
> O1  3  X    3   .........
> C1  1  S    4   ........  here go unimportant columns
> C1  2  S    5    .......
> C1  3  Y    6    ........

>I have to choose lines which columns 1 and 3 match given values:
>
>$f1 = 'O1';
>$f3 = 'S';
>
>Then i want to pass them to a sub and print matching lines. A question -
>is it possible to check variables in the pattern/reg.exp.? I couldn't
>manage to do that, and wrote something like:
>
>...
>if (  (/(\w+)\s+\d+\s+(\w+)/) && ($1 eq $f1) && ($2 eq $f3))
> { print $_;
> };

This worked for me, are you sure you're putting the data into $_ ? You
might try printing $_ before you try matching it to make sure it has the
value you think it should.

You may also want to match the beginning of the line so you don't match stuff in
columns besides the first and third.

-- 
Brian Peisley
bdp@mutagenic.org


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

Date: Fri, 07 May 1999 19:25:47 GMT
From: mjzanghi@my-dejanews.com
Subject: https help
Message-Id: <7gvenk$pve$1@nnrp1.deja.com>

I need to check a server to see that it is up and running properly.  The
server is accessed using https:// connection where the user has to enter a
valid user name and passwd to gain access.  I would like to write a script
that will go to this https site, enter the valid user id and passwd and
verify that it gained access to the server (thereby stating that the server
is up and running)

Can someone point me in the right direction?

Thank you in advance for your time


Mike

mjz01@health.state.ny.us

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 07 May 1999 19:25:45 GMT
From: mjzanghi@my-dejanews.com
Subject: https help
Message-Id: <7gvenj$pvd$1@nnrp1.deja.com>

I need to check a server to see that it is up and running properly.  The
server is accessed using https:// connection where the user has to enter a
valid user name and passwd to gain access.  I would like to write a script
that will go to this https site, enter the valid user id and passwd and
verify that it gained access to the server (thereby stating that the server
is up and running)

Can someone point me in the right direction?

Thank you in advance for your time


Mike

mjz01@health.state.ny.us

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 07 May 1999 19:31:51 GMT
From: mjz01@health.state.ny.us
Subject: https help
Message-Id: <7gvf37$qc0$1@nnrp1.deja.com>

I need to check a server to see that it is up and running properly.  The
server is accessed using https:// connection where the user has to enter a
valid user name and passwd to gain access.  I would like to write a script
that will go to this https site, enter the valid user id and passwd and
verify that it gained access to the server (thereby stating that the server
is up and running)

Can someone point me in the right direction?

Thank you in advance for your time


Mike

mjz01@health.state.ny.us

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 07 May 1999 19:00:03 GMT
From: sstarre@my-dejanews.com
Subject: Re: Increment a variable's name
Message-Id: <7gvd7g$oi5$1@nnrp1.deja.com>



Hi Tom:

Its preferable to use an hash. When rendering an HTML doc, using an array can
prove difficult at times as [] aren't legal chars in a field name. I've used
approaches like:

<input type=hidden name=myvar_1 value=cat>
<input type=hidden name=myvar_2 value=dog>

and so on..

which returns $in{myvar_1}, $in{myvar_2} and so on. You can then access hash
elements with a variable such as $in{"myvar_$i"} which is essentially what you
were trying to do:

****************************************************************************8
#! /usr/local/bin/perl -w

@h{qw(v1 v2 v3)}=qw(cat man dog);

for ($i=1;$i<4;$i++)
 {print "$h{\"v$i\"}\n";}

csh> x
cat
man
dog


In article <3731E3E1.F11997FA@ernieball.com>,
  tom@ernieball.com wrote:
> Is there a way I can increment a variable's name?   The form I am
> processing can have a different number of quantity variables depending
> on the number of items listed.  If I have $i number of items can I
> assign values to a variable that might look like qty$i?  I need to
> incerment the variables name by 1 each time a loop runs, for example:
> qty1, then qty2, then qty3 ....
>
> Thank you for your help
>
> Tom Pape
> Ernie Ball, Inc. / MusicMan
> tom@ernieball.com
>
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 07 May 1999 19:13:59 GMT
From: gregarine <michaelw@palawnet.com>
Subject: Re: ODBC and Access memo fields
Message-Id: <7gve1i$pam$1@nnrp1.deja.com>

Thanks, I probably will just rewrite in Visual Basic

What is the Automation system?
What is the BSTR datatype?

In article <373320b0.0@news.new-era.net>,
  scott@aravis.softbase.com (Scott McMahan) wrote:
> gregarine (michaelw@palawnet.com) wrote:
> > I am using Active Perl on NT using ODBC to access a memo field out of
> > Access97. The problem is that I am only getting part of the memo field
loaded
> > into my perl variable.	Their is a long article in the memo field.  It
seems
> > due to some sort of character limitation because when i cut stuff out of the
> > memo field I am able to load a bit more.  Thus I don't think it is due to
> > some sort of unrecognizable caharacter or an EOF.
>
> You may very well be hitting a limit on the amount of data that can go
> through an Automation string. I think the limit is 255 bytes, but it has
> been so long since I encountered that limit I can't remember. I don't
> think this is an Access bug as much as it is the Automation system's bug.
> I think the limit is built into the BSTR data type. It's been a long
> time, though, since I dealt with that.
>
> Scott
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 07 May 1999 19:06:33 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Oops, here is the script
Message-Id: <slrn7j6dkn.7mf.dragons@dragons.duesouth.net>

On Fri, 7 May 1999 14:48:09 -0300, Kevin Howe <khowe@performance-net.com>
lucked upon a computer, and thus typed in the following:
: use strict;
[snip program]

Can't use string ("1") as a SCALAR ref while "strict refs" in use at -
line 13.

Did you check to see what perldiag has to say about that?

$ man perldiag
 ...
       Can't use string '%s' as %s ref while """"strict refs""""
           in use
           (F) Only hard references are allowed by "strict refs".
           Symbolic references are disallowed.  See the perlref
           manpage.
 ...

And you checked the docs for strict, didn't you?

$ perldoc strict
 ...
       If no import list is supplied, all possible restrictions
       are assumed.  (This is the safest mode to operate in, but
 ...
       strict refs
             This generates a runtime error if you use symbolic
             references (see the perlref manpage).

                 use strict 'refs';
                 $ref = \$foo;
                 print $$ref;        # ok
                 $ref = "foo";
                 print $$ref;        # runtime error; normally ok
 ...

Hmm.

HTH,

--Matthew


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

Date: Fri, 7 May 1999 12:29:27 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: PERLFUNC: binmode - prepare binary files on old systems
Message-Id: <MPG.119cdef4f5f62f969899f9@nntp.hpl.hp.com>

In article <x7wvyku6im.fsf@home.sysarch.com> on 07 May 1999 13:36:01 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
>   BL> Larry Rosler wrote:
>   >> It is hard to believe that a 'programmer' doesn't know!  A text file 
>   >> consists of a sequence of characters organized into lines (i.e., with 
>   >> chunks terminated by line endings, whatever they may be).  A binary file 
>   >> is a sequence of characters without such an organization.  Sheesh!
> 
>   BL> Makes you wonder why Unix (and Perl) needs the -T and -B filetest
>   BL> operators anyway...
> 
>   BL>                 -T  File is a text file.
>   BL>                 -B  File is a binary file (opposite of -T).
> 
> those are guesses based on percentages of printable/non-printable chars
> in the first block. not something i have needed since i know what files
> i am dealing with. but if you are scanning a large dir tree for strings,
> it might be faster to skip binary files if you can't tell by their names
> or suffixes. i am sure there are other uses for those tests.

The heuristic is described in perlfunc:

The -T and -B switches work as follows. The first block or so of the 
file is examined for odd characters such as strange control codes or 
characters with the high bit set. If too many strange characters (>30%) 
are found, it's a -B file, otherwise it's a -T file. Also, any file 
containing null in the first block is considered a binary file...

As I said later in that same post in reference to the Unix 'file' 
command, it used to make a meaningful distinction between an ASCII text 
file and others.  But Latin-1 screws it completely.

Herewith a proposed documentation change:

                  -T  File is an ASCII text file.
                  -B  File is a 'binary' file (opposite of -T).

perlbug submitted.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 07 May 1999 19:04:54 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: procedure to convert sec to HH:MM:SS format
Message-Id: <373435a7.748243@news.skynet.be>

Larry Rosler wrote:

>> Apparently, if you want to be on the safe side, it's NOT redundant.
>
>I know of one other situation where a number is implicity truncated:  in 
>array indexing.  I've looked through perldata, perlop, and perlsyn, but 
>can't find an explicit statement of this truncation.  All perldata says 
>is "Normal arrays are indexed by number, starting with 0."  D'oh!.

I've noticed that too.

There's even a case whereyou actually need that behaviour: rand(). If
you give it a (numeric) parameter, it will return a pseudo-random number
between zero and that number, including the lower but excluding the
upper limit. It does NOT truncate it to an integer, which is the most
useful case. So if you want a random element from an array

	$ary[rand @ary]

you explicitely depend on the truncation of the float to integer (you
need an integer index below scalar(@ary)).

>I know of no situation where a number is implicitly rounded.

And yet, that is what *I* would have expected.

>Changing the current implementation of s?printf from truncation to 
>rounding would be malicious tampering with existing, functioning code.  

I've noticed this before: you do seem to have a tendency to rely too (?)
much on experimentally determined behaviour. You cannot seem to be able
to accept (and work around) unspecified behaviour. I do. A feature is
not documented? Don't rely on it. (e.g. execution order for map() ;-)

Anyway, I've heard reports on (s)printf() doing different things on
different platforms, when given the same data. Nasty but true.

Perl depends on the C compiler used to build the executable with. So
Perl effectively inherits the behaviour from the C library used. And C
libraries have a tendency to have differces.

Since the implementation of (s)printf() is more and more part of Perl's
own explicit source, you may be in luck. It sure shows that it's
behaviour is likely to become more and more stable, even across
different ports, to do one thing when fed a dubious value.

	Bart.


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

Date: Fri, 07 May 1999 12:54:44 -0700
From: mikej <mikej@1185design.com>
Subject: running a file from unix shell
Message-Id: <37334503.BEEE1A44@1185design.com>

Hi,

Im trying to run a file called "Configure" from a unix shell. The file
has full execute permissions and when I am in the same direcory as the
file I type:

 ../Configure

from the command line. Then it tells me ./Configure: not found

it will say the same thing if I just type:

Configure

About a few months ago we had to reinstall our unix system. Before the
reinstall i could run anything i wanted from the command line (perl
scripts and things), but now it keeps saying "not found". Am I missing
something here?

-mike
 
 



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

Date: Fri, 7 May 1999 17:28:38 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: simple way for several if ( eq ||) ?
Message-Id: <ebohlmanFBDHvq.GuL@netcom.com>

Eric The Read <emschwar@rmi.net> wrote:

: The interesting case here for me was that the grep approach wasn't
: terribly more expensive for the case where it didn't match, whereas the
: regex was over twice as slow for the case in which it didn't match.  

: My question is, is this generalizable?  That is, can I assume that grep
: isn't ever going to take (significantly) longer to fail than to succeed,
: or is it just the data I've chosen here?  I doubt I can generalize much
: from the regex, since relative times to succeed or fail will most likely
: depend heavily on the expression in question.

Well, grep has to iterate over the whole list regardless of whether it 
finds any matches (it has to continue to the end even if the first 
element matched), so it seems to me that the only difference in run times 
should be the expense of adding matched items to the returned list.

One complaint about benchmarks like this: they don't show anything about 
how the runtime is affected by the length of the lists to be searched.  
Remember that an algorithm with a high time complexity, but small 
constant term, can easily beat one with a low time complexity but large 
constant when applied to unrealistically small amounts of data.  A 
bubblesort will usually run faster than a quicksort if you're sorting 
only 5 items.




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

Date: Fri, 7 May 1999 12:44:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: simple way for several if ( eq ||) ?
Message-Id: <MPG.119ce25a756a3ff9899fa@nntp.hpl.hp.com>

In article <37331a85.459612@news.skynet.be> on Fri, 07 May 1999 16:54:56 
GMT, Bart Lateur <bart.lateur@skynet.be> says...
> sam@godzilla.wvn.wvnet.edu wrote:
> >Hi All Is there a simpler way to do the following:
> >
> >if ($name eq "BOB" || $name eq "SAM" || $name eq "CHRIS" || $name eq "DAVE"){}
> 
> Hashes?
> 
> 	%accept = map { $_ => 1 } qw(BOB SAM CHRIS DAVE);
> 	if($accept{$name}) {  ... }

Indeed, as Bob Trieger's benchmark showed, This Is The Way To Do It.  If 
the list is big, so that the time to generate the hash is significant, 
the following is much faster (and the more that people see of hash 
slices, the better):

      my %accept;
	@accept{ qw(BOB SAM CHRIS DAVE) } = ();
  	if (exists $accept{$name}) {  ... }

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 07 May 1999 13:51:53 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: simple way for several if ( eq ||) ?
Message-Id: <xkfwvykk692.fsf@valdemar.col.hp.com>

Eric Bohlman <ebohlman@netcom.com> writes:
> One complaint about benchmarks like this: they don't show anything about 
> how the runtime is affected by the length of the lists to be searched.

In fact, that's the whole reason I asked about the generalization.  It
seemed to me that, as you say, grep will have a more or less constant
running time across any given list.  But it looks like the regex was much 
faster.  I guess I should have asked the other question, namely: is the
regex winning solely because of the tiny data sets involved, or is it
generally faster?

-=Eric


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

Date: Fri, 07 May 1999 19:14:27 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Stupid FAQ question of the (day? month? year?)
Message-Id: <nYGY2.220$vP2.150@news.rdc1.tn.home.com>

>No, they aren't. They are in POD format and this format isn't pretty if
>simply displayed on a windows machine.


If you have a windows machine, it seems silly to convert it to text since you
probably already have a browser to view them. If it's worth a darn the browser
has a find feature also. I say just save um as html to your harddrive. At
least you can get to them fast and the #targets hold up.

CT




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

Date: Fri, 07 May 1999 19:53:48 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Stupid FAQ question of the (day? month? year?)
Message-Id: <7gvfk6$k4v$1@holly.prod.itd.earthlink.net>

[ courtesy cc sent by mail if address not munged ]
     
"Charles R. Thompson" <design@raincloud-studios.com> wrote:
>>No, they aren't. They are in POD format and this format isn't pretty if
>>simply displayed on a windows machine.
>
>
>If you have a windows machine, it seems silly to convert it to text since you
>probably already have a browser to view them. If it's worth a darn the browser
>has a find feature also. I say just save um as html to your harddrive. At
>least you can get to them fast and the #targets hold up.

A simple text editor, such as notepad, is a lot less cumbersome than a 
web-browser. I can have my answer by the time the browser initializes.


I don't know about the MS version of perl, but the GS 5.004 version 
already saves them as html. I use these also if I already have a browser 
window open.



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

Date: Fri, 07 May 1999 19:47:34 GMT
From: epement@jpusa.chi.il.us (Eric Pement)
Subject: tcgrep not expanding command-line wildcards
Message-Id: <37333d17.67898573@news.jpusa.net>

I'm using ActiveState Perl v5.005_03, build 515, under a Win95 system.
I have downloaded Tom Christiansen's "tcgrep" script v1.4 from the
O'Reilly web site, the same script that's listed on pp. 211-218 of "The
Perl Cookbook."

When I try executing this script, there are a few problems. At first,
it complained because "gzcat" was not found, but I renamed that command
to zcat, which I already have on the path. My chief problem is that
the script is not expanding command-line wildcards. I.e.,

    perl tcgrep "somestring" *.*

results in an error message,

    tcgrep: file "*.*" does not exist

The same error message appears if I use a filespec like "*.txt" or "*".

I'm not sure exactly what's causing this problem. Prior to this, I had
ActiveState build 315 of Perl for Win32, and it handled ambiguous
filespecs just fine. Its problem was that none of switches were being
recognized! So I downloaded a more recent build of Win32 Perl in hope
of solving the problem.

Build 515 was much bigger (16 megs instead of 4 megs), and while it
now handles all the switches, plus recognizes individual files with
fully-qualified or relative (e.g, ..\dotted) filespecs, it still fails
to accommodate any ambiguous filespecs.

I suspect the problem is with ActiveState perl itself, because it fails
the following test where tcgrep is in the current directory:

     perl -ne "print if /match/" tc*.*

generating this error message:

     Can't open tc*.*: No such file or directory

This behavior definitely did not occur with build 315, nor with earlier
versions of Perl for DOS. Has anyone noticed this problem before? Any
suggested fixes?


--
Eric Pement <epement@jpusa.org>
senior editor, Cornerstone magazine  Get the sed FAQ file here:
http://www.cornerstonemag.com        http://www.cornerstonemag.com/sed/
939 W. Wilson, Chicago, IL 60640
tel: 773/561-2450, 1-(ext.)2084      fax: 773/989-2076


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

Date: Fri, 7 May 1999 12:06:01 -0700
From: "Gabe" <grichard@uci.edu>
Subject: Re: Why my?
Message-Id: <7gvd91$eth@news.service.uci.edu>

> You should read ...
>http://language.perl.com/newdocs/pod/perlfaq7.html#What_s_the_difference_be
twe
> en_dy
> To get a basic look at my.
> Passing scalars and arrays between subroutines is possible. I think I saw
you
> mention the Camel Book in a previous message here?!? Try page 110 which
begins
> a discussion on subroutines. (112 answers your question)
> P.S. Flipping back a few pages to 108 will give more insight to my.

Thank you! You pointed me exactly where I needed to be pointed!

Gabe






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

Date: Fri, 7 May 1999 12:10:06 -0700
From: "Gabe" <grichard@uci.edu>
Subject: Re: Why my?
Message-Id: <7gvdgn$f38@news.service.uci.edu>

Eric The Read <emschwar@rmi.net> wrote in message
news:xkf3e18lnd6.fsf@valdemar.col.hp.com...
> You should "use vars qw($var1, @var2, %var3);".

Huh?

> then "use strict" will complain.  You *are* using the strict module,
> aren't you?

Nope. I've just begun learning about modules. The first one I'm looking at
is CGI.pm.

Gabe




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

Date: Fri, 07 May 1999 19:16:32 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Why my?
Message-Id: <k_GY2.225$vP2.130@news.rdc1.tn.home.com>

>Thank you! You pointed me exactly where I needed to be pointed!


I think I hear a unanimous "You ain't kidding brother". Thanks for going to
the FAQ. Use them often.

CT




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

Date: 07 May 1999 13:46:02 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Why my?
Message-Id: <xkfzp3gk6it.fsf@valdemar.col.hp.com>

"Gabe" <grichard@uci.edu> writes:
> Eric The Read <emschwar@rmi.net> wrote in message
> news:xkf3e18lnd6.fsf@valdemar.col.hp.com...
> > You should "use vars qw($var1, @var2, %var3);".
> 
> Huh?

This declares $var1, @var2 and %var3 as global variables within the
current package.  If you need to declare global variables, do it this
way.

perldoc vars

and 

perldoc strict

should help.  But usually, you don't need global variables; lexically
scoped variables (declared with "my") are just fine for most cases.

> > then "use strict" will complain.  You *are* using the strict module,
> > aren't you?
> 
> Nope. I've just begun learning about modules. The first one I'm looking at
> is CGI.pm.

*ALWAYS* include "use strict;" as the first line of your Perl programs,
until such time as you know why not to.  It forces you to declare all
your variables before using them, it prevents you from using symbolic
references (which are usually a bad thing), and prevents you from using
barewords, unless they're also functions.

In summary, "use strict;" forces good Perl style on you.  This may seem a 
bit odd, given how free-form Perl generally is, but it has the benefit of 
give you some more enforcable style guidelines that help you avoid many
of the most common mistakes.  I use "-w" (perldoc perlrun) and "use
strict;" (perldoc strict) in all my production Perl programs, and I
strongly encourage everyone else to do so, as well.

-=Eric


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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