[16860] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4272 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 9 14:05:30 2000

Date: Sat, 9 Sep 2000 11:05:11 -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: <968522711-v9-i4272@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 9 Sep 2000     Volume: 9 Number: 4272

Today's topics:
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
    Re: Converting PHP to Perl - Expert needed ! <simonis@myself.com>
    Re: Environment variables - how to list them all? <flavell@mail.cern.ch>
    Re: Environment variables - how to list them all? <flavell@mail.cern.ch>
        glob() feature = delightful japh <jeffp@crusoe.net>
    Re: Is HP finally recognizing Perl??? <DTOakey@cinci.rr.com>
    Re: Is this a bug or a feature? <bart.lateur@skynet.be>
    Re: New Perl Tutorial - www.perltutor.com (Keith Calvert Ivey)
    Re: New Perl Tutorial - www.perltutor.com <gellyfish@gellyfish.com>
    Re: Perl game Query <alian@alianwebserver.com>
        perl sockets: AF_UNIX to AF_INET port work around <pete@beforever.com>
    Re: Perl-native code for finding mail exchanger: nslook (Tony L. Svanstrom)
    Re: pl2bat missing from IndigoPerl distribution <gellyfish@gellyfish.com>
        pppperll.. <cccurious@ottawa.com>
        Restricting simultaneous file downloads in CGI program <brad@smithart.net>
    Re: use strict: why? (Gwyn Judd)
    Re: use strict: why? <uri@sysarch.com>
    Re: Variable not accepting value <dwb1@home.com>
    Re: Variable not accepting value <dwb1@home.com>
    Re: Variable not accepting value <jjohn@cs.umb.edu>
    Re: Variable not accepting value <uri@sysarch.com>
    Re: VBA conversion to Perl <DTOakey@cinci.rr.com>
    Re: What does "magic" mean? <ddorward@hotmail.com>
    Re: what is the best way to get the lastest line from a <jjohn@cs.umb.edu>
    Re: what is the best way to get the lastest line from a <uri@sysarch.com>
        Where can I find information of perl internationalizati <carfield@programmer.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 09 Sep 2000 10:22:18 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage968495045.19965@news.teleport.com>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://www.cpan.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

For an alternative way to get answers, check out the Perlfaq website.

    http://www.perlfaq.com/

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://www.cpan.org/
    http://www.perl.com/CPAN/
    http://www.cpan.org/doc/FAQs/FAQ/html/
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: 09 Sep 2000 17:09:38 GMT
From: Drew Simonis <simonis@myself.com>
Subject: Re: Converting PHP to Perl - Expert needed !
Message-Id: <39BA6C68.4D288A72@myself.com>

Sunil Jaiswal wrote:
> 
> ----> Apologies if this is the wrong place for this post ! <-----

It is, but you probably already knew that.

> 
> I'm looking for a PHP / Perl Expert who can help me out with some work :

Nothing you describe below warrants the attention of an expert.
Stop flattering yourself.  

And anyway, whats wrong with keeping these in PHP? PHP4 is rather
nice, I say.


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

Date: Sat, 9 Sep 2000 11:57:01 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Environment variables - how to list them all?
Message-Id: <Pine.GHP.4.21.0009091152530.925-100000@hpplus03.cern.ch>

On Sat, 9 Sep 2000, brian d foy wrote:

> > Sure, but the corresponding CGI environment variables contain
> > underscores.
> 
> it depends on how the headers are put into the environment. a
> particular server might do that, but the CGI specification
> doesn't specify how a server should do it. 

[...]

You win that round!

I keep complaining about people following off-topic threads, then I go
and do it myself and unintentionally demonstrate just why it's a bad
idea.  Thanks for the correction.

ttfn



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

Date: Sat, 9 Sep 2000 15:53:11 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Environment variables - how to list them all?
Message-Id: <Pine.GHP.4.21.0009091540520.13574-100000@hpplus03.cern.ch>

On Fri, 8 Sep 2000, Uri Guttman wrote:

>   AJF> On Fri, 8 Sep 2000, brian d foy wrote:
>   >> the "X-" headers contain a hyphen, for instance. HTTP is extensible.
>   >> the user can add headers, and those headers might have hyphens
>   >> in them. 
> 
>   AJF> Sure, but the corresponding CGI environment variables contain
>   AJF> underscores.
> 
> it depends on what interface you use to set the env. 

