[25002] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7252 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 14 21:06:57 2004

Date: Thu, 14 Oct 2004 18:05:09 -0700 (PDT)
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, 14 Oct 2004     Volume: 10 Number: 7252

Today's topics:
    Re: [newbie] shtml question <noreply@gunnar.cc>
    Re: Acceptible idiom ? <koos@no.spam>
    Re: Acceptible idiom ? <richard@zync.co.uk>
    Re: Acceptible idiom ? <koos@no.spam>
    Re: Acceptible idiom ? <richard@zync.co.uk>
    Re: Accessing hashes and converting into an array <tadmc@augustmail.com>
        ANNOUNCE: tclperl-3.1 (Jean-Luc Fontaine)
    Re: C (I think) to Perl Conversion (Peter Scott)
    Re: Error.pm and DBI.pm problem (Horst Walter)
    Re: function overload (not operator overload) <spamtrap@dot-app.org>
    Re: Getting Additional Perl Newsgroups <jkeen_via_google@yahoo.com>
    Re: Help needed replacing deprecated syntax <usenet@morrow.me.uk>
    Re: inverse pattern matching!!! (Anno Siegel)
    Re: is there a better way to mkdir? <abigail@abigail.nl>
    Re: is there a better way to mkdir? (wana)
    Re: is there a better way to mkdir? (Gary E. Ansok)
    Re: Module Testing Question (Anno Siegel)
    Re: odd problem with open() <colinDEL@howarth.de>
    Re: Perl to monitor server stats <usa1@llenroc.ude.invalid>
    Re: Precedence of exponentiation <do-not-use@invalid.net>
    Re: python for perl programmers? <dha@panix.com>
    Re: python for perl programmers? <dwall@fastmail.fm>
    Re: reading a zip from an IO::Scalar in 5.8 <kalinaubears@iinet.net.au>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 15 Oct 2004 01:52:38 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: [newbie] shtml question
Message-Id: <2t8hrjF1tmkvtU1@uni-berlin.de>

Larry wrote:
> David Efflandt wrote:
>> You just need to get the QUERY_STRING from the environment and
>> properly decode it, or use the Perl CGI module (perldoc CGI).
> 
> Just for the record:
> 
> <!--#include virtual="cgi-bin/script.cgi?${QUERY_STRING}" -->

Even if may be off topic, I guess it should be added to the record
that what you originally asked about is an alternative:

     <!--#exec cgi="cgi-bin/script.cgi" -->

As you saw in the document that Paul pointed you too, when using the
"exec" element, a possible query string is automatically passed to the
script.

Whether either or both of the above solutions actually work depends on
the web server configuration. For instance, my own Apache server is
configured to allow "include" but not "exec".

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Mon, 11 Oct 2004 11:58:36 +0200
From: Koos Pol <koos@no.spam>
Subject: Re: Acceptible idiom ?
Message-Id: <newscache$zmze5i$9x$1@news.emea.compuware.com>

Anno Siegel wrote (Monday 11 October 2004 11:44):

>>   !!$a
>> 
>> is a lot shorter than
>> 
>>   defined $a && ($a ne "" || $a <>0 );

> That's a quite common idiom for normalizing booleans, not only
> in Perl.

Stupid things is, I've been doing the lower for years without
realizing the upper is a lot cleaner. And just this very moment
it suddenly dawned...

-- 
KP - Never too old to learn!
43rd Law of Computing: "Anything that can go wr
fortune: Segmentation violation -- Core dumped


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

Date: Mon, 11 Oct 2004 12:54:00 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: Acceptible idiom ?
Message-Id: <ckds8o$keu$1@news.freedom2surf.net>

In article <newscache$tmye5i$yw$1@news.emea.compuware.com>, "Koos Pol"
<koos@no.spam> wrote:


> Although you need to actively think Perl,
>   !!$a
> is a lot shorter than
> 
>   defined $a && ($a ne "" || $a <>0 );
> Comments?

