[9099] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2717 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 25 19:07:31 1998

Date: Mon, 25 May 98 16:00:23 -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           Mon, 25 May 1998     Volume: 8 Number: 2717

Today's topics:
        Answer to over 500 FAQs rmorin@kbcafe.com
    Re: Clearly define "free software" <dak@mailhost.neuroinformatik.ruhr-uni-bochum.de>
    Re: Clearly define "free software" (le Fanttme)
    Re: Clearly define "free software" <arenn@urbanophile.com>
        Determining Opsys at runtime <fgrimes@hotmail.com>
    Re: Determining Opsys at runtime (Mike Stok)
    Re: get what is the RE causing matching (Mark-Jason Dominus)
    Re: get what is the RE causing matching <danboo@negia.net>
    Re: GPL documentation == unspeakable evil (Fergus Henderson)
        OPTIMIZATION TIP: tabs v.s. spaces (Steve McNabb)
    Re: Perl 5.005_xxx (I R A Aggie)
    Re: Perl 5.005_xxx <ljz@asfast.com>
    Re: Perl Win95 Question (Marek Jedlinski)
        Problem with Renaming a file to a new name that's speci <ahdiii@webspan.net>
        Q: How to recover html page(defined by URL)  using perl <kvanlier@club-internet.fr>
        random file names (was: Re: Randon files in Perl 5?) <rootbeer@teleport.com>
    Re: random file names (was: Re: Randon files in Perl 5? <hash@email.infotrade.co.uk>
        Splitting A Text Area <shaniarules@shaniarules.com>
    Re: What is wrong with this FileHandle code? (Marek Jedlinski)
    Re: What is wrong with this FileHandle code? <tchrist@mox.perl.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 25 May 1998 21:01:50 GMT
From: rmorin@kbcafe.com
Subject: Answer to over 500 FAQs
Message-Id: <6kcm7u$tqn$1@nnrp1.dejanews.com>

Remember, before posting you should check
The Programmer's Knowledge Base
http://tips.kbcafe.com/tips/

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 25 May 1998 21:20:11 +0200
From: David Kastrup <dak@mailhost.neuroinformatik.ruhr-uni-bochum.de>
Subject: Re: Clearly define "free software"
Message-Id: <m2ogwmuphw.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>

fantome/@/usa/./net (le Fanttme) writes:

> Yes, O Great And Wise Schilling. I Am SOOOOOO Sorry That I Have
> Transgressed Against Your Great Church Of So-Called Free Software.

Please don't confuse the solitary jester carrying "The end is near"
signs with the Church.


-- 
David Kastrup                                     Phone: +49-234-700-5570
Email: dak@neuroinformatik.ruhr-uni-bochum.de       Fax: +49-234-709-4209
Institut f|r Neuroinformatik, Universitdtsstr. 150, 44780 Bochum, Germany


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

Date: Mon, 25 May 1998 20:42:08 GMT
From: fantome/@/usa/./net (le Fanttme)
Subject: Re: Clearly define "free software"
Message-Id: <18FA4EF695BF72AA.F385882AC96D437E.40F582DF66416236@library-proxy.airnews.net>

On 25 May 1998 21:20:11 +0200, David Kastrup
<dak@mailhost.neuroinformatik.ruhr-uni-bochum.de> wrote:

>fantome/@/usa/./net (le Fanttme) writes:
>
>> Yes, O Great And Wise Schilling. I Am SOOOOOO Sorry That I Have
>> Transgressed Against Your Great Church Of So-Called Free Software.
>
>Please don't confuse the solitary jester carrying "The end is near"
>signs with the Church.

I don't. The leaders of the church are nutters themselves, but there
are a number of people who agree (mostly) with the thrust of the
Manifesto but also tend to be pragmatic about these things.

My problem with the GNUM and the GPL are that they don't take a
pragmatic approach to software and licensing.

We now have a commercially competitive open source operating system
(Linux). Where's the commercially competitive open source DBMS to
challenge Oracle and other DBMSes? Where's the commercially
competitive open source word processor to challenge WordPro, Word, and
WordPerfect?

I could go on, but I think that it's high time that the FSF recognize
that some level of pragmatism is near until (and unless) an end-to-end
system is viable. I haven't seen Lyx, yet, but I'm also not currently
running Linux -- because I have jobs that I have to get done and
cannot get done with the tools available on Linux.

I *do* want the GNU GPL to lose some of its teeth, at least with
respect to other open source licenses. Because I think in the long
run, those teeth are going to get long enough to come back and bite
the open source software communities.

-f
-- 
austin ziegler * fantome*@*vnet*.*net   * http://fantome.vnet.net/
---------------* aziegler*@*vcela*.*com * -------------------------
Remove the stars to email me            * Ni bhionn an rath ach
my words my opinions my ideas           * mar a mbionn an smacht
  -- I Argue Ideas, Not Beliefs: Give Up Your Dogma --


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

Date: Mon, 25 May 1998 17:36:32 -0500
From: "Aaron M. Renn" <arenn@urbanophile.com>
Subject: Re: Clearly define "free software"
Message-Id: <3569F270.B7E1B21C@urbanophile.com>

le Fanttme wrote:
> (Linux). Where's the commercially competitive open source DBMS to
> challenge Oracle and other DBMSes? Where's the commercially
> competitive open source word processor to challenge WordPro, Word, and
> WordPerfect?

Ten years ago you could have said "Where's the commercially competitive free
software product to challenge the proprietary compiler market".  Today we
have gcc.  Two years ago you could have said, "Where's the free software
product to challenge Photoshop?"  Today we have the GIMP.  Rome was not
built in a day.  Starting from nothing, it is going to take a while to build
a competitive free replacement for all proprietary products.

-- 
*****************************************************
* Aaron M. Renn                                     *
* Email: arenn@urbanophile.com                      *
* Homepage: <URL:http://www.urbanophile.com/arenn/> *
*****************************************************


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

Date: Mon, 25 May 1998 14:41:41 -0700
From: "Grimes" <fgrimes@hotmail.com>
Subject: Determining Opsys at runtime
Message-Id: <6kcol7$375$1@nntp1.ba.best.com>

What's the best way to determine if script is running on Windows or Unix at
runtime?  I suppose I could try to execute some platform-specific command
and test for failure or success.  Is there a better (standard) way?

Thanks...





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

Date: 25 May 1998 22:38:40 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Determining Opsys at runtime
Message-Id: <6kcrtg$2s@news-central.tiac.net>

You can check the value of $^O which on mu system contains the string
'linux', or you can get at more stuff via the Config module.

  perldoc perlvar

should describe $^O and 

  perldoc Config

should describe the Config module.

Hope this helps,

Mike

In article <6kcol7$375$1@nntp1.ba.best.com>,
Grimes <fgrimes@hotmail.com> wrote:
>What's the best way to determine if script is running on Windows or Unix at
>runtime?  I suppose I could try to execute some platform-specific command
>and test for failure or success.  Is there a better (standard) way?
>
>Thanks...
>
>
>


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 25 May 1998 15:23:51 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: get what is the RE causing matching
Message-Id: <6kcgg7$h8k$1@monet.op.net>
Keywords: Carboloy haul tablet taut


In article <3569585C.75D886B5@di.unipi.it>,
Antonio Gulli  <gulli@di.unipi.it> wrote:
>$REG_EXP is something like ---> REXP1|REXP2|REXP3| ....|REXPn
>
>Well what i need is tho know what kind of Regular Expression REXPi
>cause the while guard to be satisfyed. In perl simple $& gives me what
>is the part of string satisfyng $REG_EXP, instead.

I've sometimes done something like this:

	@REGEXPS = ('REXP1', 'REXP2', 'REXP3', ..., 'REXPn', );
	$REG_EXP = '(' . join(')|(', @REGEXPS), ')';

	if (@matches = ($string =~ /$REG_EXP/o)) {
	  my $i;
	  for ($i=0; $i < @matches; $i++) {
	    if (defined $matches[$i]) {
	      my $j = $i+1;
	      print "String `$string' matched pattern #$j (`$REGEXPS[$i]')\n";
	      last;
	    }
	  }
	}



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

Date: Mon, 25 May 1998 16:37:55 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: get what is the RE causing matching
Message-Id: <3569D6A3.D88A2818@negia.net>

Mark-Jason Dominus wrote:
> 
> In article <3569585C.75D886B5@di.unipi.it>,
> Antonio Gulli  <gulli@di.unipi.it> wrote:
> >$REG_EXP is something like ---> REXP1|REXP2|REXP3| ....|REXPn
> >
> >Well what i need is tho know what kind of Regular Expression REXPi
> >cause the while guard to be satisfyed. In perl simple $& gives me what
> >is the part of string satisfyng $REG_EXP, instead.
> 
> I've sometimes done something like this:
> 
>         @REGEXPS = ('REXP1', 'REXP2', 'REXP3', ..., 'REXPn', );
>         $REG_EXP = '(' . join(')|(', @REGEXPS), ')';
                                                ^
                                                this, of course,
                                                should be a dot
                                                for concatenation


-- 
Dan Boorstein   home: danboo@negia.net  work: danboo@y-dna.com

 "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
                         - Cosmic AC


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

Date: 25 May 1998 19:20:38 GMT
From: fjh@cs.mu.oz.au (Fergus Henderson)
Subject: Re: GPL documentation == unspeakable evil
Message-Id: <6kcga6$nbr$1@mulga.cs.mu.OZ.AU>

Birgitt Funk <ngouah@erols.com> writes:

>David Kastrup wrote:
>> 
>> Martin Schwartz <schwartz@cs.tu-berlin.de> writes:
>> 
>> > In my opinion the destiny of wide spread free software projects is, that
>> > they will be untied from the creators. 
>
>Why should that be ? Contrary I think if the major work of a project
>was done by one to three persons and the project is released at no-cost
>and with open source code, the authors deserve not only high respect for 
>what they are doing, but their authorship should always be respected.

Who said anything about not respecting their authorship?

>Since when are people denied the right of recognition if they donate
>huge chuncks of their work to the public ? 

Who said anything about denying them recognition?

When Martin Schwartz spoke about projects being "untied" from their
creators, that doesn't mean that the authors won't be recognized
and respected.  Open source doesn't mean that the authors won't
get the credit.  In fact, the open source community is generally quite
scrupulous about assigning credit.

But open source does mean that the software is not tied to its
original authors.  Anyone who wants to can come along and modify
the software, or even fork off new versions.  Forking off a new
version does not imply that you don't respect the authors work
or that you want to deny them recognition.

>> > I even think that for democratic
>> > reasons this has to be the case. 
>
>What is undemocratic about it ?

Well, it certainly seems to me to be more democratic for the
public to be able to choose whichever maintainer is doing
a better job.  Look at egcs vs gcc.  Judging by recent reports,
the C++-using public is voting with its feet in favour of egcs.

For projects which are available gratis but not open-source, e.g. if
the license only permits verbatim copying, and disallows modifications
by anyone other than the original author, then this choice would not be
available.

>Like being so democratic and social(istic)
>that we don't respect private ownership anymore ? You should know where
>this ends up, don't you ? 

Software is fundamentally different from ordinary goods and services
because it can be duplicated at basically no cost.  This means that
economic lessons about ordinary goods and services don't necessarily
apply to software.

But in any case, we're not talking about forcing people to release
their software as open source.  We are discussing (or at least I am)
the reasons why open source software is better for the public.

--
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3        |     -- the last words of T. S. Garp.


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

Date: 25 May 1998 19:44:58 GMT
From: smcnabb@interlog.com (Steve McNabb)
Subject: OPTIMIZATION TIP: tabs v.s. spaces
Message-Id: <6kchnq$ove$1@demon.uunet.ca>

Hi:

here is a really simple optimization trick.  I do most of my coding in a 
lovely little syntax-colouring editor called "ultraedit".  Depending on the 
stupidness of your editor, this tip may or may not apply to you.  *shrug* 

I was just polishing off a 700 line script to plop it into our production 
environment.  I thought I'd have a look at the command codes and see if I 
had any extraneous formatting characters bloating out the script.  When I 
turned the codes on (I usually leave 'em off for clarity), I found that I 
had alot of extra "spaces" in my script.  In lots of cases, there were a 
bunch of spaces standing in where a tab stop would have done the exact same 
thing.  So, I went through with the command codes on, and replaced all the 
extra spaces with tabs.  I also found that there were a bunch of spaces at 
the ends of lines (probably caused by my neurotic cut-and-paste from other 
progs ;-).  Now, even though these spaces really do nothing -- not even 
look nice, they do take up space in your script.  Just hack the useless 
spaces out completely, and use tabs for the rest.  1 tab is smaller than 8 
spaces (which ultraedit seems to occassionaly stick in -- even when you 
really wanted a tab!!)

Sooooo....to sum up:

1)  look at your script with the command codes turned on (in ultraedit, you 
select view/show tabs and spaces)

2)  hack out any extraneous spaces, and replace with tabs where req'd