Well, if you're programming a CGI script (which is the more usual of
the CGI-relevant situations in Perl) then someone else has set the
environment for you, so this isn't an issue.

As brian has pointed out, the draft RFC CGI specification entertains
the possibility that these "request metadata" will be made available
in a platform-dependent way, but it still describes the "metavariable
names" in the form of "capitals with underscore" as the "canonical
representation".  Since, as a programmer of CGI scripts, one cannot
know what other representations might get used, it's hard to see how
one can program a CGI script portably in this sense!

> execve just takes a
> char ** pointer which can have anything in it. so you can pass and parse
> anything which deosn't have null bytes.

This is obviously interesting to someone who was implementing a server
(HTTPD) in Perl and trying to find how many different ways they could
legally break the CGI-script programmers' assumptions   ;-)

> the final result is moronzilla is wrong as usual.

Let's concentrate on the technical issues.  Taunting trolls is not a
very productive activity.

cheers



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

Date: Sat, 9 Sep 2000 10:49:31 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: glob() feature = delightful japh
Message-Id: <Pine.GSO.4.21.0009091049160.23350-100000@crusoe.crusoe.net>

$_=q;
$_ *= $_ ++;
;s;\S+;<rekcaH lreP rehtonA tsuJ>;eg;
print q rr . reverse;

-- 
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: Sat, 09 Sep 2000 16:38:25 GMT
From: "Dwight T. Oakey" <DTOakey@cinci.rr.com>
Subject: Re: Is HP finally recognizing Perl???
Message-Id: <5Itu5.3$P5.705@typhoon.kc.rr.com>

In article <MPG.1422d7187abac65898ad45@nntp.hpl.hp.com>, Larry Rosler
<lr@hpl.hp.com> wrote:


>In article <8FA96864Adavidkrainessyahooco@38.8.213.2> on Fri, 08 Sep 
>2000 17:18:36 GMT, David Krainess <davidkrainess@yahoo.com> says...
>> I just got a course catalog and sure enough and under HP-UX operations 
>> there is a course H4311S, Perl Programming, 4 days, $4,000.
>> 
>> We have the lastest HP-UX OS 10.20 patch installed and look at this:
>> 
>> # /usr/contrib/bin/perl -v
>>  
>> This is perl, version 4.0
>>  
>> $RCSfile: perl.c,v $$Revision: 4.0.1.8 $$Date: 1993/02/05 19:39:30 $
>> Patch level: 36
>>  
>> Copyright (c) 1989, 1990, 1991, Larry Wall
>>  
>> 
>> 
>> I guess I'm a little confused how they could teach a course if they still 
>> use 4.0.1.8 and haven't incorporated the new version into their software.
>
>You are confusing the perl bundled with the OS (evidently used by some 
>build or initialization procedures) with the perl used to teach this 
>class.  HP similarly bundles a dain-bramaged version of the C compiler, 
>which is virtually useless for real work.
>
>The course description mentions the CGI and Tk modules, and has a unit 
>called 'Advanced Data Structures' that includes references in the list 
>of topics.  Seems to require Perl 5, no?
>
>A 1999 version of this course was described thus:
>
>  Introduction to Perl Programming
>  Instructor: Tom Christianson (sic!)
>  3 days (with Lab) -- May 18 - 20
>  ... 
>
>I doubt that TomC would teach using Perl 4.036.
>
>Time to put this particular slander to rest.
>
>-- 
>(Just Another Larry) Rosler
>Hewlett-Packard Laboratories
>http://www.hpl.hp.com/personal/Larry_Rosler/
>lr@hpl.hp.com


I think you all are missing the point, by just a little bit...

The latest version of HP-UX is 11.x.  Perl 5 *is* included with the
HP-UX 11.x.

FYI.  HP-UX 10.20 was the earliest version capable of handling the
Y2K issue.  HP-UX 11.0 came out about a year ago (I think).

I hope this clears up some of the confusion.

    -Dwight


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

Date: Sat, 09 Sep 2000 16:54:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Is this a bug or a feature?
Message-Id: <ognkrs458q5hnbgg70pa3a8ns7g35jhfne@4ax.com>

elliotfinley@my-deja.com wrote:

>The output from this program is:
>One
>Two
>
>I expected it to be:
>One
>One
>One
>One
>One
>Two
>Two
>Two
>Two
>Two