It seems to me that

	($a <> 0) implies ($a ne "") for all $a

so that means the test could have been written

	defined $a && ($a ne "")

Am I missing something?

Rich


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

Date: Mon, 11 Oct 2004 14:43:29 +0200
From: Koos Pol <koos@no.spam>
Subject: Re: Acceptible idiom ?
Message-Id: <newscache$s97f5i$nz$1@news.emea.compuware.com>

Richard Gration wrote (Monday 11 October 2004 13:54):

> It seems to me that
> 
> ($a <> 0) implies ($a ne "") for all $a
> 
> so that means the test could have been written
> 
> defined $a && ($a ne "")
> 
> Am I missing something?


Yes, you do (not your fault). I'm maintaing a script which misuses
a var to have both numeric and string values :-(


-- 
KP
43rd Law of Computing: "Anything that can go wr
fortune: Segmentation violation -- Core dumped


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

Date: Mon, 11 Oct 2004 15:09:41 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: Acceptible idiom ?
Message-Id: <cke477$msb$1@news.freedom2surf.net>

In article <ckdudi$of3$2@mamenchi.zrz.TU-Berlin.DE>, "Anno Siegel"
<anno4000@lublin.zrz.tu-berlin.de> wrote:


> Richard Gration <richard@zync.co.uk> wrote in comp.lang.perl.misc:
>> In article <newscache$tmye5i$yw$1@news.emea.compuware.com>, "Koos Pol"
>> <koos@no.spam> wrote:
>> 
>> > Although you need to actively think Perl,
>> >   !!$a
>> > is a lot shorter than
>> > 
>> >   defined $a && ( $a ne "" || $a <>0 );
>> > Comments?
>> It seems to me that
>> 
>> 	($a <> 0) implies ($a ne "") for all $a
>             ^^
> That's not Perl (nor was it in earlier postings) :)
>> so that means the test could have been written
>> 	defined $a && ($a ne "")

>> Am I missing something?

> The possibility that someone said "$a = 0"?  But anyway, your logic
> escapes me.  Even if it were true that '$a != 0 implies $a ne ""' (which
> it isn't), it would be the test for "" that could be discarded, not the
> one for 0.  Anno

I see your point about flawed logic, however ... what's going on here.
The two expressions appear to be identical, truthwise. Now I'm confused

[rich@richg perl]$ cat truth.pl
#!/usr/bin/perl

truth('a',$c);
$c = 0;
truth('b',$c);
$c = '';
truth('c',$c);
$c = 10;
truth('d',$c);
$c = 'asdf';
truth('e',$c);

sub truth {
        ($t,$n) = @_;

        print "$t 1" if (defined $n && ($n ne "" || $n != 0));
        print "\t";
        print "$t 2" if (defined $n && ($n ne ""));
        print "\n";
}
[rich@richg perl]$ ./truth.pl

b 1     b 2

d 1     d 2
e 1     e 2
[rich@richg perl]$


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

Date: Mon, 11 Oct 2004 10:54:58 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Accessing hashes and converting into an array
Message-Id: <slrncmlb6i.pi0.tadmc@magna.augustmail.com>

Rohit S <rohit.satabhai@bt.com> wrote:

> use HTML;

> use template
             ^^
             ^^  where is the semicolon?
> use Datetime;


Looks like we are not looking that the same code that you
are looking at, since our's will not even compile, and it
sounds like your's is executing...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 11 Oct 2004 03:56:10 -0700
From: jfontain@free.fr (Jean-Luc Fontaine)
Subject: ANNOUNCE: tclperl-3.1
Message-Id: <4244613b.0410110256.27544b8c@posting.google.com>

### CHANGES ###

--- version 3.1 ---
Perl interpreters can now evaluate Tcl code even from Perl threads
   (requires at least a 5.6.0 Perl core)
added tclperl.h file for possible use in extensions to tclperl

### README ###

tclperl version 3.1: a Perl package for Tcl

This package allows the execution of Perl code from a Tcl interpreter,
as in:

     package require tclperl
     set interpreter [perl::interp new]
     $interpreter eval {print "Hello World\n"}
     perl::interp delete $interpreter

You can actually create several Perl interpreters this way, if the
tclperl package was linked against a Perl library compiled with
-DMULTIPLICITY, otherwise only 1 Perl interpreter can exist at a time.

Starting with version 3.1, you can also access and use the parent Tcl
interpreter from a Perl interpreter (and even from Perl threads):

     package require tclperl
     set interpreter [perl::interp new]
     puts [$interpreter eval {
         $Tcl::parent->eval('clock format [clock seconds]');
     }]
     perl::interp delete $interpreter

This package works on UNIX machines (Redhat Linux rpms available at
http://jfontain.free.fr/) and Windows (thanks to David Gravereaux,
DLL also available). See INSTALL file for more information.

This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

###

you may find it at the following locations:

http://jfontain.free.fr/tclperl-3.1.tar.bz2
http://jfontain.free.fr/tclperl-3.1-0.fdr.1.i386.rpm
http://jfontain.free.fr/tclperl-3.1-0.fdr.1.spec
http://jfontain.free.fr/tclperl.htm

-- 
Jean-Luc Fontaine  mailto:jfontain@free.fr  http://jfontain.free.fr/


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

Date: Mon, 11 Oct 2004 14:46:14 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: C (I think) to Perl Conversion
Message-Id: <W0xad.72701$a41.15429@pd7tw2no>

In article <P8qdnTkYG5f-UPTcRVn-ug@comcast.com>,
 "Brad Walton" <sammie-nospam@greatergreen.com> writes:
>my $response_packet = <$sock>;

You're reading a line back from the socket.  The C program showed
no signs of being line oriented.  You need sysread() or recv().

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/


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

Date: 11 Oct 2004 08:38:29 -0700
From: unkwb@web.de (Horst Walter)
Subject: Re: Error.pm and DBI.pm problem
Message-Id: <53867fbe.0410110738.6976f45a@posting.google.com>

Here is a complete one you can run. I read all I found about error.pm,
I am only not certain whether I have to include other use statements
like qw(:catch).

Error is still 
Error: Can't call method "with" without a package or object reference

BTW, thanks to all for your time and efforts
-----------

use strict;
use warnings;
use Error qw(:try);
use DBI;

# global 

my $db = "XXXX";
my $password = "XXXXX";
my $username = "XXXXX";
my $oracle_sid = $db;
my $dbh;

try {

	unless ( $dbh = DBI->connect("dbi:Oracle:$oracle_sid", "$username",
$password, {AutoCommit => 0}) ) {
		print STDERR ("autodb::oracleLogin login Failed as
$username\/$password\@$oracle_sid");
	}
	unless ($dbh->disconnect) {
		print STDERR "autodb::oracleLogoff $DBI::errstr";
	}
	# force an error
	my $n = 0;
	print 0/$n;
} catch Error with {
	my $err = shift;
	print $err;
}



> Post the shortest *complete program* you can construct that
> demonstrates the problem please.  I have never had problems
> with Error.pm and DBI and cannot reproduce your problem.


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

Date: Mon, 11 Oct 2004 07:24:42 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: function overload (not operator overload)
Message-Id: <7aCdnVFEpp_m8PfcRVn-sg@adelphia.com>

Ying-Chieh Liao wrote:

> Can I do function overload in Perl (not operator) ?

Sort of - you can't create functions that share the same name, but have 
different type signatures. But you *can* create a function that will 
react differently according to what types of arguments were passed to it.

> I'd like to create a function, which accepts an object array or an
> object iterator as argument ...

Pass it an array reference, or an object reference, and check the 
argument with ref():

sub overloaded {
     my $self = shift;
     my $argType = ref($_[0]);

     if ($argType eq 'ARRAY') {
         # First arg is array ref

     } elsif ($argType eq 'IteratorClass') {
         # First arg is an IteratorClass object

     } else {
         # It's something else - you can pass it to SUPER
         return $self->SUPER::overloaded(@_);
     }
}

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Fri, 15 Oct 2004 01:03:32 GMT
From: Jim Keenan <jkeen_via_google@yahoo.com>
Subject: Re: Getting Additional Perl Newsgroups
Message-Id: <ElFbd.965$Nj1.134@trndny04>

A. Sinan Unur wrote:
> Jim Keenan <jkeen_via_google@yahoo.com> wrote in 
> news:WJlbd.1210$6W6.315@trndny05:
> 
> 
>>My ISP's news server (news.verizon.net) distributes only a limited 
>>number of Perl USENET news groups.  In particular, they do not carry 
>>perl.qa.
> 
> 
> Am I missing something here? Why don't you add nntp.perl.org to your list 
> of news servers?

And so I just did.  For some inexplicable reason, the name 
notwithstanding, I was only aware of the web interface (the link you 
cited in your follow-up message) to the perl.org lists -- so I was 
thinking of them as mail lists rather than newsgroups.  (I've also read 
the perl.org lists via Google as suggested by Peter Allen.)

Actually, I think the reason is not inexplicable.  I always look at the 
web interface at my day job -- where I don't have a newsreader.

Part of the reason why I prefer to read these lists as news rather than 
through Google is that while I can post to Google and have it 
distributed right away, Google takes 6-9 hours to post messages on its 
own web page.  So I've often replied to postings on this group or on 
c.l.p.modules, only to discover later that 4 other people (usually 
including Tad) had already read the original posting and posted 
responses before me.

Now let me extend this question a bit.  What prompted me to post the 
original question was the discussion yesterday as to how Tad and others 
had Googled "retardo Perl" to discover the source of a quotation from 
MJD.  But when I Googled "retardo Perl", I came up with many references 
to discussions of Perl in Spanish ... which led me to wonder, "How could 
I subscribe to Spanish language Usenet news groups?"  Simply adding 
nntp.perl.org as a news server doesn't suffice for this.

Any further ideas?  Thanks to all.
Jim Keenan


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

Date: Thu, 14 Oct 2004 23:12:03 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Help needed replacing deprecated syntax
Message-Id: <j6a342-gi6.ln1@osiris.mauzo.dyndns.org>


Quoth dummymb@hotmail.com (Page):
> I received the following message:
> 
> C:\Program Files\Apache Group\Apache2\cgi-bin\corr>perl -wc corrdetail.pl
> Using an array as a reference is deprecated at corrdetail.pl line 106 (#1)
>     (D deprecated) You tried to use an array as a reference, as in
>     < @foo-[23] >> or < @$ref-[99] >>.  Versions of perl <= 5.6.1 used to
>     allow this syntax, but shouldn't have. It is now deprecated, and will be
>     removed in a future version.
> 
> corrdetail.pl syntax OK
> 
> Here is the offending line:
> my $msg = @_->[0];
> 
> What is the current proper syntax for such a statement?

That depends on what you meant it to do. If you wanted the first item in
@_, you meant $_[0] (perlsyn). If you wanted to deref an array ref in $_
then you meant $_->[0] (perlref). If you wanted something else you will
have to tell us what that was.

Ben

-- 
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'
                                                               ben@morrow.me.uk


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

Date: 11 Oct 2004 13:50:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: inverse pattern matching!!!
Message-Id: <cke335$rsg$2@mamenchi.zrz.TU-Berlin.DE>

chris <chris.holt@db.com> wrote in comp.lang.perl.misc:
> Background: I have a little program that scans pathnames and does
> something worthile if a match is generated. Equally, I have a config
> file with lines representing patterns to skip. To skip lines I have
> the following (sort of):
> if ($pathname =~ m,^$pattern$,) {;#skip it} else {;#do something
> worthwhile}
> 
> Initially I want to skip home directories: '/home/.*' worked a treat.
> Now I need to skip all, but not anything with '.ssh' in it.
> so '/home/fred/.ssh' or '/home/tom/.ssh/known_hosts' is not excluded.
> 
> Now I know this must be simple but can I figure out a clean inverse of
> '/home/.*?/.ssh'.
> 
> Any ideas gurus?

Use negative lookahead.

It would be more efficient to reverse (or extend) the logic in
configuration processing (that is, make positive selection possible).

Anno


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

Date: 14 Oct 2004 22:23:55 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: is there a better way to mkdir?
Message-Id: <slrncmtv3r.34g.abigail@alexandra.abigail.nl>

Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMLXII September
MCMXCIII in <URL:news:lhstm0dunsmm5omtm8atkopfbb63g99cdt@4ax.com>:
()  On 14 Oct 2004 08:56:27 -0700, ioneabu@yahoo.com (wana) wrote:
()  
() >I use mkdir in a program which recursively searches through a
() >directory searching for files of a particular type and recreating the
() >directory structure elsewhere and the files (which happen to be images
()  
()  Well, I tend to avoid using perl just to launch a bunch of system()
()  cmds as many people does (but then they do much worse things like
()  calling grep, sed, etc. in those system()s), and I've hardly used any
()  until recently when I had to quickly hack up a script that does
()  something very similar to what you need, for which neither a pure *sh
()  script nor a "pure Perl one" (in a loose, but hopefully clear, sense)
()  would satisfy my laziness (you do remember that virtue called
()  'laziness', don't you?), so I used an external 'mkdir -p' which is
()  working great for me. It won't be available on all systems though.


I use 'system' or 'open "$cmd |"' often, even if there are Perl modules
available to do the same. I've never had a problem with using 'system
mkdir => "-p", $dir', and it sure beats writing out the loop yourself. I
always use 'system [rs]?cp|rsync' to copy files, as File::Copy is just
broken (and doesn't have a tenth of the functionality of 'cp'). I can't
be bothered to learn the semantics of File::Find - forking out to 'find'
always does the trick for me.

Perl is a glue language, and its ability to call other programs is a
feature - a feature I treasure. And I don't have any religious feelings
that urge me to write "pure Perl". As for portability, all my portability
problems arise from Perl itself, not the tools I fork out to.



Abigail
-- 
print v74.117.115.116.32.97.110.111.116.104.101.114.
      v32.80.101.114.108.32.72.97.99.107.101.114.10;


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

Date: 14 Oct 2004 15:32:50 -0700
From: ioneabu@yahoo.com (wana)
Subject: Re: is there a better way to mkdir?
Message-Id: <bf0b47ca.0410141432.4346054a@posting.google.com>

> > sub SuperMkdir
> > {
> >         my $path = shift;
> >         my $hold = $path;
> >         while (mkdir($path) == 0)
> >         {
> >                 do
> >                 {
> >                         $path =~ s/[^\/]+\/*$//;
> >                 }
> >                 while (mkdir($path) == 0);
>                                       ^^
> That is wrong.  mkdir returns true on success.
> 

I am actually testing for failure.  Each time mkdir fails, I chop of
the end of the path and try again until I succeed.  The outer loop
repeats this process over and over until the whole path is
successfully created and the loops are exited.  I tested it before
posting on a few examples.

> >                 $path = $hold;
> >         }
> > }
> 
> Well, I guess it might work, but it is more convoluted than it has to be.
> I wouldn't use pattern substitution to extract the partial path names,
> I'd split on the directory separator and build the paths from the parts.
> That can be done in a standard for-loop.  
> 
>     my $dir;
>     for ( split m{/}, $path ) {
>         $dir .= '/' if length $dir;
>         $dir .= $_;
>         mkdir $dir or last;
>     }
> 
> or even
> 
>     my @parts = split m{/}, $dir;
>     mkdir join( '/', @$_) for map [ @parts[ 0 .. $_]], 0 .. $#parts;
> 
> Anno

I like your way.  I was thinking that I had to account for different
ways the path might appear:

//dog/cat//mouse/
dog/cat/mouse
 ./dog/cat/mouse//

The double //'s might come up as a side effect of how a program puts
paths together.  Split should still work because you will just get an
empty string in the array which will not change anything.

wana


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

Date: Thu, 14 Oct 2004 22:37:56 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: is there a better way to mkdir?
Message-Id: <ckmv44$232$1@naig.caltech.edu>

In article <bf0b47ca.0410140756.27b35107@posting.google.com>,
wana <ioneabu@yahoo.com> wrote:
>I use mkdir in a program which recursively searches through a
>directory searching for files of a particular type and recreating the
>directory structure elsewhere and the files (which happen to be images
>which get manipulated by ImageMagick along the way).
>
>In recreating the directory structure, I sometimes come across the
>error:
>
>No such file or directory
>
>which is due to trying to create multiple directory levels at once
>which is not allowed.  While this probably is a problem in my program
>logic (that is another whole issue, but I didn't want to ask too much
>at once), I was wondering, why can't I create a whole path at once
>like:
>
>mkdir mouse/cat/dog
>
>where none of the three directories exist yet.

Have you tried the mkpath() function in the File::Path module?

use File::Path;

mkpath('mouse/cat/dog', 0, 0755);

(change the 0 to 1 and it will print out each directory it creates.)

This is a standard module, so you should have it available already.

-- Gary Ansok


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

Date: 11 Oct 2004 10:18:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Module Testing Question
Message-Id: <ckdmmd$j2u$1@mamenchi.zrz.TU-Berlin.DE>

Eddie <aaa@sss.com> wrote in comp.lang.perl.misc:
> Hi,
> 
> I wanted to test all the subroutines in my module from a script,
>  but I have a problem. Some subroutines are called from only
> inside the module and some are not. Therefore I have code
> like:
> 
> 1     my ($pkg, @args) = @_
> and
> 2     my @args = @_
> 
> in other places. Unfortunately if i test my sub routine that has #2 above,
> I get an error because the package name is passed into the sub and the code
> isnt
> expecting that. Is there a way that a script can call a method in a module
> and not
> pass the package name?

Just a terminological nitpick here.  If it doesn't expect the package
(or an object) as the first parameter, it isn't a method but a plain
subroutine.  As Christian Winter has suggested in another reply, don't
call the non-methods as methods and you're set.

Anno


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

Date: Fri, 15 Oct 2004 01:02:44 +0200
From: Colin Howarth <colinDEL@howarth.de>
Subject: Re: odd problem with open()
Message-Id: <ckn0ij$j1u$02$1@news.t-online.com>

On 2004-10-14 05:05:31 +0200, Tad McClellan <tadmc@augustmail.com> said:

> The documentation for open() says why it is not working.
> 
> You must have missed it.

Yup, missed it. The description for open() has about 300 lines. I 
stopped reading somewhere around when the tutorial on Bourne shell 
filehandle redirection. That was unfortunate since just after that came 
the 2/3 argument bit.  :-)


>    perldoc -f open
> 
>    The filename passed to 2-argument (or 1-argument) form of open() will
>    have leading and trailing whitespace deleted,
>    ...
>    Use 3-argument form to open a file with arbitrary weird characters in it,

Thanks, that does the trick.

> 
>> At present I've resorted to
>> 
>> #               chop $file if $file =~/\r$/;
>> chop $file if substr($file, -1, 1) eq "\r";
> 
> 
> And that makes it work?

Ah. Depends what you meen by work ;-)

It stopped the error in the open, but if you look at the original code,

               if (-d "$dir/$file") {
                        do_dir("$dir/$file");
                } elsif (-f "$dir/$file") {
                        open(FILE, "$dir/$file") or die "Can't open 
'$dir/$file': $!";


and "$dir/$file" (with the last character chopped) is no longer a plain 
file. In fact it isn't any sort of file...

> If so, then the file does NOT have a CR in its name.
> 
> I thought you said above that it did have a CR in its name.
> 
> Which is it?

It did have a CR.


So, thanks - problem solved (and something learned).

colin



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

Date: 15 Oct 2004 00:17:20 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Perl to monitor server stats
Message-Id: <Xns9582CEAF689D3asu1cornelledu@132.236.56.8>

"KWall" <mirak63@carolina.rr.com> wrote in
news:r-qdnfloErLJGPPcRVn-ig@giganews.com: 

> "A. Sinan Unur" <usa1@llenroc.ude.invalid> wrote in message 
> news:Xns9581CEDAA2917asu1cornelledu@132.236.56.8...
>> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in
>> news:Xns95819CC47D80Aasu1cornelledu@132.236.56.8:
>>
>>> I have not used them, but have you looked at
>>>
>>> Win32::NetAdmin
>>>
>>> and
>>>
>>> Win32::NetResource
>>
>> On second thought, those modules don't seem to do what you want.
>> Sorry. 


> I 've used them extensivly in the past and they don't provide them.
> Perflib may but it breaks the RAM into each segment. I'm really just
> looking for the overall physical RAM in use. I found a module that
> takes care of the CPU reporting.

In cases like this, Win32::API and the associated modules can be 
lifesavers. You can find the Windows API documentation for memory status 
functions at http://tinyurl.com/vfcw. Below, I am going to implement 
GlobalMemoryStatus, but for your application, you probably want 
GlobalMemoryStatusEx. It is just that I am at a Win98 machine right now, 
and the latter does not seem to be available.

The code below is almost a straight copy & paste from the MSDN 
documentation.

#! perl

use strict;
use warnings;

use Win32::API;
use Win32::API::Struct;

use Data::Dumper;

Win32::API::Struct->typedef('MEMORYSTATUS', qw(
  DWORD  dwLength;
  DWORD  dwMemoryLoad;
  SIZE_T dwTotalPhys;
  SIZE_T dwAvailPhys;
  SIZE_T dwTotalPageFile;
  SIZE_T dwAvailPageFile;
  SIZE_T dwTotalVirtual;
  SIZE_T dwAvailVirtual;
));

Win32::API->Import(
    'kernel32', 'VOID GlobalMemoryStatus(LPMEMORYSTATUS lpStat)'
);

my $stat = Win32::API::Struct->new('MEMORYSTATUS');

GlobalMemoryStatus($stat);

printf "Size of memory status structure: %ld bytes\n",
        $stat->{dwLength};
printf "Memory in use: %ld%%\n",
        $stat->{dwMemoryLoad};
printf "Total physical memory: %ld bytes\n",
        $stat->{dwTotalPhys};    
printf "Free physical memory: %ld bytes \n",
        $stat->{dwAvailPhys};
printf "Total paging file: %ld bytes\n",
        $stat->{dwTotalPageFile};
printf "Free paging file: %ld bytes\n",
        $stat->{dwAvailPageFile};
printf "Total virtual memory: %ld bytes \n",
        $stat->{dwTotalVirtual};
printf "Free virtual memory: %ld bytes\n",
        $stat->{dwAvailVirtual};

__END__

D:\Home> perl w32meminfo.pl
Size of memory status structure: 32 bytes
Memory in use: 84%
Total physical memory: 133558272 bytes
Free physical memory: 131072 bytes
Total paging file: 536870912 bytes
Free paging file: 414134272 bytes
Total virtual memory: 2143289344 bytes
Free virtual memory: 2104754176 bytes


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

Date: 11 Oct 2004 14:00:13 +0200
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Precedence of exponentiation
Message-Id: <yzdmzytjwhe.fsf@invalid.net>


Abigail <abigail@abigail.nl> writes:
> David Frauzel (nemo@weathersong.net) wrote on MMMMXLV September MCMXCIII
> in <URL:news:1096244875.SwmN1svA7N7MUFMdSJ4pgw@teranews>:
> ^^  Rhetorical question.
> ^^  
> ^^  Why does Perl give such high precedence to the exponentiation operator, 
> ^^  "**"?
> ^^  
> ^^  perlop makes it very clear that -2**4 is equivalent to -(2**4), not (-2)
> ^^  **4. So -2**4 gives you -16, not 16. So Perl facilitates people who 
> ^^  prefer unary operators to have less significance than binary operators, 
> ^^  which seems to be completely counter to the general rules of algebra.
> 
> Short answer: because C has the same precedence table. I think it's
> commonly regretted in the Perl world that it is this way, but the 
> advantages of changing the precedence table are dwarved by the pain
> it will cause. 

Sorry for coming in late, and maybe someone already pointed this out,
but C does not have an exponentiation operator, so it is not from C
that Perl got it.


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

Date: Fri, 15 Oct 2004 00:19:48 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: python for perl programmers?
Message-Id: <slrncmu5t4.206.dha@panix2.panix.com>

On 2004-10-14, John Bokma <postmaster@castleamber.com> wrote:
> Chris Richmond - MD6-FDC ~ wrote:
>
>> Hi Folks,
>> 
>>    Not out of choice, I'm going to have to learn python on
>> Windows.  I've used perl on Unix forever and totally hate
>> the idea, but like I said, no choice.

We're so sorry. :-)

>> What I'm looking for is a some sort of a Learning python
>> for perl programmers.  I don't think I need plain old
>> programming help, but something that will translate all
>> those nice perl concepts into the equivelant python
>> constructs.
>
> I personally think that is a bad idea.

I think it's not so much a bad idea as a virtually impossible idea.
Perl and Python are, in many ways, completely different.  I would doubt
that many Perl idioms would be translatable into Python.

But that's just my opinion.

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
I'm already not yet convinced.	- Larry Wall


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

Date: Fri, 15 Oct 2004 00:23:21 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: python for perl programmers?
Message-Id: <Xns9582CF6A44810dkwwashere@216.168.3.30>

crichmon@filc8046.fm.intel.com (Chris Richmond - MD6-FDC ~) wrote:

>    Not out of choice, I'm going to have to learn python on
> Windows.  I've used perl on Unix forever and totally hate
> the idea, but like I said, no choice.
> 
> What I'm looking for is a some sort of a Learning python
> for perl programmers.  I don't think I need plain old
> programming help, but something that will translate all
> those nice perl concepts into the equivelant python
> constructs.  I don't have a *.python.advocacy on this
> news server, otherwise I would have started there.
> I've already checked out the docs on python.org, and didn't
> really like what I saw.

I've dabbled with Python a little, and collected a few links at 
http://ylatis.com/cgi-bin/shire?PythonLanguage

I suspect "Dive into Python" is the best for your purposes:
http://diveintopython.org/

You might also find the Portland Pattern Repository Wiki page for the 
Python language to be useful: http://c2.com/cgi/wiki?PythonLanguage


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

Date: Fri, 15 Oct 2004 10:15:04 +1000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: reading a zip from an IO::Scalar in 5.8
Message-Id: <416f17c9$0$25578$5a62ac22@per-qv1-newsreader-01.iinet.net.au>

Kevin wrote:
> perl, v5.8.3
> Archive-Zip-1.13
> 
> How do I need to change the code given in the Archive::Zip examples
> directory to make it work with perl 5.8? It works ok on machines with
> 5.6 and I'm assuming that it's a problem caused by changes in 5.8.
> 

Second attempt at posting - apologies if the first attempt shows up as 
well. (Never use Mozilla .... for *anything* !!!)

I find no problem with the script on both perl 5.6.1 and perl 5.8.5 so 
long as "testin.zip" is no larger than the number of bytes being read 
(20,000 in the example given).

I'm on Windows2000.

Cheers,
Rob

-- 
To reply by email u have to take out the u in kalinaubears.



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V10 Issue 7252
***************************************


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