3)  admire your much smaller script :-)

I got my 700-liner about 23% smaller with this technique. 

(before:  23,697 bytes  -- after:  18,309 bytes:  a diff of 5388 bytes)

Hooray!  
(now, of course, if I was using a _real_ editor like emacs or vi, this 
probably wouldn't be a problem ;-)
 

Enjoy!

steve

(p.s. -- I've enjoyed all the little tips being posted from time to 
time....keep them coming!!!)



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

Date: Mon, 25 May 1998 15:12:06 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl 5.005_xxx
Message-Id: <fl_aggie-2505981512060001@aggie.coaps.fsu.edu>

In article <lt90nrt8u6.fsf@asfast.com>, Lloyd Zusman <ljz@asfast.com> wrote:

+ fl_aggie@thepentagon.com (I R A Aggie) writes:

+ > I can just imagine what this newsgroup would be like should several newbies
+ > accidentally (or otherwise[*]) obtain a _beta TEST_ version. And having it
+ > puke on their machines. Oh, yeah, that's a Real Good Idea.

+ So, are you in favor of protecting "newbies" from themselves?  If so,
+ isn't that a bit paternalistic?

Yes, it is paternalistic. On the other hand, its a form of self-defense.
Do you _really_ want newbies running about with beta versions of perl?
For what reason? they've got enough on their plate - learning Perl as
it _is_ - that they don't really need to waste their time chasing
perl beta's around their machines...

Shoot, I'm reasonably well versed in perl, but even *I* don't want to
be chasing beta's around...

+ And isn't paternalism a totally backwards approach to take if you want
+ to encourage people to be self-motivated self-starters?

"Does a father hand his son a scorpion when the son asks for an egg?"

+ Yes, this indeed does look like a manhood ritual.  :)