So did I.

For starters, I dropped the "last", and this is what I got:

  One
  Two
  One
  Two
  One
  Two
  Two
  Two
  Two
  Two

That looks mor elike it, doesn't it? Now, I guess that because of your
extra blocks, "next" doesn't do what you think it should. Dropping the
bare blocks around the "if", makes the output turn into 5 "One"'s
followed by 5 "Two"'s.

So the question is: what does "next" do in a bare block?

	$\ = "\n";
	{
	    print 1;
	    {
	        print 2;
	        next;
	        print 3;
	    }
	    print 4;
	    next;
	    print 5;
	}
	print 6;
-->
	1
	2
	4
	6

Suprised? I am. But, in short, it looks to me as if "next" in a bare
block does the same as a "last" would: it jumps out of the block. (Try
replacing every "next" with "last" the output is the same.) That is
because it wants to go to the next loop, but a bare block normally loops
only once.

Oh, try "redo" in a bar block, to. It jumps back to the start of the
loop. If you'd do that in the above code, it would loop forever.

-- 
	Bart.


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

Date: Sat, 09 Sep 2000 15:02:10 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: New Perl Tutorial - www.perltutor.com
Message-Id: <39bb5016.43936843@news.newsguy.com>

tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote:

>hmmm...interpolating \\ in a single quoted string is pointless (and
>annoying, meaning you need to double your backslashes if you actually
>did want to print two of them.

How do you propose to represent a backslash at the end of a
single-quoted string then?  Or include a backslash followed 
by a single quote in the string?

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: 8 Sep 2000 22:03:14 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: New Perl Tutorial - www.perltutor.com
Message-Id: <8pbk6i$m1i$1@orpheus.gellyfish.com>

On 8 Sep 2000 08:52:36 -0700 Tom Christiansen wrote:
> In article <slrn8rhudn.8ll.tjla@thislove.dyndns.org>,
> Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
>>I really think you need to use the '-w' flag for all of your scripts as
>>well as the 'use strict' pragma.  
> 
> NB: The "use warnings" pragma is safer and more functional than a
> mere -w.  Why?  Because it's lexically scoped.  That way you don't
> autoenable warnings in separate lexical scopes--read, module
> files--that you don't have control over.
> 
> Advocate "use warnings" over -w in most cases.  See also the perllexwarn
> manpage and the -W and -X entries in the perlrun manpage.
> 

I couldn't agree with you more in principle, however it takes a little
while to test and upgrade some ninety servers to 5.6.0 so the 5.005 < stuff
sticks around for a little while I'm afraid.  I guess I ought to promise
to use this stuff in examples here though ...

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sat, 09 Sep 2000 13:55:26 +0200
From: Alain BARBET <alian@alianwebserver.com>
Subject: Re: Perl game Query
Message-Id: <39BA252E.D37115F1@alianwebserver.com>

Hi,

> Does anyone know if there is available Perl modules for playing backgammon?
> Creating such a program is an enormous challenge and I would really like to see
> how others may have attempted it.

Look at http://www.perl.com/pub/language/ppt/src/backgammon/index.html
HTH,
--
Alain & Estelle BARBET
http://www.alianwebserver.com


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

Date: 9 Sep 2000 11:09:39 -0500
From: Peter Schultz <pete@beforever.com>
Subject: perl sockets: AF_UNIX to AF_INET port work around
Message-Id: <6htu5.693$KK1.85606@news.corpcomm.net>

I'm trying to get sockets to work under BeOS, it only supports
Internet domain sockets so I'm wondering what steps to take
in order to work around this problem.  Here is a snip from a
conversation I was having on the subject:

>>Could you please point me to a resource, or give me a couple
>>hints on how I can complete the work around?  Is it a simple
>>matter of switching AF_UNIX with AF_INET?
>
>Yes, and switching sockaddr_un with sockaddr_in and filling in the
>structure.  Where a domain socket references a file, you'll have to
>reference a port. (bound to localhost so the entire world doesn't see
>it)

Here are the errors I am currently getting from make test-notty:
lib/io_sock........No such file or directory at lib/io_sock.t line 29.
FAILED at test 1
lib/io_udp.........No such file or directory (maybe your system does not
have the 'localhost' address defined) at lib/io_udp.t line 36.
FAILED at test 1

Does anyone know of a patch from another platform with the same
problem?  I'm interested in fixing this the right way, so I came to you,
the perl experts.  :-)

