[8918] in Perl-Users-Digest
Perl-Users Digest, Issue: 2535 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 7 20:07:57 1998
Date: Thu, 7 May 98 17:00:33 -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 Thu, 7 May 1998 Volume: 8 Number: 2535
Today's topics:
'die' outside eval returns 0 <jstern@world.northgrum.com>
Re: ANSI Colour in Perl <Rosie@dozyrosy.demon.co.uk>
Re: COUNTING DAYS UNTIL 2000 <upsetter@shore.net>
Re: CPAN & Module gripes (was Re: Ever Wonder...?) (Stuart McDow)
Re: CPAN Suggestions (conciliatory) (Stuart McDow)
Re: Directory usage in Perl for win32 (Martien Verbruggen)
Re: Does anybody understand $File::Find::prune ?? <rpsavage@ozemail.com.au>
Re: Ever Wonder Why Not Everyone Uses Modules? <jsd@gamespot.com>
Re: Ever Wonder Why Not Everyone Uses Modules? (Craig Berry)
Re: Help Please: How Do I Test A String (Hakan Hjelmstrom)
How do I return arrays by value from a function? (George Lembersky)
Re: How do I return arrays by value from a function? (Hakan Hjelmstrom)
Question: Is Perl an acronym? evangelo@dnai.com
Re: Question: Is Perl an acronym? <btate@primary.net>
regular expression assistance <7twh@ttc-cmc.net>
Re: regular expression assistance (brian d foy)
Re: regular expression assistance <quentin@shaddam.amd.com>
Setting Environment Variables <laura.morgan@itron.com>
Re: stat function (Martien Verbruggen)
Re: Symbolic References <tchrist@mox.perl.com>
Tip: Ignoring Return Values <gnat@frii.com>
Re: Unable to use CPAN.pm through firewall (Clinton Pierce)
Re: Where can I download Perl interpreter? (Hakan Hjelmstrom)
Re: WIN32 tee command (Steven Wayne)
Re: WIN32 tee command <gburnore@netcom.com>
Re: WIN32 tee command (Craig Berry)
Re: WIN32 tee command (Craig Berry)
Re: win32, cgi run from dos (Hakan Hjelmstrom)
Windows 95 Problem <bobras@erols.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 7 May 1998 21:58:16 GMT
From: "James M. Stern" <jstern@world.northgrum.com>
Subject: 'die' outside eval returns 0
Message-Id: <35522E78.D130A9D1@world.northgrum.com>
This program:
<snip>
#!/usr/local/bin/perl -w
use strict;
print system('perl -we \'$! = 0; $? = 1 << 8; die "failed"'), "\n";
</snip>
prints
<snip>
failed at -e line 1.
0
</snip>
The last line is the exit code. However, my (mis?)reading of the
perldoc entry for 'die' says that 'die' exits as follows, in effect:
exit($! || ($? >> 8) || 255);
Thus the 'die' exit code can never be 0.
My configuration is:
% perl -v
This is perl, version 5.004_04 built for aix
% oslevel
4.1.4.0
--
James M. Stern -- Views here are my own, not my employer's.
(Hawthorne, CA)
------------------------------
Date: Thu, 7 May 1998 23:54:22 +0100
From: Rosemary I H Powell <Rosie@dozyrosy.demon.co.uk>
Subject: Re: ANSI Colour in Perl
Message-Id: <0w$aUuAeujU1Ew4Y@dozyrosy.demon.co.uk>
In article <m3ra29oa92.fsf@windlord.Stanford.EDU>, Russ Allbery
<rra@stanford.edu> writes
>John Porter <jdporter@min.net> writes:
>
>> wadr, the correct spelling is the one which finds the package, if you're
>> doing a text-based search. 'color' finds it, 'colour' does not.
>
>I'll see about fixing this. :)
>
Thank you!!
Rosemary
who will carry on being a Just Another Micr$oft Idiot if it get things
done:-)
-------------------------------------------------------------------
| Rosemary I.H.Powell EMail: Home: rosemary@dozyrosy.demon.co.uk |
| Work: r.i.h.powell@rl.ac.uk |
| http://www.netlink.co.uk/users/dozyrosy/ |
| http://www.dozyrosy.demon.co.uk/ |
-------------------------------------------------------------------
------------------------------
Date: 7 May 1998 23:10:09 GMT
From: Art Cohen <upsetter@shore.net>
Subject: Re: COUNTING DAYS UNTIL 2000
Message-Id: <6itf0h$8vf@fridge.shore.net>
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
:> Well, I hate to say it in this group, but the much reviled Matt's
:> script archives has a general countdown script, which will work for
:> any given date.
: Nice for Matt, but CPAN has Date::Manip, which also can do it, can do
: lots more, and probably is a bit more robust.
Yuk. Date::Manip is a huge piece of code, just a little too "robust" (imo)
than needed for a simple application like this. (Especially if it's going
to be part of a web page, where the time to load Date::Manip would
seriously affect download time).
I'd probably Time::Local (or even timelocal.pl), but that's just me.
--Art
National Ska/Reggae Calendar: www.ziplink.net/~upsetter/ska/calendar.html
Boston Ska Home Page: www.ziplink.net/~upsetter/ska/index.html
------------------------------
Date: 7 May 1998 22:39:53 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: CPAN & Module gripes (was Re: Ever Wonder...?)
Message-Id: <6itd7p$e88$1@ns1.arlut.utexas.edu>
cpierce1@ford.com (Clinton Pierce) writes:
>
> 1. dependencies list, available from CPAN, that is accurate,
> greppable and (preferably) does not rely on the module author
> keeping an accurate description file and (while we're wishing)
IMO, the dependency list should also include tools require to build
the module (specific versions of make, compilers, preprocessors, etc)
as well module dependencies. I also believe the dependency list should
be part of the module itself, a la Solaris packages. A new or modified
ExtUtils module would be required to deal with this new
information. I'd start some sort of specification, but I haven't
thought about it very much and I'm way way low on tuits.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"Look for beauty in roughness, unpolishedness"
------------------------------
Date: 7 May 1998 22:50:08 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: CPAN Suggestions (conciliatory)
Message-Id: <6itdr0$fo0$1@ns1.arlut.utexas.edu>
cpierce1@cp500.fsic.ford.com (Clinton Pierce) writes:
>
> I'll open with something simple: can the modules be extracted/parsed/
> folded/spindled in some automagic way to extract dependency information?
> Possibly looking for things like:
I just posted this in another thread, but it's more appropriate in
this one. So, here goes,
IMO, the dependency list should also include tools required to build
the module (specific versions of make, compilers, preprocessors, etc)
as well module dependencies. I also believe the dependency list should
be part of the module itself, a la Solaris packages. A new or modified
ExtUtils module would be required to deal with this new
information. I'd start some sort of specification, but I haven't
thought about it very much and I'm way way low on tuits.
I posted a similar idea in yet another thread somewhere about a
theoretical Depend.PL file as part of the module distribution and a
theoretical ExtUtils::Dependencies module to deal with that file. I
also proposed that this could all be rolled up into the Makefile.PL
file (maybe) so that only one pass (as opposed to one for dependency
checking and one for Makefile building) would be needed.
Thoughts?
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"Look for beauty in roughness, unpolishedness"
------------------------------
Date: 7 May 1998 22:51:29 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Directory usage in Perl for win32
Message-Id: <6itdth$n8f$1@comdyn.comdyn.com.au>
[Please, next time, if you send a courtesy copy to a poster, state so
in your message. Most people read their email first, and won't realise
that all they got is a copy, not really private communication. They'll
answer there, while the discussion relaly belongs here]
In article <35516E7E.3F39B2F4@selectst.com>,
David Coldrick <davidc@selectst.com> writes:
>
>
> Martien Verbruggen wrote:
>
>> In article <354E72F7.9B719F19@selectst.com>,
>> David Coldrick <davidc@selectst.com> writes:
>> > my $pathsep = "\\";
>>
>> Why not just '/'?
>>
>
> Um, because the path separator on Windows NT is '\' - to be honest, I'm
> often confused as to when I have to add another backwhack, even with single
> quotes, so I err on the side of caution. Sloppy, but I'll probably get over
> it.
Actually, it isn't :). The NT kernel (as well as the DOS kernel) have
never had any problem at all with / as a path separator. The DOS and
NT _shells_ on the other hand do have a problem with that. But within
perl and C programs, you can safely use / (as long as you don't call
external programs with exec or system)
>> > foreach $f (@files) {
>> > next if ($f eq '.' or $f eq '..'); # ignore the DOS weirdness
>>
>> Weirdness? DOS?
>
> Yeah, tell me about it. What's really cute is that the version I was using
> when I wrote this (ActiveState/Ware), found the '.' and '..' to be
> directories, and the recursion on them went infinite. I haven't tried the GS
> port to see what happens there.
Oh, you meant . and ..? They are part of many OS's idea of a
directory. I do seem to remember that DOS is 'special' in the way that
the root directory of every drive doesn't have a ., even though it
should. If you want to ignore current and parent directory pointers
(which . and .. are) then you should do that on most platforms :)
Nothing DOS specific about it. That was where I got confused.
Of course, in a recursive routine, you will most definitely not want
to follow them. The GS port would do the same. If you would pass the
'.' directory (current) into a recursive routine, it would just repeat
what it just did, and keep on repeating.
>> And it really doesn't answer the original question, does it?
>
> Blush. Sure nuff. I realised that after I posted it, but thought the code
> was clear enough to be easily changed to do what the original poster wanted
>:-)
hehe, maybe :) I don't know the original poster's ability to do that.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd. | clothes.
NSW, Australia |
------------------------------
Date: Fri, 08 May 1998 09:36:51 +1100
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: Does anybody understand $File::Find::prune ??
Message-Id: <35523783.4C90@ozemail.com.au>
Les Woolsey wrote:
>
> I'm doing using File::Find and calling the find function to scan all the
> files in a directory. I don't want to go below the current directory level
> so inside the "wanted" routine I'm setting $File:Find:prune=1;
>
> On NT under 5.003_07 this works just fine.
>
> But under 5.004_04 under AIX I get entirely different results. I have to
> wait until I get passed a directory that is below the current one, then set
> prune=1 as above. If I set it sooner, (ie on the current directory), I
> don't get the files in this directory.
>
> Either the functionality of this code has changed between revisions of Perl
> or it's a variation in the operating systems. Does anybody know which?
>
> Les
I think you'll find that File::Find doesn't call your wanted() if there are no
files in the directory. Perhaps this is relevant.
On my web site you'll find File::FindAll.pm, which always calls wanted()...
--
Cheers,
Ron Savage
Office: savage.ron.rs@bhp.com.au
Home (preferred): rpsavage@ozemail.com.au
Web: http://www.ozemail.com.au/~rpsavage
------------------------------
Date: Thu, 07 May 1998 15:10:37 -0700
From: Jon Drukman <jsd@gamespot.com>
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <3552315D.2732A64A@gamespot.com>
Brett Tabke wrote:
> That appears to be the main difference of opinion, I'd rather Perl
> remain a programmers language instead of a users language.
it's a floor wax AND a dessert topping!
> If it is
> a programmers language, it can inspire people beyond the simple
> weekend writting a script built around modules, into learning about
> the systems underneath.
yeah but not everybody wants to do that, or cares. maybe someone just
wants to grab a web page. hey, it happens. i don't see why an exchange
like "hey i want to get a web page" "use HTML::Parser" is going to
inevitably lead to the death of perl as "a programmer's language". (i
also don't really see the distinction... as i said above, i believe it
can comfortably fill both roles.)
> If it is to be a users language, then it is headed in the direction
> of a csh with bells and that any actually programming is being
> deffered in favor of glueing stuff together. It will become nothing
> more than a batch/submit/exec/shell script language. If that is the
> case, then I've compeletly misread Perl, I thought it was a hackers
> language about ingenuity and creativity.
i think it is what you make it. perl, to me, is not about ingenuity and
creativity so much as getting stuff done quickly and elegantly so i have
more time to play videogames when i get home. :)
the fact that "gluing stuff together" is a large part of perl's life is
only due to how well it does it. sure you can do cgi stuff that
communicates with a database in C... but it takes a LOT more work than
using perl with CGI.pm and DBI.pm. if you want to work harder, go nuts!
> I seem to recall a little thing referred to as black thursday in 87
> (er was it 88?) which in large part, was due to folks using a
> "perfectly working" finger routine that no one bothered to rewrite
> because it worked so good. Much the same is with module - who would
> consider redoing lww these days? All the net eggs are in that basket.
obviously it wasn't perfectly working at that point. do you have a
particular problem with LWP? if so, why not fix it, or at the very
least, report it as a bug to Gisle. i found what i perceived as a
deficiency with it, reported it to him, and was politely informed that
it was a design decision.
> To a degree, yes I was leaning that way pretty far, but look at how
> many folks (from reading the modules group) use the lww set - hasn't
> it all but killed any new development in net routine writing? As
> you said yourself, why rewrite a prefectly working module.
well, you can't have it both ways. if the module works, why would
anyone with real work to do rewrite it? to create an incompatible,
competing standard? i mean, i can envision a slimmed-down lwp, maybe,
for those people who can't afford the load time/bloat of the full
package, but when i'm in the situation where lwp's size & (lack of)
speed are hampering development, i'll do something about it.
> >Plan: Eat right, exercise regularly, die anyway.
>
> hehe.
>
> -bt
>
> --
> -- Brett Tabke (phdss at writeme.com) www.netins.net/showcase/phdss/
> ..."In '69 a couple of guys walked around on the moon, but more
> important to the future of humanity, UNIX was invented" (c.bruce)
--
Jon Drukman jsd@gamespot.com
-----------------------------------------------------------------------
Plan: Eat right, exercise regularly, die anyway.
------------------------------
Date: 7 May 1998 23:29:29 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <6itg4p$o79$1@marina.cinenet.net>
Zenin (zenin@archive.rhps.org) wrote:
: CPAN.pm is good, CPAN is good, and even the search engines for
: CPAN are good. It's the layout and navigation that I think has
: the biggest problems.
Thanks, I've been trying to phrase it that concisely for three days
without notable success. :)
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Thu, 07 May 1998 22:21:28 GMT
From: hawk@algonet.se (Hakan Hjelmstrom)
Subject: Re: Help Please: How Do I Test A String
Message-Id: <35522164.3970539@news.algonet.se>
On Thu, 07 May 1998 15:21:10 -0400, Frank Blanchard wrote:
> i want to test a string to see if it contains any characters other
> than spaces.
> i tried ne "" and ne " " and some other iterations.
> can it be done? thanks in advance.
Look up "Regular Expressions" in the docs. Abbr. perlre.
Hekan Hjelmstrvm
hawk@algonet.se
------------------------------
Date: 7 May 1998 22:37:10 GMT
From: lemb9881@cims.nyu.edu (George Lembersky)
Subject: How do I return arrays by value from a function?
Message-Id: <6itd2n$5pb$1@news.nyu.edu>
I know that this must be a common question, but does anyone know how to return from a function by value? To make my question
more clear, here's a snippet of code that doesn't work because I am returning references to arrays that get wiped out after
the function exits.
#!/usr/local/bin/perl
sub pass2nums
{
my @letters1=("one1", "two1", "three1");
my @letters2=("one2", "two2", "three2");
return (\@letters1, \@letters2);
}
my @letters1=("a1", "b1", "c1");
my @letters2=("a2", "b2", "c2");
(\@nums1, \@nums2) = &pass2nums();
print "nums1=@nums1, nums2=@nums2\n";
print "letters1=@letters1, letters2=@letters2\n";
Does anyone know of a way to return more than one local array from a function?
- George
george@nickmail.com
------------------------------
Date: Thu, 07 May 1998 23:09:56 GMT
From: hawk@algonet.se (Hakan Hjelmstrom)
Subject: Re: How do I return arrays by value from a function?
Message-Id: <35553d50.11118978@news.algonet.se>
On 7 May 1998 22:37:10 GMT, George Lembersky wrote:
> I know that this must be a common question, but does anyone
> know how to return from a function by value? To make my question
> more clear, here's a snippet of code that doesn't work because
> I am returning references to arrays that get wiped out after
> the function exits.
> #!/usr/local/bin/perl
> sub pass2nums
> {
> my @letters1=("one1", "two1", "three1");
> my @letters2=("one2", "two2", "three2");
> return (\@letters1, \@letters2);
> }
>
> my @letters1=("a1", "b1", "c1");
> my @letters2=("a2", "b2", "c2");
>
> (\@nums1, \@nums2) = &pass2nums();
>
> print "nums1=@nums1, nums2=@nums2\n";
> print "letters1=@letters1, letters2=@letters2\n";
> Does anyone know of a way to return more than one local array from a function?
Ouch, said my interpreter when run using -w and "use strict;".
It spat on the line stating:
(\@nums1, \@nums2) = &pass2nums();
The refs being returned are scalars so you should use a scalar to hold
the refs and dereference them later on. Like this:
#!/usr/bin/perl -w
use strict;
sub pass2nums
{
my @letters1=("one1", "two1", "three1");
my @letters2=("one2", "two2", "three2");
return (\@letters1, \@letters2);
}
my @letters1=("a1", "b1", "c1");
my @letters2=("a2", "b2", "c2");
my ($nums1, $nums2) = &pass2nums();
print "nums1=@$nums1, nums2=@$nums2\n";
print "letters1=@letters1, letters2=@letters2\n";
Pay attention to the dereferencing taking place in the first print
statement. To dereference a hash ref you'd swap the @ for % etc.
Take a look at perlref and have fun.
Hekan Hjelmstrvm
hawk@algonet.se
------------------------------
Date: Thu, 07 May 1998 22:48:11 GMT
From: evangelo@dnai.com
Subject: Question: Is Perl an acronym?
Message-Id: <6itdnb$4k2$1@nnrp1.dejanews.com>
OK, so everybody's got serious programming issues they're trying to deal
with, but *I've* got a frivolous and nit-picking question which is extremely
.misc, so listen to me!
I recently corrected a friend on his misspelling of PERL. "Use perl or Perl
instead, my friend," I said politely. "Perl is not an acronym."
"Wrong!" said another, rather argumentative friend. "It stands for Practical
Extraction and Reporting Language."
"Well, yeah, kinda. But not really. I think Practical Extraction and
Reporting Language was kind of a reverse-acronymization (bathynym?), in a
humorous vein, based on the fact that many cryptic names of UNIX tools are
acronyms or abbreviations."
My friend was unrelenting, though. "Look here in the Camel Book!" he
exclaimed, pointing to the section on the origins of perl. "Faigan says that
the name was originally 'pearl', shortened to 'perl'. And that you can see
traces of that original name in the ACRONYM'S GLOSS, 'Practical Extraction
_A_nd Reporting Language'. See, it _is_ an acronym!"
Oh, Brother, I thought. "Listen, a 'gloss' is an intentionally misleading
interpretation. Anyways, don't you think that 'Practical dah dah dah' is
kind of a cumbersome name to begin with? Doesn't it just make more sense
that 'perl' came first, then 'Practical'?"
But he had a good comeback ready. "Well, perl was first used _for_
extraction and reporting. And it _is_ practical. So why not? People
_frequently_ develop an acronym and what it stands for in parallel."
So, it comes down to this: Is 'perl' an acronym? Were the name "perl" and
the term "Practical Extraction and Reporting Language" developed together, or
did one come before the other?
~ESP
P.S. Comments to the effect that I have too much time on my hands and should
get back to updating the Windows FAQ will be cheerfully ignored.
--
#! perl
@a = ( 0x2E805,0x6B39,0x15B3,0x45993,0x153C,0x1D9F );
for ( @a ) { ( $s, $i )=( 'a', 0 ); $s++ while $i++ < $_; print $s }
__END__
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 7 May 1998 18:45:50 -0500
From: "Bob Tate" <btate@primary.net>
Subject: Re: Question: Is Perl an acronym?
Message-Id: <355247db.0@news.primary.net>
Better listen to your friend on this one.
------------------------------
Date: Thu, 07 May 1998 16:05:14 -0600
From: Tim Hodges <7twh@ttc-cmc.net>
Subject: regular expression assistance
Message-Id: <3552301A.5E032DB5@ttc-cmc.net>
I need to form a regular expression that matches either of these:
> ba6c32h
< djaycc7
That is, either a greater than or less than symbol, followed by a
space and then an alphanumeric string with lowercase letters.
So.. you regex experts give me a hand??
Tim Hodges
7twh@ttc-cmc.net
------------------------------
Date: Thu, 07 May 1998 18:40:09 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: regular expression assistance
Message-Id: <comdog-ya02408000R0705981840090001@news.panix.com>
Keywords: from just another new york perl hacker
In article <3552301A.5E032DB5@ttc-cmc.net>, Tim Hodges <7twh@ttc-cmc.net> posted:
>I need to form a regular expression that matches either of these:
>
>> ba6c32h
>< djaycc7
>
>That is, either a greater than or less than symbol, followed by a
>space and then an alphanumeric string with lowercase letters.
#!/usr/bin/perl -w
use strict;
my @array = ('> ba6c32h', '< djaycc7', 'blahfoo');
foreach my $string ( @array )
{
print "[$string] matched!\n"
if $string =~
m/
[><] #either < or >
\ #there's a space after that slash
[a-z0-9]+ #some lowercase letters or some numbers
/x; # eXtended format
}
__END__
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: 07 May 1998 18:07:27 -0500
From: Quentin Fennessy <quentin@shaddam.amd.com>
Subject: Re: regular expression assistance
Message-Id: <ximwwbxissw.fsf@shaddam.amd.com>
>>>>> "Tim" == Tim Hodges <7twh@ttc-cmc.net> writes:
Tim> I need to form a regular expression that matches either of
Tim> these:
Tim> > ba6c32h
Tim> < djaycc7
Tim> That is, either a greater than or less than symbol, followed
Tim> by a space and then an alphanumeric string with lowercase
Tim> letters.
/^[<>] \w+$/
more precisely (perhaps too precise for your example):
/^[<>] \w{7}$/
Of course you did not say this was the entire line -- if it is not
then the ^ and $ would be wrong.
--
Quentin Fennessy AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals
------------------------------
Date: Thu, 07 May 1998 16:06:24 -0700
From: Laura Morgan <laura.morgan@itron.com>
Subject: Setting Environment Variables
Message-Id: <35523E70.6DEC@itron.com>
Is there a way to set environment variables from within a Perl script so
that once I've exited Perl, I can do a "set" and see the environment
variable that I've set? I can't seem to figure out how to do this. I
need something that will work on NT and UNIX (Korn Shell).
Thank you!
------------------------------
Date: 7 May 1998 23:05:44 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: stat function
Message-Id: <6iteo8$nap$1@comdyn.comdyn.com.au>
[ Please, when you send a courtesy copy to the poster, state so in your
message. Most people read their email before Usenet, and will not
realise that they don't have a private piece of email, but merely a
copy of a post. They will most likely answer the email, while they
really should, and probably wanted to answer to the post. ]
In article <35519764.0@tmsserv4.tmsnet.co.uk>,
"Mark Austin" <mark@tmsnet.co.uk> writes:
> Here is the code i'm using
>
> while ($FileName = readdir(dir))
> {
>
>
> if ($FileName cmp "." && $FileName cmp "..")
Have you read what cmp does?
# perldoc perlop
[snip]
Binary "cmp" returns -1, 0, or 1 depending on whether the
left argument is stringwise less than, equal to, or greater
than the right argument.
[snip]
You probably want to use ne
# perldoc perlop
[snip]
Binary "ne" returns true if the left argument is stringwise
not equal to the right argument.
[snip]
But you probably should also read
# perldoc readdir
It has an example that makes this slightly easier (with a bit of
adaptation.
my @files = grep{ ! /^\.\.?$/ } readdir(DIR);
foreach (@files)
{
}
Of course, now you also are looking at all the directories and special
files, which you probably don't want.
This is where the -X file tests come in:
# perldoc -f -X
opendir(DIR, $some_dir) or die "Cannot open $some_dir: $!";
my @files = grep{ ! /^\.\.?$/ && -f "$some_dir/$_" } readdir(DIR);
closedir(DIR);
foreach (@files)
{
# Do what you need to do here
}
If you do what the directories as well, move the file test inside the
loop.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I'm desperately trying to figure out
Commercial Dynamics Pty. Ltd. | why kamikaze pilots wore helmets - Dave
NSW, Australia | Edison
------------------------------
Date: 7 May 1998 21:57:03 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Symbolic References
Message-Id: <6itanf$dhn$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Ala Qumsieh <aqumsieh@matrox.com> writes:
:For some reason, I can't get symbolic references to do what I want!
They are the spawn of the devil. Get them behind thee!
:I might be doing something wrong, please help me!
You are.
:my ($temp, @tt);
:my @temp = ("red", "black", "white");
:$temp = "temp";
:@tt = @$temp; <-- doesn't work .. neither does @tt = @{$temp};
Of course not. Symbolic references refer to the symbol table -- hence
their name. Lexical variables live in no package symbol table.
They are beyond the reach of symbolic referencing. You can't play
around with package symbol tables table to get them.
This is the same problem as the person who thought this would work:
package main;
my $lfile;
package other;
*his = \$main::lfile;
Somehow confusing symbol-table variables with lexical-scoped ones,
just as you have.
I know it's my own fault for not having explained this well enough
in the documentation.
--tom
--
I hope to get Perl 5 out this summer, for certain values of summer.
-- <1993Jun5.052825.3897@netlabs.com>
------------------------------
Date: 07 May 1998 16:26:48 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Tip: Ignoring Return Values
Message-Id: <5qsomlemzb.fsf@prometheus.frii.com>
Here's my contribution to raising the signal:noise ratio.
I've spent the last year writing, with Tom Christiansen, "The Perl
Cookbook" (it's in the final stretches before it goes off to O'Reilly
for production and printing, Praise Allah And His Omnipotent Pixies).
I can't believe how much I've learned. I used to think I knew my way
around Perl, but Tom showed me hundreds of things I didn't know Perl
could do.
Being a generous kind of guy, I figure I'll share some with you. The
tips will all be in the cookbook (writing it is how I learned 'em,
after all) but I'll post some here in a more compact form to share the
wealth with the world.
The first tip is how to get at only part of a returned list of values.
This comes in two varieties: assigning to undef and taking a hash
slice.
(undef, $password, undef, undef) = getgrnam("wheel");
We can use the way Perl ignores extra values from the right hand side
of an assignment to make this shorter:
(undef, $password) = getgrnam("wheel");
Or we could take a slice into it and do away with the list assignment
altogether:
$password = ( getgrnam "wheel" )[1];
When taking a slice like this, it's in your best interests to reduce
the number of parentheses. I could have said:
$password = (getgrnam("wheel"))[1];
But this is harder to read. And that which is easier to read is
easier to debug, says Debugging Barbie.
A related trick is assigning to the empty list:
() = somefunc("boo", "hoo");
This puts the call to somefunc into list context, but ignores
the returned values. This replaces assigning to a dummy array:
@dummy_array = somefunc();
undef @dummy_array;
You can assign to the empty list to read through a file:
open(FILE, "< /etc/passwd") || die "Couldn't open passwd : $!\n";
() = <FILE>; # read all lines
close(FILE);
print "There are $. users in the password file.\n";
Assigning to the empty list is new in release 5.004. Prior to then
you got "Can't modify stub in empty list assignment" as an error.
Enjoy,
Nat
------------------------------
Date: Fri, 08 May 1998 22:13:23 GMT
From: fubar@ameritech.deleteme.net (Clinton Pierce)
Subject: Re: Unable to use CPAN.pm through firewall
Message-Id: <35538380.1807017391@192.0.0.10>
Keywords: Perl CPAN proxy
[courtesy e-mail sent to author]
On Thu, 07 May 1998 14:26:39 -0500, Mark Conty
<mconty@year.grain.cargill.com> wrote:
>I have a version of "lynx" for my version of HP-UX, but I saw in the
>code that it doesn't yet support proxy authorization, so I'm probably
>outta luck anyway, even if I _were_ to get CPAN working for our
>restricted firewall environment here. Or might it be the case that I
>can still use CPAN through our firewall without having to make use of
>"lynx"?
I'm at home, so I can't give you an exact number, but there are recent
copies of lynx (source code) that do support proxy authorization.
Given that, you don't have to fiddle with the FTP proxy stuff.
(To my critics, yes I HAVEused CPAN.pm. Just sometimes, It would
be easier to figure out all of this stuff about the modules, or
download them without having a Perl machine of the right type
on the 'Net proper...)
Once you get lynx to go through the proxy (set http_proxy and no_proxy
in your environment, and for goodness sake test it in interactive mode
with normal web pages), then CPAN.pm will work. On my version of
CPAN.pm though, I had to modify the "CPAN.pm" file itself to change
"-source" to "-pauthID:PASSWORD -source" to get through my proxy.
(Not a pretty hack, should have done it right.)
remove deleteme to reply in e-mail
Remove something from the address to reply in E-Mail.
Damned spammers...
------------------------------
Date: Thu, 07 May 1998 22:43:21 GMT
From: hawk@algonet.se (Hakan Hjelmstrom)
Subject: Re: Where can I download Perl interpreter?
Message-Id: <355337d9.9720056@news.algonet.se>
On 7 May 1998 20:48:45 GMT, "Pheng Lay" <phengl@ir-optima.com> wrote:
> Could anyone tell me where I can download a copy of the latest Perl
> interpreter for Winnt? Thanks for any help.
I'd recommend you take a close look at http://www.perl.com/ or
more specific still, check http://www.perl.com/latest.html
There's even a nice little description of the differences between the
two ports availible.
Hmm... I'm rather new posting here and I'm feeling deja-vu already.
Hekan Hjelmstrvm
hawk@algonet.se
------------------------------
Date: Thu, 07 May 1998 22:38:22 GMT
From: steven@amber.co.uk (Steven Wayne)
Subject: Re: WIN32 tee command
Message-Id: <35533704.4021051@news.demon.co.uk>
Dennis Kowalski <dennis.kowalski@daytonoh.ncr.com> wrote:
>Does anyone know if there is a tool on NT that functions like the UNIX
>tee command ??
>
>Maybe something in Perl ??
What does the UNIX tee command do?
--
We pray for one last landing, on the globe that gave us birth,
To rest our eyes on fleecy skies, and the cool green hills of Earth.
-- R.A. Heinlein
http://www.ambercomputing.demon.co.uk/
------------------------------
Date: Thu, 7 May 1998 22:47:22 GMT
From: Gary L. Burnore <gburnore@netcom.com>
Subject: Re: WIN32 tee command
Message-Id: <gburnoreEsLzAy.Mst@netcom.com>
On Thu, 07 May 1998 22:38:22 GMT
in article <35533704.4021051@news.demon.co.uk>
someone claiming to be Steven Wayne <steven@amber.co.uk> wrote:
: Dennis Kowalski <dennis.kowalski@daytonoh.ncr.com> wrote:
: >Does anyone know if there is a tool on NT that functions like the UNIX
: >tee command ??
: >
: >Maybe something in Perl ??
: What does the UNIX tee command do?
Tee allows the output of a command to be directed to two different places
(input).
Example: Run du into a file and see it on the screen at the same
time:
du -f | tee /dev/tty > output.file
--
for i in databasix netcom primenet ; do ; gburnore@$i.com ; done
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
DataBasix | ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
spamgard(tm): zamboni | ][3 3 4 1 4 2 ]3^3 6 9 0 6 9 ][3
http://www.databasix.com | Official Proof of Purchase
===========================================================================
------------------------------
Date: 7 May 1998 22:39:46 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: WIN32 tee command
Message-Id: <6itd7j$kub$1@marina.cinenet.net>
Dennis Kowalski (dennis.kowalski@daytonoh.ncr.com) wrote:
: Does anyone know if there is a tool on NT that functions like the UNIX
: tee command ??
I've seen tee for DOS written many times. Any such should run fine in an
NT DOS box (and I can't imagine how you'd run it elsewhere).
: Maybe something in Perl ??
Here's a simple but useful version:
#!/usr/bin/perl -w
# tee (like the Unix utility)
# Craig Berry (19980507)
use strict;
die "Useage: tee _outfile_\n" unless @ARGV == 1;
my $outfile = shift @ARGV;
open OUT, "> $outfile" or die "Can't open $outfile for writing: $!\n";
while (<>) {
print;
print OUT;
}
close OUT;
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 7 May 1998 23:40:19 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: WIN32 tee command
Message-Id: <6itgp3$o79$2@marina.cinenet.net>
Steven Wayne (steven@amber.co.uk) wrote:
: Dennis Kowalski <dennis.kowalski@daytonoh.ncr.com> wrote:
: >Does anyone know if there is a tool on NT that functions like the UNIX
: >tee command ??
:
: What does the UNIX tee command do?
Tee copies from standard input both to standard output and into an output
file named on its command line. The analogy is to a T-branch in a pipe,
and indeed tee is most often used in piped sequences of commands to
'split' output to two destinations. So, for example,
$ genreport | tee report.txt | lpr
would run genreport, and put its output both into report.txt and onto the
printer. Similarly,
$ make all | tee build.log
would run a build and both log the output and make it visible to the user.
It's a very handy little utility.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Thu, 07 May 1998 22:47:46 GMT
From: hawk@algonet.se (Hakan Hjelmstrom)
Subject: Re: win32, cgi run from dos
Message-Id: <355439bf.10206295@news.algonet.se>
On Thu, 07 May 1998 21:32:35 GMT, David@iqtexas.com wrote:
> Using perl5, cgi.pm
> when I run my cgi in dos, perl asks for some input data(which is cool), but I
> don't know how to tell it that I'm done entering data.
Quoted from the CGI.pm docs: "indicate that you're finished with input
by pressing ^D (^Z on NT/DOS systems)."
Hekan Hjelmstrvm
hawk@algonet.se
------------------------------
Date: Thu, 07 May 1998 18:05:08 -0400
From: Bob Rasmussen <bobras@erols.com>
Subject: Windows 95 Problem
Message-Id: <35523014.3BE1@erols.com>
I run Perl on my Sparc 10 and Windows 95 computers at work.
I just did a backup from my Windows 95 machine at work and
a restore on my Windows 95 machine at home. When trying
to execute a simple
C:\PERL5>PERL -V I receive
"Program will not run in DOS mode" Can anyone suggest why
I have a problem with the home system, but, not the work system?
I also received the same error message when I installed
Perl 5 from a Windows 95 CD containing versions for UNIX,
NT and 95. Any help appreciated...Bob
------------------------------
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 2535
**************************************