Bingo, sir! All societies - paternal or maternal - have coming of age
events. After which, one is expected to behave like the adult they are.

+ > So, you allow people to drive your car even if they don't have driver's
+ > licenses? 
 
+ People can be seriously injured or killed if someone loses control of
+ an automobile. 

Which is why there are formal methods of obtaining licensing, and why
that license is required by law. Which is why there are informal methods
and unwritten laws regarding perl.

But I'll tell you this: motor vehicle operator licensing in this country
is a JOKE. Anyone who hasn't assumed Room Temperature, can see, and is
reasonably coordinated can become licensed.

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>


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

Date: 25 May 1998 16:50:28 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Perl 5.005_xxx
Message-Id: <ltd8d2qdm3.fsf@asfast.com>

fl_aggie@thepentagon.com (I R A Aggie) writes:

> In article <lt90nrt8u6.fsf@asfast.com>, Lloyd Zusman <ljz@asfast.com> wrote:
> 
> + fl_aggie@thepentagon.com (I R A Aggie) writes:
> 
> + > I can just imagine what this newsgroup would be like should several newbies
> + > accidentally (or otherwise[*]) obtain a _beta TEST_ version. And having it
> + > puke on their machines. Oh, yeah, that's a Real Good Idea.
> 
> + So, are you in favor of protecting "newbies" from themselves?  If so,
> + isn't that a bit paternalistic?
> 
> Yes, it is paternalistic. On the other hand, its a form of self-defense.
> Do you _really_ want newbies running about with beta versions of perl?
> For what reason? they've got enough on their plate - learning Perl as
> it _is_ - that they don't really need to waste their time chasing
> perl beta's around their machines...