Thank you,
Pete...



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

Date: Sat, 9 Sep 2000 18:12:40 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Perl-native code for finding mail exchanger: nslookup -q=mx some.domain?
Message-Id: <1egpe15.11i5ct9s0ibswN%tony@svanstrom.com>

<bryl@my-deja.com> wrote:

> If both fail, it seems likely that the user didn't enter a correct
> domain name in their email. I'd like to replace both calls with perl-
> native code. The first one is easy enough:
> 
> unless (my $addr = gethostbyname $domain) {
>       error("Invalid domain name in your email address.");
> }

Eh, no... that won't catch if the domain only has a MX-record and
nothing else, me thinks.


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: 8 Sep 2000 22:04:44 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: pl2bat missing from IndigoPerl distribution
Message-Id: <8pbk9c$m1l$1@orpheus.gellyfish.com>

On Thu, 7 Sep 2000 14:18:18 -0500 Cogswheel wrote:
> I just downloaded and installed the IndigoPerl distribution for Win32
> and discovered that there was no pl2bat utility included.  Could someone
> point me to a source?
> 

Then download a version of Perl that has that included.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sat, 09 Sep 2000 17:26:18 GMT
From: "Mark Livingstone" <cccurious@ottawa.com>
Subject: pppperll..
Message-Id: <_ouu5.19529$E_6.7059708@news3.rdc1.on.home.com>

re,

i am executing a perl script using SSI (<!--#exec
cgi="/cgi-bin/mcount.cgi" -->).

if i specify "mcount.cgi 1212", how do i make perl read that "1212" syntax
and based upon it, print "command 1".. if "2323" given, then print "2323"?

thanks in advance!




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

Date: 9 Sep 2000 12:49:56 -0500
From: "news-east.newscene.com" <brad@smithart.net>
Subject: Restricting simultaneous file downloads in CGI program
Message-Id: <39ba779b$0$94165$45beb828@newscene.com>

I've finally given up and decided to ask for help/answers.

Here's my goal:

I want to be able to track and restrict how many users can simultaneously
download a particular file.

Some possible solutions I've considered:

1) I've tried using a counter file -- incrementing it when a user starts to
download, decrementing it when the download is complete, and checking the
counter file for too many users before beginning the download.
Unfortunately, when someone *cancels* a download, the Perl programs stops,
and the counter never gets decremented.

2) If there was some function that would return from the system how many
connections/processes were using a particular file, I could call that.
Unfortunately, if a call like that exists, I haven't been able to find it.

3) Of course, I could use file locking to restrict the download to a single
user.
Unfortunately, that's a little *too* restrictive.

