[10555] in Perl-Users-Digest
Perl-Users Digest, Issue: 4147 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 4 12:07:58 1998
Date: Wed, 4 Nov 98 09:00:27 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 4 Nov 1998 Volume: 8 Number: 4147
Today's topics:
/libg++:2.7.2;/: nested *?+ in regexp at /mis/install/U jnoviell@my-dejanews.com
Re: /libg++:2.7.2;/: nested *?+ in regexp at /mis/insta (Tad McClellan)
Re: [HELP] I can't use Socket. ronald_f@my-dejanews.com
Re: Array Ref Question (Brand Hilton)
Difference in ftp::pm distribued with Res Kit <tor@kmd.dk>
Easy problem with @ARGV rfreytag@my-dejanews.com
Easy problem with @ARGV rfreytag@my-dejanews.com
Re: FAQ question. dave@mag-sol.com
Re: FAQ question. (Tad McClellan)
Re: HELP! I need a perl enviroment for Win 95 dturley@pobox.com
Re: How to insert PERL commands in a ASP page ? <msergeant@ndirect.co.uk_NOSPAM>
Re: libwww question... (Bart Lateur)
Re: Newbie: read a string from keyboard <d-edwards@nospam.uchicago.edu>
Re: Not to start a language war but.. <hyoon@bigfoot.com>
Re: Not to start a language war but.. <jdporter@min.net>
Re: Not to start a language war but.. <jdporter@min.net>
Re: Not to start a language war but.. <jdporter@min.net>
Re: Not to start a language war but.. <jdporter@min.net>
Re: Opendir <sigh> again (Tad McClellan)
Re: perl newbie desperate question <finortis@intrex.net>
Perl Programming Workshop <dmurray@dgesolutions.com>
Re: perl&cgi question droby@copyright.com
Re: PERL/UNIX newbie wants to multiprocess in his first dzuy@my-dejanews.com
Re: PERL/UNIX newbie wants to multiprocess in his first (Andrew M. Langmead)
Re: Poll: How Did You Learn Perl? <jdporter@min.net>
Problem with encrypting/decrypting files glerat@igtech.fr
Proc-ProcessTable-0.04 (was Monitoring a child process. <sobek@irit.fr>
Re: reading a string in from a text file (Tad McClellan)
Re: redirect output (Tad McClellan)
Using a tied hash as a class member - please help ronald_f@my-dejanews.com
Verify secure web page is up <eyoung_3@earthlink.net>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 04 Nov 1998 13:51:17 GMT
From: jnoviell@my-dejanews.com
Subject: /libg++:2.7.2;/: nested *?+ in regexp at /mis/install/Update/Patchdiag-1.0.2/patchdiag.pl line 799.
Message-Id: <71pm4l$mtr$1@nnrp1.dejanews.com>
Greetings,
Does anyone now what this means ?
/libg++:2.7.2;/: nested *?+ in regexp at
/mis/install/Update/Patchdiag-1.0.2/patchdiag.pl line 799.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 4 Nov 1998 09:42:20 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: /libg++:2.7.2;/: nested *?+ in regexp at /mis/install/Update/Patchdiag-1.0.2/patchdiag.pl line 799.
Message-Id: <sksp17.i0e.ln@flash.net>
jnoviell@my-dejanews.com wrote:
: Greetings,
: Does anyone now what this means ?
: /libg++:2.7.2;/: nested *?+ in regexp at
: /mis/install/Update/Patchdiag-1.0.2/patchdiag.pl line 799.
Yes. It means you have a nested + in regexp
((libg+)+)
You need to escape (backslash) regex metatcharacters if you want
the literal character.
Perl will do the escaping for you, if you ask for it:
/\Qlibg++:2.7.2;/
^^
^^
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 04 Nov 1998 16:18:25 GMT
From: ronald_f@my-dejanews.com
Subject: Re: [HELP] I can't use Socket.
Message-Id: <71puoh$439$1@nnrp1.dejanews.com>
In article <71j6e2$i3q$1@lucifer.secom-sis.co.jp>,
taguti@secom-sis.co.jp (Taguti) wrote:
> 11:38:53 ~ $ perl -e 'use Socket; exit;'
Hmmm... I think this should be
use IO::Socket
but...
> Can't find 'boot_Socket' symbol in
> /opt/perl5/lib/PA-RISC1.1/5.00401/auto/Socket
> /Socket.sl
... I had nevertheless expected a different error message.
--
Ronald Fischer <ronald_f@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 4 Nov 1998 15:54:37 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: Array Ref Question
Message-Id: <71ptbt$bh113@mercury.adc.com>
In article <1dhy0ic.20yvma1idm8tsN@bay1-282.quincy.ziplink.net>,
Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
>Brand Hilton <bhilton@tsg.adc.com> wrote:
>
>> Out of curiosity... in your program, you have the following line:
>>
>> my $array_ref = +['1'];
>>
>> Was that "+" intentional? It appears to be ignored, which surprises
>> me somewhat. I know a "+" preceding a curly brace disambiguates
>> anonymous hashes from blocks, but I don't know what, if anything, "+["
>> does.
>
>That's like asking what the "-(" does in "$foo = -($bar * $baz)";
>
>+, like -, can be a unary operator. Unlike unary minus, "unary plus has
>no semantic effect whatsoever." [perlop] Instead, it is useful for its
>syntactic effects, such as disambiguating anonymous hashes from blocks,
>or keeping a parenthesized list from being interpreted as the entire
>argument to a function, as in "print +(2*3)-4;"
>
>+{} disambiguates an anonymous hash from a block because a block cannot
>be used as the operand of unary +, while an anonymous hash can.
So, like I said, "+[" doesn't do anything different from bare "[".
But Perl doesn't complain about it because, hey, no harm no foul :-)
That makes sense. Thanks.
--
_____
|/// | Brand Hilton bhilton@adc.com
| ADC| ADC Telecommunications, ATM Transport Division
|_____| Richardson, Texas
------------------------------
Date: Wed, 4 Nov 1998 16:19:56 +0100
From: "Torfinn Keringen" <tor@kmd.dk>
Subject: Difference in ftp::pm distribued with Res Kit
Message-Id: <71prcr$aid$1@miri.tele.dk>
Hi
I Just installed Perl Res Kit (5.005) and the libnet module.
When I try to do; connect, ls and quit, I get a strange error, look at the
line with a --> in the begining.
It mostly the line with my IP address that confuse me, why is a 0,0 in the
end, on an other installation with an older verson of perl and Net::pm it
says 4,34 at the end.
Its like it don't find it way back to me.
any suggestions
Torfinn --> tor@kmd.dk
C:\data\perl>perl ftptest.pl
Net::FTP: Net::FTP(2.33)
Net::FTP: Exporter
Net::FTP: Net::Cmd(2.11)
Net::FTP: IO::Socket::INET
Net::FTP: IO::Socket(1.1603)
Net::FTP: IO::Handle(1.1505)
Net::FTP=GLOB(0x10eda00)<<< 220-
Net::FTP=GLOB(0x10eda00)<<< 220 server3 FTP server (Version 2.1WU(1)) ready.
Net::FTP=GLOB(0x10eda00)>>> user xxxxxx
Net::FTP=GLOB(0x10eda00)<<< 331 Password required for edisafe.
Net::FTP=GLOB(0x10eda00)>>> PASS ....
Net::FTP=GLOB(0x10eda00)<<< 230 User edisafe logged in.
-->Net::FTP=GLOB(0x10eda00)>>> PORT 172,20,10,33,0,0
Net::FTP=GLOB(0x10eda00)<<< 200 PORT command successful.
Net::FTP=GLOB(0x10eda00)>>> NLST
-->Net::FTP=GLOB(0x10eda00)<<< 425 Can't build data connection: Cannot
assign requested address.
Net::FTP=GLOB(0x10eda00)>>> QUIT
Net::FTP=GLOB(0x10eda00)<<< 221 Goodbye.
------------------------------
Date: Wed, 04 Nov 1998 15:17:50 GMT
From: rfreytag@my-dejanews.com
Subject: Easy problem with @ARGV
Message-Id: <71pr6u$uii$1@nnrp1.dejanews.com>
Hi Folks,
Here is an easy one for you. I am trying to grab my command line arguments
after the program name and print out the arguments. The catch is that the
arguments are wildcarded pathnames.
Here is the code:
#!/usr/bin/perl -w
($from, $to) = @ARGV;
chomp( $from, $to);
print "0\n";
print "( $from, $to)\n";
print "1\n";
print "\$from: $from\n";
@list = glob( "$from");
print "2\n";
print @list;
print "\n";
die "break in program\n";
end code. Here is the execution (the prompt is "rfreytag@freytag%":
rfreytag@freytag% ./g.pl /home/rfreytag/* /*
0
( /home/rfreytag/Macjordomo.hqx, /home/rfreytag/coreproof)
1
$from: /home/rfreytag/Macjordomo.hqx
2
/home/rfreytag/Macjordomo.hqx
break in program
rfreytag@freytag%
end execution display.
As you can see the wildcarded filenames (/home/rfreytag/*), are being
interpreted. If I put $from and $to in single quotes (' '), then the
variable contents are not printed. Here is the question:
Q: How does one avoid (simple solution please!), having wildcarded filenames
being evaluated to the directory contents when printing out the contents of a
scalar variable that is a wildcarded filename?
Thanks! (See I told you it was simple)
--
Cheers,
Richard Freytag
Skyline Soaring Club - LS-3a
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 04 Nov 1998 15:20:32 GMT
From: rfreytag@my-dejanews.com
Subject: Easy problem with @ARGV
Message-Id: <71prc0$umo$1@nnrp1.dejanews.com>
Hi Folks,
Here is an easy one for you. I am trying to grab my command line arguments
after the program name and print out the arguments. The catch is that the
arguments are wildcarded pathnames.
Here is the code:
#!/usr/bin/perl -w
($from, $to) = @ARGV;
chomp( $from, $to);
print "0\n";
print "( $from, $to)\n";
print "1\n";
print "\$from: $from\n";
@list = glob( "$from");
print "2\n";
print @list;
print "\n";
die "break in program\n";
end code. Here is the execution (the prompt is "rfreytag@freytag%":
rfreytag@freytag% ./g.pl /home/rfreytag/* /*
0
( /home/rfreytag/Macjordomo.hqx, /home/rfreytag/coreproof)
1
$from: /home/rfreytag/Macjordomo.hqx
2
/home/rfreytag/Macjordomo.hqx
break in program
rfreytag@freytag%
end execution display.
As you can see the wildcarded filenames (/home/rfreytag/*), are being
interpreted. If I put $from and $to in single quotes (' '), then the
variable contents are not printed. Here is the question:
Q: How does one avoid (simple solution please!), having wildcarded filenames
being evaluated to the directory contents when printing out the contents of a
scalar variable that is a wildcarded filename?
Thanks! (See I told you it was simple)
--
Cheers,
Richard Freytag
Skyline Soaring Club - LS-3a
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 04 Nov 1998 13:56:46 GMT
From: dave@mag-sol.com
Subject: Re: FAQ question.
Message-Id: <71pmev$njd$1@nnrp1.dejanews.com>
In article <36422882.403949438@thunder>,
NukeEmUp@ThePentagon.com (David Cantrell) wrote:
> On Tue, 03 Nov 1998 15:11:24 +0100, Kjetil Svendsberget
> <kjetil@balder.no> enlightened us thusly:
>
> >I have a question which i didnt find at language.perl.com/faq
> >which MUST be a faq.
> >
> >How do i remove carrige returns from a file copied from winblows to
> >unix?
>
> The easiest way (that is, without even touching vi or perl) is to
> transfer the file using ftp, in TEXT mode as opposed to BINARY mode.
...or you may find that your Unix has the dos2unix filter (if not it's trivial
to write one in Perl).
dos2unix < nasty_corrupted_pob_file > pristine_cleaned_up_unix_file
hth,
Dave...
--
dave@mag-sol.com
London Perl M[ou]ngers: <http://london.pm.org/>
[Note Changed URL]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 4 Nov 1998 08:09:13 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: FAQ question.
Message-Id: <96np17.rkd.ln@flash.net>
Kjetil Svendsberget (kjetil@balder.no) wrote:
: James Peregrino wrote:
: >
: > perl -p -i -e s/\r//g yourfilename
: > on the unix machine.
: Thanks, exactly what i been looking for!
: Except it still dont work.
: You do mean
: perl -p -i -e s/\\r//g yourfilename
: right? Doing the above removes all 'r' from yourfilename.
You need some single quotes to keep the shell from changing
arguments before it calls perl:
perl -p -i -e 's/\r//g' yourfilename
^ ^
^ ^ make the shell leave this alone
But that is much slower than:
perl -p -i -e 'tr/\r//d' yourfilename
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 04 Nov 1998 14:04:22 GMT
From: dturley@pobox.com
Subject: Re: HELP! I need a perl enviroment for Win 95
Message-Id: <71pmt6$o17$1@nnrp1.dejanews.com>
In article <364008BF.14DC@mrfoda.com>,
> Ok why does nobody believe me? I found two macro viruses ( Microsoft
> Word).
There are no word documents in the AS distribution (last time I looked) how
can there be word macro viruses in there?
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 04 Nov 1998 14:13:12 +0000
From: Matt Sergeant <msergeant@ndirect.co.uk_NOSPAM>
Subject: Re: How to insert PERL commands in a ASP page ?
Message-Id: <364060F8.103E6143@ndirect.co.uk_NOSPAM>
alphaque@my-dejanews.com wrote:
>
> Hi.. May I know is there any way for me to insert some PERL commands in the
> ASP pages ? If yes, what is the syntax and do I need to install the PERL
> interpreter in my IIS server because I don't think the ASP interpreter can
> understand the PERL command.. Any help ? Thanks
Yes, you need to install perl on the IIS server. Get it from
www.activestate.com (install ActivePerl with PerlScript). Then see the
docs for PerlScript/ASP on my web page.
--
<Matt/>
| Fastnet Software Ltd | Perl in Active Server Pages |
| Perl Consultancy, Web Development | Database Design | XML |
| http://come.to/fastnet | Information Consolidation |
------------------------------
Date: Wed, 04 Nov 1998 14:04:40 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: libwww question...
Message-Id: <3642565e.3833050@news.ping.be>
bbrelin@dnai.com wrote:
>I'm to send the following HTML code to an internal web server:
>
>HTTP-Version=HTTP/1.0
>Content-Type=text/html
><HTML>
There should be at least one empty line between headers and contents,
i.e. in this case, between the "Content-type" line, and the "<HTML>".
Is that your problem?
Bart.
------------------------------
Date: Wed, 4 Nov 1998 15:56:21 GMT
From: Darrin Edwards <d-edwards@nospam.uchicago.edu>
Subject: Re: Newbie: read a string from keyboard
Message-Id: <tgvhkvsb8a.fsf@noise.bsd.uchicago.edu>
Joyot Pierre <joyot@univ-tln.fr> writes:
>
> My problem:
> How can i read a string from keyboard (the Pascal readln)?
>
> A very simple problem I suppose !
>
> Thank you.
Look in the "perlop" section of the perl documentation
(should be man perlop or perldoc perlop on your computer)
under the heading "I/O Operators." You're looking for
something called the angle bracket operator.
Cheers,
Darrin
------------------------------
Date: Wed, 04 Nov 1998 09:10:07 -0500
From: Hoon Yoon <hyoon@bigfoot.com>
Subject: Re: Not to start a language war but..
Message-Id: <3640603F.381478C3@bigfoot.com>
Nowadays, I just implement Python with VB as GUI and don't even bother
trying to explaining it. It works well and no one can understand why I
can get complicated stuff out so quickly using VB. Job security on
triple counts. ;)
If I consider this thread subject "Re: Not to start a language war
but.." as curly braces (and replaced it with'em), the whole
comp.lang.python would look like perl program. -> poor readability.
Please cross post to show our gratitude.
Some people really have problem following direction. They don't even
bother reading the title.
Perl hacks would have difficulties against Pythoneers in general. Many
were disenchanted Perlers who know exactly why they switched. Here's a
suggestion, learn little bit of Python to attack back. Let's have a
month of cease fire on this subject; so, people can get used to white
spaces and get enhanced class. And after that those people can either
come back with well informed arguments (with better subject title like
'To start another P-langs holy war'), or "Well.., if you can'T lick'em,
join'em." (Yosemite Sam)
"JANE!... STOP THIS CRAZY THING!!" George Jetson
Hoon,
Bill Tutt wrote:
>
> COM support exists for perl as well as an ActiveX Scripting Eningne, check
> out http://www.activestate.com/
> The Perl Resource Kit from O'Reilly (non-free) comes with code to allow you
> to make COM servers out of Perl code (including type libraries)
>
> Although Python's COM system is significantly more flexible then Perl's
> current COM support, except that nobody has gone to the trouble of
> generating type libraries directly from Python code.
>
> e.g.: Perl's COM support currently only handles IDispatch interfaces whereas
> Python's COM infrastructure can handle anything you throw at it. (As long as
> you write some C wrapping modules for the IUknown derived interfaces you
> want to work with)
>
> Bill
------------------------------
Date: Wed, 04 Nov 1998 11:01:27 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Not to start a language war but..
Message-Id: <36407A57.76338728@min.net>
V. Chandrasekhar wrote:
>
> Even here by judicious use of white space and
> comments, one can make the code rapidly comprehendable.
> (I have been interested for quite a while now on writing
> an article on Rapid Comprehendability of Computer Programs
> or some such thing. Whether I do this or not, as far as I
> know, I am the first to use this term in this context. I
> think that this is a useful term. Perhaps the term can be
> improved.) The point is: To give up a language because one
> does not like '{' or '&', seems to me to throw away a
> treasure because some dust is attached to it.
> . I have never used Python. However, I have not had
> trouble writing rapidly comprehendable programs with
> Perl.
Whatever you do, please remember that the word is
"comprehensible", not "comprehendable".
$Chandrasekhar{'vocab'} =~ s/hendab/hensib/g;
Thank you.
John Porter
------------------------------
Date: Wed, 04 Nov 1998 11:36:42 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Not to start a language war but..
Message-Id: <3640829A.30854642@min.net>
Thomas Andrews wrote:
>
> In article <363f183a.9460846@read.news.global.net.uk>,
> >
> >Exactly what I've been saying - perl discourages OO programming.
>
> I essentially agree with this.
I hope by now everyone can see that this is not really a valid
characterization of Perl. For some people, apparently, it is
valid to say that they find attemping OO in Perl leaves them
discouraged; but many other people do not share that experience.
I, for example, find programming OO in Perl to be no more
trouble than non-OO.
John Porter
------------------------------
Date: Wed, 04 Nov 1998 11:31:55 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Not to start a language war but..
Message-Id: <3640817B.4E408599@min.net>
Dave Kirby wrote:
>
> John Porter <jdporter@min.net> wrote:
> >Again, poor choice of words. s/wrong/not preferable/; s/right/preferable/.
>
> As far as I can tell from reading perltoot.pod, the right/preferable
> version is necessary for inheritance to work properly. If I read it
> right the first version will work ok until you (or someone else)
> derives from the class at which point it will fall over. To my mind
> that makes the first version wrong.
Without going to the docs, I can tell you that it is not *necessary*, in
the general sense. It is necessary in one style of programming, but
in at least one other, it is not necessary. The author of that doc
prefers the former style, needless to say.
> >It's the creation of objects which has primacy in perl, not the declaration
> >of classes. The notion of a class in perl is very fluid, very dynamic.
>
> According to the docs the package that the reference is being blessed
> into is the class of that object, so you are still defining a class.
Maybe this is simply a semantic nitpick, but blessing an object into a
package does not, imho, "define a class". It defines an object.
Perl's OO mechanism does not depend on the existence of the definition
of classes; it is entirely wrapped up in how *objects* are handled.
Now, this does not answer the fundamental question; replace "class"
with "object" in the question, and I'll admit it's a good one.
> >> With python it is immediately apparent that a class is being
> >> created even to someone who has never seen the language before.
> >
> >Only because the construction is similar to other languages with which
> >they already have familiarity. A good analogy can be drawn to human
> >languages.
>
> It is also because in python the keyword that defines the class is not
> hidden away in the middle of a function.
Ref my comment above. No keyword defines a class.
A package is a "class" only because/if an object tries to find its methods
there.
> Even an experienced perl
> hacker would have to scan through the text of a package to find out if
> it is a class or not. Not having this vital piece of information at
> the place that the package is declared unncessarily increases the
> cognitive effort of understanding the code.
One simple comment will do it.
I (almost) always include a comment to this effect; just like
I comment each sub in a package as being an object method, a package
method, or not a method.
> >> I used perl for years for the creation of various utilities and I cant
> >> remember ever using classes in production code - it simply wasnt in my
> >> perl mindset.
> >
> >I think that's a feature of perl.
>
> Exactly what I've been saying - perl discourages OO programming.
I think you're too ready to infer that meaning from that text.
Perl does not force OO. That's not the same as discouraging it.
Perl encourages multiplicity of paradigms, and multiple dialects.
That's a feature.
> It doesnt need to be hard, just a little mental effort is enough to
> make a difference to the way you use a language. The Worf hypothesis
> states that thought follows language - the way you think about a
> problem is dictated by the language you are thinking in. ...
> When I am thinking in perl I
> think procedurally and if absolutely necessary translate it into OO
> form later, since it takes more mental effort - which is what you
> imply you do.
Yes, I think that's true. But for me at least, the additional effort
to write OO perl is marginal. I never find myself cursing the fact
that "now I have to write OO". Like a lot of things we do that are
not the easiest of alternatives, I do it because it's fun/fulfilling/
satisfying.
> In python I am far more likely to think in OO terms from
> the start since it is more natural in that language. My experience is
> that it makes me a better programmer in python than I am in perl.
I consider myself a multi-paradigm programmer. OO is a tool in my belt.
If it is apparent before coding that the design wants to be OO, then
I start out in OO. Many times, I'm designing concurrently with coding,
so the appropriateness of OOP is somewhat emergent.
John Porter
------------------------------
Date: Wed, 04 Nov 1998 11:47:36 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Not to start a language war but..
Message-Id: <36408528.C844D93E@min.net>
Hoon Yoon wrote:
>
> Let's have a month of cease fire on this subject...
> And after that those people can either
> come back with well informed arguments
Oh, I don't know... I think we've been trading volleys for so long,
it's lost a lot of its bitterness. I for one am finding the exchange
of ideas very educational.
John Porter
------------------------------
Date: Wed, 4 Nov 1998 09:06:25 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Opendir <sigh> again
Message-Id: <hhqp17.1td.ln@flash.net>
Patrick Taylor (alpaca@gmp.usyd.edu.au) wrote:
: i've checked through Dejanews for all the posts on this but no one seems
: to have had exactly the same problem.....
Maybe because other folk get a more helpful error message
from their die(). See below.
: i got a very simple script that lists files from a list of directories
: and prints the full file names. It gets to the opendir command and
: returns the "Cannot open..." (and yep, the directories do exist, and the
: directory name it returns is valid). i'ce made the file owned by, and
: run by, root.
: Any clues for the clueless?
: #!/usr/local/bin/perl -w
: $rootdir="/usr/local/web/docs";
: open ( LIST, "list" ) ;
You check the return value from opendir() below, but leave
this open() call fragile.
Toughen it up. You should always, yes *always*, check the
return value from open() calls.
: while (<LIST>){
: $dir= "$rootdir/$_";
: opendir DIR, $dir or die "Cannot open $dir";
opendir DIR, $dir or die "Cannot open '$dir' $!";
I work in three features on *every* open() (or opendir()) call:
1) check the return value (you have this one)
2) put delimiters around the file/dir name (this would have
saved your bacon with your current problem)
3) print the $! special variable (as a string) to get
(hopefully) helpful error messages, such as
"No such file or directory"
: @allfiles = grep ( !/^\./, readdir(DIR));
That works. I like to say it like below, though use whatever
looks "better" to you (negative logic makes my head hurt):
@allfiles = grep ( /^[^.]/, readdir(DIR));
: closedir(DIR);
: for $i ( 0 .. $#allfiles ){
: print " [$dir/@{$allfiles[$i]}]\n ";
^^ ^
Since you haven't gotten any elements into @allfiles due to
the missing chomp(), you haven't discovered the problem(s)
with this part.
What array are you trying to access there?
The space following the newline makes every line (except
the first one) be indented two spaces. Looks funny.
I think you just want to print the "files" found, right?
foreach (@allfiles) {
print " [$dir/$_]\n";
}
: }
: }
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 4 Nov 1998 09:49:31 -0800
From: "finortis" <finortis@intrex.net>
Subject: Re: perl newbie desperate question
Message-Id: <71povb$be0$1@supernews.com>
Casema wrote in message <71pkd4$2eu$1@sun4000.casema.net>...
>Hi perl programmers,
>
>I downloaded perl from www.perl.com and installed it on my windows98 pc for
>testing.
>the compiler itself is in c:\perl\bin
>
>what is the code to point to this directory. Al my testing results with the
>same output......
>The prints are ignored and the HTML is installed.
>I cannot use variables, nothing
>
>#!c:\perl\bin\perl does not work.
>Please, can someone point me in the right direction?
>
>thanks,
>
>Michel
>
>
Assuming that you have already included the perl path to the "autoexec.bat"
file, that "#!/perl path" line in the script is a Unix thing. There are some
ways of getting the same deal in Windows (file assocaition), but I always
prepend my scripts in Windows with "perl whateverScriptName". There is a
modules out there that will give you an executable (well, sort of)...I think
it's "perl2exe" or something like that...
Finortis
------------------------------
Date: Wed, 04 Nov 1998 15:08:48 GMT
From: "Deborah Murray" <dmurray@dgesolutions.com>
Subject: Perl Programming Workshop
Message-Id: <01be0805$018e3c30$cf98c9d0@debhome>
UniForum Technology Training Institute Presents:
Accelerated Perl Workshop
January 28-29, 1999
San Jose, CA
Space is limited to 15 attendees.
For more information, call 1-800-333-8649 or visit the Web @
www.uniforum.org/web/education/perlworkshop.html
------------------------------
Date: Wed, 04 Nov 1998 15:45:57 GMT
From: droby@copyright.com
Subject: Re: perl&cgi question
Message-Id: <71psrl$u3$1@nnrp1.dejanews.com>
In article <363EC5AF.14E81D60@balder.no>,
Kjetil Svendsberget <kjetil@balder.no> wrote:
>
>
> brian d foy wrote:
> >
> > In article <363DDAE2.A18140AE@corp.home.net>, Justin Harvey
<jbharvey@corp.home.net> posted:
> >
> > > You need to change the mime association for .pl extension inside your
> > > browsers so that it will use it as a CGI, and not try to download it.
> >
> > sorry, but it's the server that does what you are thinking about.
>
> Sorry for asking this in the wrong newsgroup, but as i said this is NOT
> a web server problem, since both machines acess the same web-server
> (www.balder.no), they even have the same browser. IE 4.0 (v.4.72). But i
> get different results looking at the same page.
> I really thought there was something wrong with my perl script because
> whenever the perl script is uncompilable it sometimes happened that the
> browser wants to download the script instead of executing it.
> So if this is not perl related in what newsgroup should i ask this
> question then?
>
If it's really a browser problem, try
comp.infosystems.www.browsers.ms-windows. But I doubt it is, so you might
want to check out comp.infosystems.www.servers.* where * is replaced by
whatever is appropriate.
It may well be that configuration of the browser can cause variations in this
misbehavior. But it can be prevented by configuration of the server. If it
can't you should change server platforms.
--
Don Roby
droby@copyright.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 04 Nov 1998 15:07:17 GMT
From: dzuy@my-dejanews.com
Subject: Re: PERL/UNIX newbie wants to multiprocess in his first script *LAUGH*
Message-Id: <71pqj4$tl9$1@nnrp1.dejanews.com>
In article <01be078f$94fbcbc0$7f02a8c0@pc256.mdsi.bc.ca>,
"Stephen Moore" <smoore@mdsi.bc.ca> wrote:
> I am fairly experienced with C/C++ for the PC environment, but am
> completely new to PERL and the UNIX environment.
>
> I am trying to write a PERL script that must execute multiple processes in
> the background, each generating a huge array of strings which must be
> passed back to the foreground process for processing (each huge array is
> timestamped and processed by queue).
>
> I do not want to use files. I want to keep it all in memory. I got fork
> and signals working fine but not message queues, shared memory, semaphores,
> and cannot really see a straight forward solutions.
>
> In a WIN32 environment I would just spawn multple threads each gathering
> the data and then plugging them into shared variables with a few synch
> objects to help.
>
> Any way to implement shared variables with a simple fork to assist? I
> tried:
>
> $A = 0;
> $P = \$A;
> if (fork == 0)
> {
> ${$P} = 1;
> exit(0);
> }
You've modified the child's variable.
> wait();
> print $A;
>
You want to print the parent's variable. Share memory is more of a UNIX
question, not particularly Perl. Read man page on share memory on your
UNIX system.
> and hoped it would print 1 but it printed 0. :( thought maybe references
> were pointers and that they wouldnt be adjusted...
>
> Any help appreciated.
>
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 4 Nov 1998 16:17:36 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: PERL/UNIX newbie wants to multiprocess in his first script *LAUGH*
Message-Id: <F1wnxC.BGt@world.std.com>
"Stephen Moore" <smoore@mdsi.bc.ca> writes:
>I am trying to write a PERL script that must execute multiple processes in
>the background, each generating a huge array of strings which must be
>passed back to the foreground process for processing (each huge array is
>timestamped and processed by queue).
How about using a pipe() to pass the data between the processes. You
use it like a file, but its really just being pased between the childs
memory to the kernels memory and from there to the parent. (or
reversed, depending on the direction of the pipe)
See the perlipc man page for details.
$A = 0; $A = 0;
$P = \$A;
if (fork == 0) unless (open KID, '-|')
{ {
${$P} = 1; print "1\n";
exit(0); exit 0;
} }
$A = <KID>;
wait(); close KID or die "Error running child: $!\n";
print $A; print $A;
>and hoped it would print 1 but it printed 0. :( thought maybe references
>were pointers and that they wouldnt be adjusted...
When you fork(), you start an entirely different process, with its own
unique memory space. The child has its own $A, and its own $P, and
they start as copies of the parent's, but changes are not reflected in
the original.
--
Andrew Langmead
------------------------------
Date: Wed, 04 Nov 1998 10:56:20 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <36407924.DD7B8DC9@min.net>
Matthew Bafford wrote:
>
> You forgot:
> Intuition : 1
>
> I dunno how I learned it. Perl just seemed intuitively obvious to me.
> -- Larry Wall in <6ubeee$m64@kiev.wall.org>
I put it this way: "Larry didn't learn Perl, Perl learned Larry."
Actually, I left out Larry intentionally, since his experience with
learning (or larnin') Perl has little bearing on the teachability
of Perl. The Geek Code is cute, but this ain't the Geek Code.
John Porter
------------------------------
Date: Wed, 04 Nov 1998 16:21:08 GMT
From: glerat@igtech.fr
Subject: Problem with encrypting/decrypting files
Message-Id: <71putk$46l$1@nnrp1.dejanews.com>
Hello,
I am having a hard time using Perl's Crypt::DES interface for
encrypting/decrypting from/to one file.
Here is what my programm looks like. I think there is just a small mistake (in
the unpack function I guess), but I can't figure out which one.
#!/usr/bin/perl -I.. -w
use Crypt::DES;
my $key = pack("H*", "1234567812345678");
my $cipher = new Crypt::DES $key;
$filetocrypt = "/home/sgdl/upload/plaintext.txt";
$ciphertext = "/home/sgdl/upload/ciphertext";
$uncrypted = "/home/sgdl/upload/uncrypted";
print "On chiffre...\n";
open (FICHIER,"$filetocrypt") or die "Can't open $filetocrypt: $!\n";
open (CRYPT,">$ciphertext") or die "Impossible d'ouvrir $ciphertext en
icriture: $!.\n";
open (UNCRYPT,">$uncrypted") or die "Impossible d'ouvrir $uncrypted en
icriture: $!.\n";
while (read FICHIER, $buffer, 8) {
my $in = pack("H16", $buffer);
my $chiffre = unpack("H16",$cipher->encrypt($in));
#$out = pack("H*", $chiffre);
$out = pack("H16", $chiffre);
if ($cipher->decrypt($out) eq $in) {
print "Good !\n";
#syswrite UNCRYPT, unpack("H16",$cipher->decrypt($out)), 8;
print UNCRYPT unpack("H16",$cipher->decrypt($out));
}
else {
print "Not good !\n";
}
print CRYPT $chiffre;
}
close (FICHIER);
close (CRYPT);
$decrypt = "/home/sgdl/upload/decrypt";
print "On dichiffre...\n";
open (FICHIER,"$ciphertext") or die "Impossible d'ouvrir $ciphertext en
lecture: $!.\n"; open (DECRYPT,">$decrypt") or die "Impossible d'ouvrir
$decrypt en icriture: $!. \n";
while (read FICHIER, $buffer, 16) {
print "Voici la phrase ` dichiffrer: $buffer\n";
my $out = pack("H16", $buffer);
my $dechiffre = unpack("H*",$cipher->decrypt($out));
print DECRYPT $dechiffre;
}
close (FICHIER);
close (DECRYPT);
The strange thing about all this is that we get into the printing of Good!,
so that the encryption/decryption should be ok. But when I write it back
(using unpack) I don't get the same stuff on the file. If anyone has any idea
about this, I would be very grateful.
Best regards,
Gilles
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 04 Nov 1998 11:59:08 +0100
From: Ralph SOBEK <sobek@irit.fr>
Subject: Proc-ProcessTable-0.04 (was Monitoring a child process.)
Message-Id: <auyapryb9f.fsf_-_@irit.fr>
>>>>> "SM" == Sean McAfee <mcafee@waits.facilities.med.umich.edu> writes:
SM> I see there's a Proc::ProcessTable module on CPAN, but it's currently only
SM> advertised to work on Linux, and it's alpha software, at that. You may be
SM> able to cannibalize the code to produce one that works on your particular
SM> OS.
I have got it , Proc-ProcessTable-0.04.tar.gz, running under
perl5.005.02 on Solaris 2.5 and sent the minor fixes to the author.
--
Dr. Ralph P. Sobek Disclaimer: The above ruminations are my own.
Ralph.Sobek@irit.fr Addresses are ordered by importance.
sobek@irit.fr If all else fails, try:
newsmaster@irit.fr, postmaster@irit.fr sobek@diva.eecs.berkeley.edu
Ph:(+33)[0]561558618 FAX:(+33)[0]561556258 http://www.irit.fr/SSI/~Ralph.Sobek/
===============================================================================
The truth about the Past is really all we have to guide us in the Present
-- Mary Benson (1964)
------------------------------
Date: Wed, 4 Nov 1998 08:39:19 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: reading a string in from a text file
Message-Id: <nuop17.apd.ln@flash.net>
No User (nouser@ucdavis.edu) wrote:
: OK, this is a pretty basic question, I am sure...please don't flame me I
: am new!
: I have text files that I want to pull information from.
Perl was created to handle just a job.
: There is a
: pattern that I can match that recurs through out...what I would like to
: do is this...every time it recognizes the pattern then begin reading
: when it sees a particular character and stop when it reads another.
Can the "start" and "stop" characters be on different lines?
The solution could be significantly different base on the answer
to that question.
Since you didn't specify that, you have to take what you get.
You're going to get a solution based on the answer being "No"
(because it is easier to do, heh heh).
: How can I set up the read function to do this?
read() is likely not the Right Tool For the Job.
: From what I have learned
: it reads a fixed number of characters.
Right. If it reads a fixed number and you don't want to read a
fixed number, then consider some other tool in Perl's arsenal ;-)
: Ex: I want it to read into a string that is in between the * characters
: after it matches the pattern /myptrn/
: dasflh myptrn fdfa * xacto nife * dfsdf
: in this example I would want to be left with a string var whose contents
: were " xacto nife "
Give up on *read*ing only what you want. You have to read it *all*
in order to see if it contains "what you want".
Read it all, but ignore everthing except what you want.
--------------------------
#!/usr/bin/perl -w
while (<DATA>) {
# while ( m/myptrn[^*]*\*([^*]*)/g ) { # all on one line
while ( m/myptrn # user specified "pattern"
[^*]* # zero or more non-asterisk characters
\* # a literal asterisk char
( # start remembering the matching chars
[^*]* # zero or more non-asterisk characters
) # stop remembering the matching chars
/gx ) {
print "found '$1'\n";
}
}
__DATA__
dasflh myptrn fdfa * xacto nife * dfsdf
Give up on *read*ing only what you want. You myptrn to read it *all*
--------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 4 Nov 1998 09:10:09 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: redirect output
Message-Id: <hoqp17.1td.ln@flash.net>
Warren Miller (wmiller@mars.cs.unp.ac.za) wrote:
: This program works but at the moment all it does it print the ouput of a
: webpage to the screen.
: How would I get the info that prints to the screen into a variable?
You put it into a variable (assignment) instead of print()ing it.
: #!/usr/local/bin/perl
You have a bug on that line.
You are missing the -w switch.
: use IO::Socket;
: $host="mars.cs.unp.ac.za";
: $document="index.html";
: $remote = IO::Socket::INET->new(Proto =>"tcp",
: PeerAddr => $host,
: PeerPort => "http(80)",
: );
: $remote->autoflush(1);
: print $remote "GET $document HTTP/1.0\n\n";
$whole_thing = "GET $document HTTP/1.0\n\n";
: while (<$remote>) {print} #This is the problem area
while (<$remote>) {$whole_thing .= $_}
: close $remote;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 04 Nov 1998 16:22:37 GMT
From: ronald_f@my-dejanews.com
Subject: Using a tied hash as a class member - please help
Message-Id: <71pv0d$47g$1@nnrp1.dejanews.com>
Can someone help me with this? I get the error message
untie attempted while 1 inner references still exist at ./pt2 line 17.
wenn trying to untie a reference that is stored as a member in some class.
I believe to understand what this message means in general, but I fail to
see how it applies to my case. This is a simplified version of my program.
I use Perl 5.004 to run it:
#!/usr/local/bin/perl -w
package Demo;
use strict;
use Fcntl;
use NDBM_File;
sub _h { return shift->{_hash}; }
# simulate "Demo->new" for this small example
my $self = { _hash => {} }; # Real application has other members as well
bless $self,"Demo";
(tie(%{$self->_h}, "NDBM_File", "dh.db", O_RDWR|O_CREAT, 0640)) or die;
if(tied %{$self->_h})
{
untie %{$self->_h}; # At this point the error occurs
}
--
Ronald Fischer <ronald_f@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 04 Nov 1998 08:07:44 -0800
From: Ed Young <eyoung_3@earthlink.net>
Subject: Verify secure web page is up
Message-Id: <36407BD0.8F160D12@earthlink.net>
Does anyone have any examples of perl code that verify a web page that
is secure?
I imagine using something with module LWP, I have to authenticate with a
username
and password and check the page is still available, any suggestions are
appreciated.
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4147
**************************************