But the person asking for the location of the Perl beta was almost
certainly not a "newbie".  He or she may very well have been *assumed*
to be one without any indication of this except perhaps through some
sort of sixth sense, but that doesn't make it so.

> Shoot, I'm reasonably well versed in perl, but even *I* don't want to
> be chasing beta's around...

Of course, that's your right and prerogative.  No one is asking you to
do this.

> + And isn't paternalism a totally backwards approach to take if you want
> + to encourage people to be self-motivated self-starters?
> 
> "Does a father hand his son a scorpion when the son asks for an egg?"

No. But when a very likely non-"newbie" asks for the location of a
Perl beta, what is the rationale for lumping that person in the same
category as "newbies" and being deliberately obtuse?

And where is the correlation between someone's ability to hunt down a
compressed archive on the net and his or her ability to deal with a
Perl beta?

> + Yes, this indeed does look like a manhood ritual.  :)
> 
> Bingo, sir! All societies - paternal or maternal - have coming of age
> events. After which, one is expected to behave like the adult they are.

??? Hunt down a Perl beta and you are now an adult?  Well, I have to
say that certainly do prefer this to a stone knife! :)

> + > So, you allow people to drive your car even if they don't have driver's
> + > licenses? 
>  
> + People can be seriously injured or killed if someone loses control of
> + an automobile. 
> 
> Which is why there are formal methods of obtaining licensing, and why
> that license is required by law. Which is why there are informal methods
> and unwritten laws regarding perl.