If I could find a way to keep the program running after a "cancel" (and
maybe intercept the appropriate HTTP headers?), I could use solution number
1. (I'd like to know how to do that anyway.) As a matter of fact, the best
case would be to find ways to do both 1 and 2, for future reference. Surely
there's more than one way to do it?

I'll be happy to provide more details, if necessary.

Brad
-----




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

Date: Sat, 09 Sep 2000 11:46:50 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: use strict: why?
Message-Id: <slrn8rk8p7.edj.tjla@thislove.dyndns.org>

I was shocked! How could Uri Guttman <uri@sysarch.com>
say such a terrible thing:
>>>>>> "GJ" == Gwyn Judd <tjla@guvfybir.qlaqaf.bet> writes:
>
>  >> my       @word = qw/do you see what I see/;
>  >> local    @word[2,-1] = ("know") x 2;
>
>  GJ> interesting...if we make it:
>
>  GJ>          local   @word = ("blah");
>
>  GJ> we get:
>
>  GJ>          Can't localize lexical variable @word at - line 4.
>
>  GJ> but it works with the array slice...hmmm...does that mean the my
>  GJ> variable is lexical in scope but the array elements get listed in the
>  GJ> symbol table?
>
>local affects the VALUE of any variable. you can localize an element of
>a hash or an array and since you can localize multiple values, you can
>localize slices. 

Yes but the slice it was localising was part of a lexically scoped
array. You can't localise a lexically scoped variable:

[gwyn@thislove:~]$ cat local.pl 
my $x = "blah";
{
local ($x) = "bletch";
}
[gwyn@thislove:~]$ perl -w local.pl 
Can't localize lexical variable $x at local.pl line 3.

So what is so special about a slice?

>in general, it is best to forget all these wacky uses of local and just
>use it for perl variables, typeglobs and the few other things mentioned
>by mjd in his article about 7 uses for local.

yah

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Every person who has mastered a profession is a skeptic concerning it.
		-- George Bernard Shaw


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

Date: Sat, 09 Sep 2000 15:25:07 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: use strict: why?
Message-Id: <x7g0n9io4t.fsf@home.sysarch.com>

>>>>> "GJ" == Gwyn Judd <tjla@guvfybir.qlaqaf.bet> writes:

  GJ> Yes but the slice it was localising was part of a lexically scoped
  GJ> array. You can't localise a lexically scoped variable:

you are missing the point. in your mind, separate the way you access a
value (lexical or symbolic) from the value itself. local affects the
value only and not the variable. so if you have access to the value you
can localize it. a slice has access to the values of a lexical so local
can work on those values. 

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 09 Sep 2000 12:07:32 GMT
From:  <dwb1@home.com>
Subject: Re: Variable not accepting value
Message-Id: <Pine.LNX.4.20.0009090722150.13965-100000@ethyl.addictmud.org>

On 9 Sep 2000, Tina Mueller wrote:

> hi,
> In comp.lang.perl.misc dwb1@home.com wrote:
> 
> > I'm having problems occasionally with variables not accepting a value.
> 
> > 	my @path = split(/^A/, $in{QUESTION_PATH});
> 
> without looking too much at the rest of the code, this
> seems wrong to me.
> what are you splitting here?
> just remove the first "A" would have the same effect.
> maybe you want to split on "^A",
> and not on "A" at the beginning of the string.
> remember from
> perldoc perlre
> that "^" is special in regexes.
> split on /\^A/ will do the trick. i hope
> that's the error, as I said, didn't look at the rest.
> 

I'm sorry, when I cut and paste the routine, the ctrl-a character pasted
as 2 characters (the ^ and A).  Sorry for the confusion, but in my code
it's just 1 character 

Dan.




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

Date: Sat, 09 Sep 2000 12:11:16 GMT
From:  <dwb1@home.com>
Subject: Re: Variable not accepting value
Message-Id: <Pine.LNX.4.20.0009090724320.13965-100000@ethyl.addictmud.org>

On Sat, 9 Sep 2000, Uri Guttman wrote:

> >>>>> "JJ" == Joe Johnston <jjohn@cs.umb.edu> writes:
> 
>   >> my @path = split(/^A/, $in{QUESTION_PATH});
>   >> for (my $i = 0; $i < $#path; $i++) {
> 
> 
>   JJ> for (my $i = 0; $i < @path - 1; $i++ ){ ... }
> 
>   JJ> It is such a common mistake to forget that $#path is the last index 
>   JJ> of the array @path. You might want to emphasis that you are not going
> 
> and both of you are skipping the last entry in @path. let's assume there
> are 10 elements in @path, indexed from 0-9. both of your loops are
> comparing $i to 9 and therefore fail when $i == 9. 
> 
> the proper loop idiom to access all elements of an array is:
> 
> 	for (my $i = 0; $i < @path ; $i++ )
> 
> but in general c style for loops are rarely needed in perl so look for
> way to use foreach loops instead.
> 

The point of the function is to remove the last element when rebuilding
the string.  thus why the for loop was used.  Yes I do see that there
is plenty of other ways it could have been written, but I'm trying to
gain an explaination of why the variable in the %in hash will not allow
itself to be set to blank directly (although delete was reccomended, so
I'm going to see how that works out).

Dan




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

Date: Sat, 09 Sep 2000 12:25:19 GMT
From: Joe Johnston <jjohn@cs.umb.edu>
Subject: Re: Variable not accepting value
Message-Id: <39BA2C2D.3391BAA2@cs.umb.edu>

Uri Guttman wrote:
> 
> and both of you are skipping the last entry in @path. let's assume there
> are 10 elements in @path, indexed from 0-9. both of your loops are
> comparing $i to 9 and therefore fail when $i == 9.

It is funny that you didn't quote the rest of my last sentence. 
The whole context is:

   It is such a common mistake to forget that $#path is the last index 
   of the array @path. You might want to emphasis that you are not going
   to process the last element of the array. 

Uri, I think the original poster *wanted* to skip the last element
of the array, as weird as that sounds. Recall that the function was 
designed to remove the last subfield of the incoming string in that
hash. Your assumption that he wanted to iterate throught the whole 
loop was my assumption too. Then I reread the code and his post. 

I appreciate your comment about C-style loops though. They are 
a bit icky.

Peace.

-- 
----------------
Joe Johnston
http://aliensaliensaliens.com


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

Date: Sat, 09 Sep 2000 15:37:51 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Variable not accepting value
Message-Id: <x7aedhinjl.fsf@home.sysarch.com>

>>>>> "JJ" == Joe Johnston <jjohn@cs.umb.edu> writes:

  JJ> Uri Guttman wrote:
  >> 
  >> and both of you are skipping the last entry in @path. let's assume there
  >> are 10 elements in @path, indexed from 0-9. both of your loops are
  >> comparing $i to 9 and therefore fail when $i == 9.

  JJ> It is funny that you didn't quote the rest of my last sentence. 
  JJ> The whole context is:

  JJ>    It is such a common mistake to forget that $#path is the last index 
  JJ>    of the array @path. You might want to emphasis that you are not going
  JJ>    to process the last element of the array. 

  JJ> Uri, I think the original poster *wanted* to skip the last element
  JJ> of the array, as weird as that sounds. Recall that the function was 
  JJ> designed to remove the last subfield of the incoming string in that
  JJ> hash. Your assumption that he wanted to iterate throught the whole 
  JJ> loop was my assumption too. Then I reread the code and his post. 

i don't recall seeing the OP. it was not clear from what i read that the
last element was being skipped on purpose.

another way would be to simply pop the last element before doin a normal
looking loop. or control the number of elements in the list at split
time. but if you c style loop over an array and skip elements, be sure
you comment why you are doing that.

which reminds me:

code is what

comments are why


uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 09 Sep 2000 16:30:27 GMT
From: "Dwight T. Oakey" <DTOakey@cinci.rr.com>
Subject: Re: VBA conversion to Perl
Message-Id: <DAtu5.2$P5.157@typhoon.kc.rr.com>

In article <39b72d29.1@d2o68.telia.com>, "Nadim Khemir" <nkh@cpen.com>
wrote:


>"David Hedtke" <dhedtke@birch.com> wrote in message
>news:srdhsrm7ljn62@corp.supernews.com...
>> I am unable to find any additional references to assist me in converting
>> this VBA macro for Excel in to Perl code...
>
>Check if th ActiveState help called "Usig  OLE with Perl" could help.
>
>

Also, if using ActiveState (port of) Perl, you can actually use
"PerlScript".
This means that the Windows Script Host becomes the Perl interpreter.  This
also means that you can mix Perl and VB code in the same script.

While I'm no expert, I have experimented with this, a little, in ASP pages.
If I'm not mistaken (please, anyone who knows better, feel free to correct
me!) in your example, you'd have to *convert* all the VBA code into perl.
Meaning that you have to convert all the:

        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlTop
        .WrapText = True
        .Orientation = 0
        .ShrinkToFit = False
        .MergeCells = False

into perl objects - essentially rewriting the VBA code in perl syntax.
However, if you use PerlScript, you should be able to do something like
this:  (NOTE: This is an example for ASP...)

        <%@ Language = PerlScrit %>
        <%
            # Insert perl code here.
        %>
        <%@ Language = VBScript %>
        <%
            ' Insert VBScript code here.
        %>

I'm sorry for the incomplete example.  I've read that you can mix-n-match
the languages in a non-ASP piece of code, but I don't have a ready example
of the syntax.

Like David wrote, check the ActiveState help for where my example falls
short.

Good luck!
    -Dwight



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

Date: Sat, 09 Sep 2000 12:26:58 +0100
From: David Dorward <ddorward@hotmail.com>
To: Shimon Bollinger <webmaster@wholefamily.com>
Subject: Re: What does "magic" mean?
Message-Id: <39BA1E82.DD0A8204@hotmail.com>

Shimon Bollinger wrote:
> 
> Several Perl features are described as "magical".  Is there a well defined
> technical meaning to "magical" or is it just a shortcut for "intuitive,
> though nonetheless surprising"?  I checked out PERGUTS but am unilluminated.

http://www.tuxedo.org/~esr/jargon/html/entry/magic.html

Relevent extract: "As yet unexplained, or too complicated to explain"

-- 
David Dorward
http://www.dorward.co.uk/


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

Date: Sat, 09 Sep 2000 12:14:55 GMT
From: Joe Johnston <jjohn@cs.umb.edu>
Subject: Re: what is the best way to get the lastest line from a file?
Message-Id: <39BA29BC.F2C1FE5B@cs.umb.edu>

Uri Guttman wrote:
> 
> File::ReadBackwards.pm

My bad. I'm sorry, Uri.

>   JJ> tail(1). I would choose tail(1) if it was most
>   JJ> convenient. I submit the code below for your
> 
> huh? it is much slower and not portable. how is that more convenient?

Not portable? True. But you, Uri, know I'm a *nix bigot. 
I've got tail(1) :-)
As for convenient:

my $last = `tail -1 blah`;

rolls off my keyboard like a four letter word. But, 
you have provided a more portable solution and that's
why I mentioned it first and (mis)pointed to it. 
 
> i am not amused by bad code like this. calling seek, read for each byte
> is horrendously slow. read the code for File::ReadBackwards.pm
> for a better and much faster way to actually do this. and it doesn't
> read the file char by char.

Horrendously slow? Perhaps. Perhaps not. How many bytes are we 
looking for? 80? 150?  We could grab larger chunks of text, looking 
for that elusive newline and then piece the desire line together. 

As for the charge of bad code, I'll warrant my code hasn't kick 
any small puppies, cheated any old ladies out of their social security 
checks nor even participated in mutli-level marketing schemes. There 
is some evidence that this code once was in a room full of ASP scripts, 
but I've adopted a "don't look, don't tell" policy. 

I bet you were *a little* amused after all. Or is that bemused? 
Oh well. I'll try harder next time.

Take care, Uri. 

-- 
----------------
Joe Johnston
http://aliensaliensaliens.com


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

Date: Sat, 09 Sep 2000 15:34:10 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: what is the best way to get the lastest line from a file?
Message-Id: <x7d7idinpr.fsf@home.sysarch.com>

>>>>> "JJ" == Joe Johnston <jjohn@cs.umb.edu> writes:

  JJ> my $last = `tail -1 blah`;

and what if that is a large log file which has to be completely
processed. then you just read it all into ram and that could be very bad
for your system. File::ReadBackwards is designed to be fast and
efficient. the solution in the perl cookbook does 2 passes of the file,
one forward to find the lines and one backwards doing seeks and
reads. my module only does one pass and reads in large chunks (8k) for
speed. i could have made it read 1 char at a time but that is
degenerate. :-)

  >> i am not amused by bad code like this. calling seek, read for each byte
  >> is horrendously slow. read the code for File::ReadBackwards.pm
  >> for a better and much faster way to actually do this. and it doesn't
  >> read the file char by char.

  JJ> Horrendously slow? Perhaps. Perhaps not. How many bytes are we 
  JJ> looking for? 80? 150?  We could grab larger chunks of text, looking 
  JJ> for that elusive newline and then piece the desire line together. 

i don't know how many lines a program might want to read backwards, so i
assumed the worst case of the whole file.

  JJ> As for the charge of bad code, I'll warrant my code hasn't kick
  JJ> any small puppies, cheated any old ladies out of their social
  JJ> security checks nor even participated in mutli-level marketing
  JJ> schemes. There is some evidence that this code once was in a room
  JJ> full of ASP scripts, but I've adopted a "don't look, don't tell"
  JJ> policy.

i will order the hell's grannies to tell you how to make money fast
and to punt your pooch. then i will sic the baby snatchers on you!
finally the gang of keep left signs will put you out of your misery.

  JJ> I bet you were *a little* amused after all. Or is that bemused? 
  JJ> Oh well. I'll try harder next time.

it brought back very bad memories of a perl program i rewrote which read
large files with getc (which is the absolute worst way to read data in
perl). my rewrite was over 60 times faster. i can't stand such a waste
of electrons.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sun, 10 Sep 2000 01:42:09 +0800
From: Carfield Yim <carfield@programmer.net>
Subject: Where can I find information of perl internationalization?
Message-Id: <39BA7671.9EBED773@programmer.net>

As title, I want to find information of using perl and perl regex to
doing some text formatting job with Chinese, where can I find
information of this?





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

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


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