But the rest of my statement in that paragraph was snipped.  I'll repeat
my entire paragraph here:

> + People can be seriously injured or killed if someone loses control of
> + an automobile.  I suppose that there's an infinitessimal chance that
> + serious injury or death could also occur if someone messes up the
> + installation of a beta version of Perl, but I think that there many
> + other things that are much more likely to be harmful that we should be
> + concerned about.

In other words, I do not consider the risk of death or injury due from
the mis-use of a Perl beta to be significant enough to bother with,
and therefore, I don't think that it's appropriate to equate the
danger of this scenario with that of an unqualified person operating a
motor vehicle.

> But I'll tell you this: motor vehicle operator licensing in this country
> is a JOKE. Anyone who hasn't assumed Room Temperature, can see, and is
> reasonably coordinated can become licensed.

I agree with you here.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: Mon, 25 May 1998 18:47:45 GMT
From: cicho@polbox.com (Marek Jedlinski)
Subject: Re: Perl Win95 Question
Message-Id: <356b525d.1675370@news.nask.org.pl>
Keywords: If you're happy and you know it, clunk your chains.

sowmaster@juicepigs.com (Bob Trieger)  wrote:

>
>The easiest ways to do it is to just write a one line .bat file or make it 
>clickable with a shortcut to "perl yourscript.pl"

Yeah, but thanks to the immense stupidity of the shell, you then lose the
ability to redirect input/output.

"start script.pl" is ok, but no improvement over "perl script.pl" (in fact,
it's worse :) 

I've had the best luck with putting the script in a directory on the path
and using the -S switch:
	perl -S script.pl
This lets me avoid typing the full path to the script, which is a nuisance
if, say, the files that the script operates on are in a completely
different location (often deeply nested) than the script itself. Of course
one needs to watch for naming conflicts (i.e. don't have anything else
called "script.pl" earlier in the path).

 .marek


-- 
After things go from bad to worse, the cycle will repeat itself.
http://come.to/fnord/



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

Date: Mon, 25 May 1998 18:32:13 -0400
From: Arthur Dardia <ahdiii@webspan.net>
Subject: Problem with Renaming a file to a new name that's specified by a variable
Message-Id: <3569F16C.790181E0@webspan.net>

In my CGI problem, I have the following code:

rename "../htdocs/toast/matches/temp.html",
"../htdocs/toast/matches/'.$in{filename}.'";

Why doesn't that work?  I tried:

rename "../htdocs/toast/matches/temp.html",
'../htdocs/toast/matches/'.$in{filename}.'';

also, and neither statement works...please help me.

                    Severely stumped,
                    Arthur Dardia



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

Date: Mon, 25 May 1998 21:51:40 +0200
From: KRIS VAN LIER <kvanlier@club-internet.fr>
Subject: Q: How to recover html page(defined by URL)  using perl ?.
Message-Id: <3569CBCC.5495@club-internet.fr>

How can I copy a html page given an URL using perl.
Any reference to handle this would be appreciated.

Thanks in advance and if this is not the right newsgroup just ignore
this message.


Kris


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

Date: Mon, 25 May 1998 19:31:12 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: random file names (was: Re: Randon files in Perl 5?)
Message-Id: <Pine.GSO.3.96.980525120547.26181O-100000@user2.teleport.com>

On Mon, 25 May 1998, Alex Barilo wrote:

> I was always wondering is it safe enough to make random file name from
> memory address on HP-UX. For example like this
> ($FName = \$AnyVar) =~ s/\((.+)\)/$1/;

Well, that's a technique I hadn't seen before. Maybe you want something
more like this, though. 

    ($fname = \$any_var) =~ s/.*(0x[\dA-Fa-f]+).*/ hex $1 /e;

Still, you should be careful to use a different "any" variable each time. 
Probably not worth the bother. If you don't have a temp-name function on
your system, you could use something like this. 

    BEGIN {
	my $count = 0;
	my $base = "/tmp/mytemp.$$.$^T";
	sub temp_name { $count++; "$base.$count"; }
    }

Of course, there's no guarantee that you won't have a filename collision
this way, but it's pretty unlikely. Hope this helps! 

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



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

Date: Mon, 25 May 1998 22:11:54 +0100
From: "Alex Barilo" <hash@email.infotrade.co.uk>
Subject: Re: random file names (was: Re: Randon files in Perl 5?)
Message-Id: <6kcgrc$p6l@news3.force9.net>


Tom Phoenix wrote in message ...
>    BEGIN {
> my $count = 0;
> my $base = "/tmp/mytemp.$$.$^T";
> sub temp_name { $count++; "$base.$count"; }
>    }
>
>Of course, there's no guarantee that you won't have a filename collision
>this way, but it's pretty unlikely. Hope this helps!


Yes, this is highly likely if I have several copies of my script running.
That can not happen to memory addresses. But it doesn't apply to Intel
architechture where I can have the same offset in diferent paragraphs.

Cheers,

Alex.







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

Date: Mon, 25 May 1998 16:21:28 -0700
From: David Stinemetze <shaniarules@shaniarules.com>
Subject: Splitting A Text Area
Message-Id: <3569FCF7.3EE10866@shaniarules.com>

How do you split a text area to get differnt variables

--
<CENTER>
<TABLE BORDER=10 BORDERCOLOR=DARKBLUE BGCOLOR=SILVER>
<TR><TD>David Stinemetze</TD></TR>
<TR><TD>shaniarules@shaniarules.com</TD></TR>
<TR><TD>http://www.shaniarules.com</TD></TR>
<TR><TD>ICQ# 3704650</TD></TR>
</TABLE>




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

Date: Mon, 25 May 1998 18:47:53 GMT
From: cicho@polbox.com (Marek Jedlinski)
Subject: Re: What is wrong with this FileHandle code?
Message-Id: <356c543e.2156961@news.nask.org.pl>
Keywords: If you're happy and you know it, clunk your chains.

Martin Gregory <mgregory@asc.sps.mot.com>  wrote:

>Tom Christiansen <tchrist@mox.perl.com> writes:
>
>>  [courtesy cc of this posting sent to cited author via email]
>> 
>> In comp.lang.perl.misc, Martin Gregory <mgregory@asc.sps.mot.com> writes:
>> :You have yet to quantify this claim, nor explain why it is true.  
>> 
>> It seems subclever to suck in nearly 5,000 lines of code and 
>> seventeen files merely to say:
>> 
>>     $fh = FileHandle->new();
>>     open($fh, "< $path");
>> 
>> instead of 
>> 
>>     open(FH, "< $path");

As long as things work, never check dependencies: therein lies peace of
mind :)


>Eryq made the point that the most efficient low-level way of doing
>things is not necessarily the best way.
>
>Further more, who really cares how long (within reason) it takes to
>load?  What one generally cares about is how fast the ongoing IO
>operations are.
>
>But even more to the point, it is only "subclever" _if_ you could be
>expected to know about the inefficiencies.  "FileHandle" is included
>with perl.  There are no warnings to the effect that it is a
>inefficient implementation.  Indeed, there are numerous suggestions
>that it is the way to go.  

Perl FAQ a prominent one among them. ("How can I make a filehandle local to
a subroutine?") 

In fact, I just learned this bit yesterday when I needed a recursive sub
that creates a new file and (sometimes) needs to call itself to create
another one (where nesting may be almost arbitrarily deep). If I noticed my
script slowing to a crawl (I wasn't using recursion before, hence no
FileHandle) I assumed it was my own inefficient regex coding, which it
probably is, too :)

>If a person had not read this thread, and
>continued to use FileHandle, would that make them "subclever"?

Okay, can I have a recursive file-creation routine *without* using
FileHandle and friends? Or a meta question: why aren't file handles treated
as "normal" variables in Perl, so one could do
	my FH
and things would work as expected? ("why arent" is not a complaint, mind,
it's a curious question out of ignorance :)

 .marek


-- 
After things go from bad to worse, the cycle will repeat itself.
http://come.to/fnord/


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

Date: 25 May 1998 20:38:24 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: What is wrong with this FileHandle code?
Message-Id: <6kcks0$a0u$1@csnews.cs.colorado.edu>
Keywords: If you're happy and you know it, clunk your chains.

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

In comp.lang.perl.misc, 
    cicho@polbox.com (Marek Jedlinski) writes:
:Okay, can I have a recursive file-creation routine *without* using
:FileHandle and friends? 

Of course.  See below.

:Or a meta question: why aren't file handles treated
:as "normal" variables in Perl, so one could do
:	my FH
:and things would work as expected? ("why arent" is not a complaint, mind,
:it's a curious question out of ignorance :)

Because they aren't.  They're symbols.  Saying my FH would
simple mean local *FH, essentially.  My isn't in the symbol 
table.  Just learn how filehandles work and use them.  
Pretty Please.

--tom

#!/usr/local/bin/perl

die "usage: $0 [-I path] pattern file ...\n" unless @ARGV > 1;

@ipath = ( '.', '/usr/include', '/sys/h');

while ($ARGV[0] =~ /^-I(.*)/) {
    shift;
    push(@ipath, $1 || shift);
} 

$pattern = shift;
eval "/$pattern/";  # test her
die "$0: $@" if $@ =~ s/ at \(eval\).*//;

for (@ARGV) { &process($_); } 

exit (!$ok);

sub process {
    local($fname) = @_;
    local(*FH);

    return if $seen{$fname};

    unless ($fname =~ m#^/# ? open(FH, $fname) : &iopen(FH, $fname)) {
	warn "can't open $fname: $! called from "
		. join(" from ", reverse @in) . "\n";
	$seen{$fname}++; # sigh
	return;
    }

    push(@in, $fname);
    unless($seen{$fname}++) {
	while (<FH>) {
	    #print "$fname: $.: $_" if /$pattern/o;
	    print join(" from ", reverse @in), ": $.: $_"
		if /$pattern/o;
	    $ok++;
	    next unless /^\s*#\s*include\s*(["<])([^">]+)[">]/; 
	    &process($2);
	} 
    }
    pop @in;
    close(FH);
} 

sub iopen {
    local($fh, $path) = @_;
    local($mypath) = $in[$#in]; # cpp extra inc path

    $mypath = '' unless $mypath =~ s#/[^/]*$##;
    for $dir ($mypath, @ipath) {
	next if $dir eq '';
	next unless open ($fh, "$dir/$path");
	$_[1] = "$dir/$path"; # clobber caller ref for better msgs
	return 1;
    } 
    return 0;
} 
-- 
You have to admit that it's difficult to misplace the Perl sources.  :-)
		--Larry Wall in <1992Aug26.184221.29627@netlabs.com>


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

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

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