[11726] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5326 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 8 04:07:40 1999

Date: Thu, 8 Apr 99 01:00:21 -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, 8 Apr 1999     Volume: 8 Number: 5326

Today's topics:
    Re: =~tr / / /; problem (Larry Rosler)
    Re: =~tr / / /; problem (Bart Lateur)
        better way to write this script ? (Mike Mckinney)
        book: perl modules by Eric Foster-Johnson (Peter Bismuti)
    Re: buggy counter? (Larry Rosler)
    Re: Can you stepthrough a Perl program? apriya@my-dejanews.com
        DEBUGGING PERL WITH EMBEDDED INTERPRETER apriya@my-dejanews.com
    Re: DEBUGGING PERL WITH EMBEDDED INTERPRETER (Ilya Zakharevich)
        DNS server implimented in Perl? <robertson@rocketmail.com>
    Re: DNS server implimented in Perl? (Michael Fuhr)
    Re: duplicate checker (Larry Rosler)
    Re: Dyn-IP "wanna be" 1-liner <SpamMeNOT.3pound@iname.com>
        How to pass parameters for perl programs under ActivePe agniora@usa.net
        HTTP_REFERER blazek@sisblansko.cz
    Re: HTTP_REFERER (Larry Rosler)
    Re: Large hash tables rehash hook, gc hook (Ilya Zakharevich)
    Re: Perl as a first programming language - suitability, (Bart Lateur)
    Re: Perl calls PGP <rra@stanford.edu>
        Stat::mode? bitwise operator? (Peter Bismuti)
        String manipulation <moab@emirates.net.ae>
    Re: String manipulation (Larry Rosler)
    Re: unexpected file test behaviour (Tad McClellan)
    Re: using "require example.cgi" on NT <indexfinger@usa.net>
    Re: verifying programs can execute (Tad McClellan)
    Re: Which text editor should I use <robertson@rocketmail.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 7 Apr 1999 22:00:33 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: =~tr / / /; problem
Message-Id: <MPG.1175d7ceb80ac937989864@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <x73e2bu511.fsf@home.sysarch.com> on 08 Apr 1999 00:09:46 -
0400, Uri Guttman <uri@home.sysarch.com >says...
> >>>>> "G" == George  <fred222@mauimail.com> writes:
> 
>   G> I just thought I'd explain a little more.  The tr/// operator is
>   G> the "transliterate" operator.  It lets you, for instance, switch
> 
> s/transliterate/translate/
> 
> transliterate means spelling a word in one human language so it sounds
> like one in another, e.g. almost anything you see written using english
> syllables from chinese or hebrew (my name being transliterated from
> hebrew).

I hate to disagree with my respected co-author, but you've got this 
wrong.  Either that, or so do I and so do the authors of the Perl docs.  
This is from perlop:

   tr{}{}    Transliteration

and similarly for the entries in perlfunc:

   tr/// 
       The transliteration operator. Same as y///. See perlop.

To trans*liter*ate means to change letters, which is what tr/// does.  
As do your natural-language examples.

>   G> A's to letter B's, and all the B's to A's (this isn't possible with the
>   G> s///, or substitute, operator).
> 
> as larry showed, it is possible with s/// but slower and clumsier.

I thought one of the problems might be the conditional, so I replaced it 
with a hash lookup (the hash being initialized outside the benchmark 
loop).  There was no speed difference.  Further benchmarking shows the 
time about evenly split between the regex and the substitution, if any.

>                 t///
> is meant just for that simple function and to do it fast. you actually
> see many newbies doing things with s/// that would be better with t///
> like squeezing multiple spaces to one, etc.

Not only newbies.  Also people who answer questions on this list.  But 
maybe those sets aren't as disjoint as they should be.  :-)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 08 Apr 1999 07:56:52 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: =~tr / / /; problem
Message-Id: <371460fe.4254765@news.skynet.be>

George wrote:

>I just thought I'd explain a little more.  The tr/// operator is the
>"transliterate" operator.  It lets you, for instance, switch all the letter
>A's to letter B's, and all the B's to A's (this isn't possible with the
>s///, or substitute, operator).

	%transliterate = ( A => 'B', B => 'A');
	s/([AB])/$transliterate{$1}/g;

But, tr/// is easier (and probably faster).

	Bart.


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

Date: Thu, 08 Apr 1999 07:02:23 GMT
From: mike@mike.local.net (Mike Mckinney)
Subject: better way to write this script ?
Message-Id: <slrn7gol19.36c.mike@mike.local.net>

I'm just getting started again with Perl, and am trying to write a simple
script to calculate some formulas for me. What I was hoping is that some
people here on the newsgroup could give me some pointers on trimming the
script down, or just improving the style a bit.
Also, I'm having a problem with the <<here document, in that I can't seem to
get rid of the last newline, so that the users input is on the same line as
the final : .

Below is the full script...Any advice or suggestions for trimming it down,
improving the style, or fixing the <<here doc would be greatly appreciated.
If posting entire programs to the newsgroup is frowned upon, I apologize in
advance, and will certainly refrain from doing so in the future if this is the
case.

TIA

#!/usr/bin/perl -w
use diagnostics; 

# Simple program to calculate proportional band, authority, or % outside air
# being delivered to a given area.
# Still need to add a function for graphing the reset schedule to check
# controller calibration

{
print <<End_Of_Options;
Calculate: (P)roportional band, (T)hrottling range, (A)uthority,
(V)entilation, or (Q)uit :
End_Of_Options
chomp( $choice = <STDIN> );
if( $choice =~ /^P/i ) {
	print "Set the proportional band at : ",PROPORTIONAL_BAND(),'%',"\n" x 2;
} elsif( $choice =~ /^t/i ) {
	print "The throttling range is : ",THROTTLING_RANGE(),"degrees","\n" x 2;
} elsif( $choice =~ /^A/i ) { 
	print "Set the controller for : ",AUTHORITY(),'%',"\n" x 2;
} elsif( $choice =~ /^V/i ) {
	print "The amount of outside air is : ",VENTILATION(),'%',"\n" x 2;
} else {
	exit if $choice =~ /^Q/i;
}
redo;
}
sub THROTTLING_RANGE {
	print "Enter the proportional band : ";
	chomp( my $pb = <STDIN> );
	print "Enter the sensor span : ";
	chomp( my $span = <STDIN> );
	return( ($pb * $span) / 100 );
}
sub PROPORTIONAL_BAND {
	print "Enter the desired throttling range, in degrees : ";
	chomp( my $tr = <STDIN> );
	print "Enter the sensor span : ";
	chomp( my $span = <STDIN> );
	return( ($tr / $span) * 100 );
}
sub AUTHORITY {
	print "Enter the primary sensor span : ";
	chomp( my $primary_span = <STDIN> );
	print "Enter the reset sensor span: ";
	chomp( my $reset_span = <STDIN> );
	print "Enter the primary sensor delta \"T\" + throttling range : ";
	chomp( my $primary_delta = <STDIN> );
	print "Enter the reset sensor delta \"T\" : ";
	chomp( my $reset_delta = <STDIN> );
	my $span_total = $primary_span / $reset_span ;
	my $delta_total = $primary_delta / $reset_delta ;
	return( ($span_total * $delta_total) * 100 );
}
sub VENTILATION {
	print "Enter the Return Air temp : ";
	chomp( my $RA_Temp = <STDIN> );
	print "Enter the Mixed Air temp : ";
	chomp( my $MA_Temp = <STDIN> );
	print "Enter the Outside Air temp : ";
	chomp( my $OA_Temp = <STDIN> );
	my $rama = $RA_Temp - $MA_Temp ;
	my $raoa = $RA_Temp - $OA_Temp ;
	return( ($rama / $raoa) * 100 );
}

-- 
mikemck@austin.rr.com



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

Date: 8 Apr 1999 06:53:32 GMT
From: bismuti@cs.fsu.edu (Peter Bismuti)
Subject: book: perl modules by Eric Foster-Johnson
Message-Id: <7ehjpc$hvg$1@news.fsu.edu>


Has anyone read the book "Perl Modules" by Eric Foster-Johnson :

   Paperback - 400 pages Bk&Cd Rom edition (March 1998) 
   IDG Books Worldwide 
   ISBN: 1558515704 
   Dimensions (in inches): 1.20 x 9.28 x 7.45 

Is it worth buying??



Also, announcing The Perl CD Bookshelf:

By O'Reilly & Associates, Inc.
1st Edition May 1999 (est.)
1-56592-462-2, Order Number: 4622
N/A, $59.95 (est.), Features CD-ROM

Perl programmer alert! Six bestselling O'Reilly Animal Guides are now 
available on CD-ROM, easily accessible with your favorite Web browser: 

Perl in a Nutshell
Programming Perl, 2nd Edition
Perl Cookbook 
Advanced Perl Programming
Learning Perl
Learning Perl on Win32 Sytems. 

As a bonus, the new hardcopy version of Perl in a Nutshell is also included. 



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

Date: Wed, 7 Apr 1999 22:20:55 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: buggy counter?
Message-Id: <MPG.1175dc8e6995289f989865@nntp.hpl.hp.com>

In article <1dpwuk7.7cn9rh10k2036N@p75.block2.tc1.state.ma.tiac.com> on 
Thu, 8 Apr 1999 00:14:05 -0400, Ronald J Kimball 
<rjk@linguist.dartmouth.edu >says...
 ...
> Solution: open the file _once_, for read _and_ write access.  Lock the
> file.  Read.  Seek to the beginning.  Write.  Close _without_ unlocking
> -- closing the file unlocks it for you.

Just for the record (though it is irrelevant for an incrementing 
counter, of course), proper rewriting of the file entails a 'Truncate.' 
step before the 'Write.'

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 08 Apr 1999 07:30:50 GMT
From: apriya@my-dejanews.com
Subject: Re: Can you stepthrough a Perl program?
Message-Id: <7ehlva$oa4$1@nnrp1.dejanews.com>

U dont need to User all those buttons.. All u need to do is put -d switch in
your perl script..

e.g.

#!/usr/local/perl -d

# write ur code here..
----------------------------

When U run this script.. Step-by-step execution will be done....
I hope it works..

- Abhishek

In article <370AA575.FE37C521@dynamite.com.au>,
  newman@dynamite.com.au wrote:
> I am new to Perl programming but have some experience with using Borland
> C++. i am using MacPerl (MacOS) and have been look for the 'step
> through' and 'display register' buttons but to no avail. This is very
> useful features for debugging purposes. Anyone suggest how I can step
> through my Perl programs?
>
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 08 Apr 1999 05:30:04 GMT
From: apriya@my-dejanews.com
Subject: DEBUGGING PERL WITH EMBEDDED INTERPRETER
Message-Id: <7ehet1$hr9$1@nnrp1.dejanews.com>

The -d switch in perl allows line by line execution and debugging when run on
the command line.

I am using an embedded perl interpreter:

main()

{
  /*
   invoke perl interpreter
  */

  /*
    parse a perl file mytest.pl
  */

  /*
    invoke a  subroutine 'mytestsub' here
   */

  /*
    destroy perl interpreter
   */

}


******
File mytest.pl
******

#!/usr/local/bin/perl -d

sub myetestsub{

print "my test subroutine called.\n";
print "my test subroutine say 4*4 == ";
$x = 4*4;

print "$x\n";
print "bye\n";
}


The problem is that the program when excuted, does not show line by line
execution... It seems that -d switch is not working at all...

What may be the possible problem?? Is there any way out..??

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 8 Apr 1999 06:11:03 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: DEBUGGING PERL WITH EMBEDDED INTERPRETER
Message-Id: <7ehh9n$i7o$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to 
<apriya@my-dejanews.com>],
who wrote in article <7ehet1$hr9$1@nnrp1.dejanews.com>:

> I am using an embedded perl interpreter:
> 
> main()
> 
> {
>   /*
>    invoke perl interpreter
>   */

> The problem is that the program when excuted, does not show line by line
> execution... It seems that -d switch is not working at all...

Hmm, I did not see anything bug comments inside your main().  No
wonder the debugger is not called.

Did you put "-d" into perl_argv (sp)?

Ilya


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

Date: Thu, 08 Apr 1999 01:36:35 -0500
From: Andy Robertson <robertson@rocketmail.com>
Subject: DNS server implimented in Perl?
Message-Id: <370C4E73.FB4B0B39@rocketmail.com>

Does anyone know of any DNS servers implimented in Perl, or any modules
capable of being used
as a DNS server?  This seems like a fairly useful tool to have.

I have a peculiar need.  I need to have mail servers forward failed mail
to another
server, without actually rejecting it.  This second server, will try to
deliver the message
over a different ISP, possibly getting around any networking issues that
is preventing the
mail from getting through.

The ideal solution would be to impliment this in the sendmail rulesets. 
However, the company
I work for does not like sendmail.

The idea suggested to me by my employer, was to set up a DNS server that
appends an extra
mail exchange to a mail exchange list, which would actually be the next
server in the
chain.  I have been searching through the perl servers and modules,
looking for DNS services.
I found a DNS client.  But, I have been unable to find any NameD modules
or servers.  Does
anyone know of any of these?  How hard would it be to impliment, a two
or three hour task
for proof of concept, or several days to even get it to work?  I have
seen httpd servers
implimented in perl...

Thanks!  I would appreciate any replies to this newsgroup or my email.
      andy
-- 
Let us read and let us dance.  Two things which will never
bring any harm to this world.  Voltaire


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

Date: 8 Apr 1999 01:08:27 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: DNS server implimented in Perl?
Message-Id: <7ehklb$jqe@flatland.dimensional.com>

Andy Robertson <robertson@rocketmail.com> writes:

> Does anyone know of any DNS servers implimented in Perl, or any modules
> capable of being used
> as a DNS server?  This seems like a fairly useful tool to have.

lbnamed is written in Perl:

    http://www.stanford.edu/~riepel/lbnamed/

You could write a nameserver with the Net::DNS module, though you'd
have to work out the details yourself.  I've been meaning to show an
example of a nameserver in a future version of Net::DNS.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


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

Date: Wed, 7 Apr 1999 23:26:40 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: duplicate checker
Message-Id: <MPG.1175ebf3dc4af819989866@nntp.hpl.hp.com>

[Posted and a copy sent to Tom Christiansen.]

In article <370B8DA7.D6F18BAA@mail.cor.epa.gov> on Wed, 07 Apr 1999 
09:53:59 -0700, David L. Cassell <cassell@mail.cor.epa.gov >says...
> Larry Rosler wrote:
 ...
> > `perldoc -q array` would have produced the FAQ with 'intersection' in
> > its title (among several others), but even that wouldn't have answered
> > the problem without knowing what 'intersection' means.
 ...
> True.  Are you going to submit an addendum to that particular
> FA Question, so that there are keywords that would be found by someone
> without any exposure to set theory?

Intersection seems easy -- I would add a definition in parentheses to 
the title of the FAQ, with the word 'common' to search for:

How do I compute the difference of two arrays?  How do I compute the 
intersection of two arrays (the elements in common)?

Difference is harder -- a nontrivial synonym isn't obvious to me.  "The 
elements in one array but not in the other" doesn't add any search 
terms.

(On a related note -- the difference computed in the FAQ is the 
'symmetric difference':  A and not B or B and not A.  The difference of 
two sets, A - B, is 'A and not B'.  Maybe the term 'symmetric 
difference' should be used in the title.  But that might really scare 
away someone unfamiliar with set theory.  The term certainly should be 
used in the body of the FAQ.)

I hope Tom Christiansen, the owner of the FAQs, will take a look at 
these minor issues.  I have mailed him a copy of this post.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 8 Apr 1999 02:13:32 -0500
From: "Jay J" <SpamMeNOT.3pound@iname.com>
Subject: Re: Dyn-IP "wanna be" 1-liner
Message-Id: <HCYO2.713$s4.4815384@rsnws01.mn.mediaone.net>

Woops!

Okay - it was very late when I hacked that together.. so it's a
"gateway/p-t-p" finder, not an IP finder.

In my delusion I was looking for something that loaded up quicker on my
lowly dx2-66 w/8mb of ram, but as you pointed out - it's easy enough to grab
it from ifconfig ..

I'd image an IP can be 1 digit, so therefore \d*

Silly me,

-Jay

Matthew Bafford <dragons@scescape.net> wrote in message
news:slrn7gnupn.m2.dragons@dragons.duesouth.net...
> 7 Apr 1999 22:25:17 GMT -- Andrew Allen <ada@fc.hp.com>:
> -> Hmmm... I'm confused. Why do you need to "de-dupe" if you're going to
> -> use the first element anyways... looks like another '\.' crept in after
> -> the final "255". Also, couldn't the IP start with a single 1-9
> -> digit, needing '[1-9]\d*' instead of '[1-9]\d+'?
>
> *shrug* his code -- I barely even looked at it... :-)
>
> Yep, another \. slipped in.
>
> IPs could start with a single digit, I guess.  Never looked at the
> RFC, to tell you the truth.  Again, his code.
>
> Also, the -Mstrict doesn't work like I thought.  Not sure how that
> slipped by me.
>
> -> Unfortunately, I don't any 'route' output available, but it seems like
> -> you should be able to replace
>
> One of the lines:
>
> 216.98.0.30     0.0.0.0         255.255.255.255 UH    0      0        0
ppp0
>
> ->   map{/([1-9]\d*\.\d+\.\d+\.\d+)/}grep{/ppp/}map{split/s+/}
> ->
> -> with something like
> ->
> ->   /ppp[^s]*([1-9]\d*(?:\.\d+){3})/g
> ->
> -> (or maybe the 'ppp' is after, I don't know--are you really splitting
> -> on the letter 's'???). I guess these suggestions yield:
>
> perldoc perlre
>
> The \s is any whitespace.
>
> -> #!/usr/bin/perl -wl -Mstrict
> ->
print+(grep{!/(255\.){3}255/}`/sbin/route -n`=~/ppp[^s]*([1-9]\d*(?:\.\d+){3
})/g)[0];
>
> Doesn't do the same thing at all...
>
> $ perl ./andrew_huh
> 5.255.255.255
> $ perl ./matthew_huh
> 216.98.0.30
> $
>
> Really, if I was going to write the same thing, I'd probably do:
>
> #!/usr/bin/perl -w
> print "216.98.0.30\n";
>
> Since route doesn't give you your IP address, rather the address
> you're sending all your data to (ie: your ISP's).  Mine hasn't
> changed in about 2 years.
>
> If you want your IP address, you want the script to be short, and
> insist on using an external command, how about:
>
> #!/usr/bin/perl -w -n -l -000
> BEGIN{@ARGV='/sbin/ifconfig|'} next if !
> /^p/;print+(/((\d+\.){3}\d+)/gx)[0];exit
>
> or maybe:
>
> #!/usr/bin/perl -w -a -n -U -l -000
> BEGIN{@ARGV='/sbin/ifconfig ppp0|'}
> print+(/((\d+\.){3}\d+)/xg)[0];exit
>
> This also has the very great advantage of being a perfect block!
> Unfortunatly for this thread, it's not that obfuscated.
>
> Hope This Helps!
>
> -> Andrew
>
> --Matthew




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

Date: Thu, 08 Apr 1999 07:26:10 GMT
From: agniora@usa.net
Subject: How to pass parameters for perl programs under ActivePerl?
Message-Id: <7ehlmd$o6r$1@nnrp1.dejanews.com>

I am using ActivePerl on WinNT platform. But everytime i have to run a script
i have to type perl myprog.pl but i need to pass some parameters to my
program, adding parameters to the above line doesnt work cause it gets taken
as an argument to the perl program not myprog.pl does anyone know any
workaround to this?

thanks
Nayeem (agniora)

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 08 Apr 1999 06:00:04 GMT
From: blazek@sisblansko.cz
Subject: HTTP_REFERER
Message-Id: <7ehgl2$j4t$1@nnrp1.dejanews.com>

Is there a way how to say my CGI script to set HTTP_REFERER
to a value I wish?
Thank you very much for help

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 7 Apr 1999 23:59:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: HTTP_REFERER
Message-Id: <MPG.1175f3babff70145989868@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7ehgl2$j4t$1@nnrp1.dejanews.com> on Thu, 08 Apr 1999 
06:00:04 GMT, blazek@sisblansko.cz <blazek@sisblansko.cz >says...
> Is there a way how to say my CGI script to set HTTP_REFERER
> to a value I wish?

For what purpose?

The server *may* set $ENV{HTTP_REFERER} to be read by the CGI program, 
and the CGI program may set $ENV{HTTP_REFERER} to be read by any child 
program it spawns.

But none of this affects the browser.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 8 Apr 1999 06:07:29 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Large hash tables rehash hook, gc hook
Message-Id: <7ehh31$i6j$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to 
<alanr@mpi.com>],
who wrote in article <7egu31$48v$1@nnrp1.dejanews.com>:
> I'm working with large hash tables. I've preallocated space for the tables I
> know will be big, but have a feeling that I am missing something somewhere.
> Is there any way I can get a function called when a hash table is to be
> resized? I'd prefer to be called any time any hash table is resized so I can
> quickly detect expensive rehashes.
> 
> Along these lines, I am concerned about how much memory perl is using and
> reclaiming. Ideally I would like to be called before and after the gc, and be
> able to call a function that reported perl's gc statistics - how much memory
> is in use, how much garbage was collected, etc, so that I can see if the
> memory I expect will be reclaimed actually is.
> 
> Any suggestions?

Please report why

       perldoc perldebug

did not help you.

Ilya


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

Date: Thu, 08 Apr 1999 07:56:54 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Perl as a first programming language - suitability, good books ?
Message-Id: <371360e3.4228456@news.skynet.be>

Jonathan wrote:

>Maybe Python doesn't belong to that club. *Probably* it doesn't. But I do
>understand that it's "verbose" and that it has a high ratio of people
>writing research papers about it to people using it for solving real
>problems. These I take as bad signs. 

	:-)

>Oh, and I just junk email from some
>silly ass (no one who posted here) telling me that Perl is "good for
>nothing" and that my friend  should learn Python instead. This doesn't
>reflect badly on Python at all, but this sort of over defensiveness normally
>means a language is an economic dead goose, and hey, we've all got to eat.

Well... I wouldn't go that far. I don't use Python at all, but I *did*
try it, and it's not bad at all. It feels a bit like Lisp (that's a good
thing) but with an ordinary language syntax (like Basic). Huh... isn't
that Logo? ;-)

I don't use it, well, because there is Perl. I like Perl better. And
when I tried, in Python, printing numbers 1 to 100 as an array, I could
just FEEL the delay between start of construction of the array, and the
printout. This would have taken just a few milliseconds in Perl, on the
same platform. That means to me that Python is relatively slooooow.

But still, as a learning language, it's not half bad.

	Bart.


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

Date: 07 Apr 1999 22:42:27 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl calls PGP
Message-Id: <yllng3vfb0.fsf@windlord.stanford.edu>

Donny Widjaja <donny@impulsesoftware.com> writes:

> I had the same problem with you, and I think we can use Expect.pm.  I
> have not try this, so I don't know if it is going to work or not.  First
> you can download Expect.pm from the CPAN, and the Expect.pm requires
> IO::Tty and IO::Stty from CPAN.

This message was also posted to comp.lang.perl.modules and I answered it
there; to repeat for this group, PGP has a batch mode designed for doing
things noninteractively, and that's what this person should be using.

If they're only doing generation and checking of detached signatures, they
can use my PGP::Sign module (on CPAN) to do all the dirty work for them.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 8 Apr 1999 07:19:47 GMT
From: bismuti@cs.fsu.edu (Peter Bismuti)
Subject: Stat::mode? bitwise operator?
Message-Id: <7ehlaj$iii$1@news.fsu.edu>


 Could someone please explain to me how to find out whether a file
 is a regular file, directory and whether or not it is a sym link 
 using the mode value returned from stat (or better yet refer me to some
 documentation)?  (I realize there are built-in operators (-d, -f, ...),
 I am interested in the more generic unix way of doing it.)

 Also, it has been suggested that in the statments:
 
    if (mode &  0111) 
    if (mode & 07777) 
 
 the numbers 0111 and 07777 are interpreted as decimal and not octal,
 is this correct?  These numbers make sense to me in octal but don't
 as decimal.  0111 as decimal would translate to: 
 
    0000 000 001 101 111 
 
 in binary. I don't see what this number has to do with a file being
 executable, it seems random to me.  I think the number is octal 
 and should give:
 
    0000 000 001 001 001 
 
 which makes sense if you're testing to see if a file is executable.

 Which is correct?
 
 Thanks as always!



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

Date: Thu, 08 Apr 1999 05:25:17 GMT
From: Nabil Courdy <moab@emirates.net.ae>
Subject: String manipulation
Message-Id: <7ehejn$hnm$1@nnrp1.dejanews.com>



if $gccport="ED123", how do I get at each element, as in
E or D. I want to get the hex equivalence of each element.
i.e. hex(E), hex(D), hex(1), ...



Nabil Courdy
mooab@emirates.net.ae (Sub moab for mooab)
======================

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 7 Apr 1999 23:50:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: String manipulation
Message-Id: <MPG.1175f189328c2eb989867@nntp.hpl.hp.com>

[Posted and a courtesy copy sent to someone who may be the first poster 
from the Arab Emirates!]

In article <7ehejn$hnm$1@nnrp1.dejanews.com> on Thu, 08 Apr 1999 
05:25:17 GMT, Nabil Courdy <moab@emirates.net.ae >says...
> if $gccport="ED123", how do I get at each element, as in
> E or D. I want to get the hex equivalence of each element.
> i.e. hex(E), hex(D), hex(1), ...

Something like this is one way to do what I think you want:

print map { hex, "\n" } split '' => $gccport;

14
13
1
2
3

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 7 Apr 1999 20:42:20 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: unexpected file test behaviour
Message-Id: <c1uge7.dn3.ln@magna.metronet.com>

Steven Smith (steves@wco.com) wrote:
: The following gives "Use of uninitialized value at line 4." error if
                                                              ^^^^^

    It is a warning.


: file doesn't exist.  What gives?
  ^^^^^^^^^^^^^^^^^^
  ^^^^^^^^^^^^^^^^^^

:      1  #!/usr/local/bin/perl -w
:      2  foreach $file (@ARGV) {
:      3      print "$file:";
:      4      print int (-e $file);


   Looks like a File Test operator there on line 4.

   Better go have a look at what it says about the operator
   that is giving you trouble in the standard Perl docs
   that are already installed on your hard drive...


   From perlfunc.pod:

      "Unless otherwise documented, it returns C<1> for TRUE 
       and C<''> for FALSE, or the undefined value if the 
       file doesn't exist."
       ^^^^^^^^^^^^^^^^^^
       ^^^^^^^^^^^^^^^^^^


   Would you be surprised to get that _warning_ message from 
   this one-line Perl program?

      print int undef;



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 08 Apr 1999 07:54:37 GMT
From: "IndexFinger.com" <indexfinger@usa.net>
Subject: Re: using "require example.cgi" on NT
Message-Id: <1hZO2.472$zE3.12517@typhoon.nycap.rr.com>

> Where is the exampl.cgi?

Here is the exact code:

require 'D:\home\nt133249\bigtalker\config.cgi';



>is the directory where it resides in perl's path?

What do you mean? I call on config.cgi from a program called admin.cgi,
which is in the same directory. When I use the below code, I get an error:

require 'config.cgi';

I don't get an error when I use it on Unix, just on NT.


--
==================================================
BigTalker - http://www.bigtalker.com
Bulletin board software - faster than the UBB





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

Date: Wed, 7 Apr 1999 20:22:20 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: verifying programs can execute
Message-Id: <srsge7.dn3.ln@magna.metronet.com>

Christian M. Aranda (christianarandaOUT@OUTyahoo.com) wrote:

: #########################
: sub verify_programs {
: my ($program);


   You are strict about $program, but not the others?

   Danger Will Robinson!


:    $Tar = "/bin/tar";
:    $Rsh = "/bin/rsh";
:    $Ftp = "/bin/ftp";

:    foreach $program ($Tar, $Rsh, $Ftp) {


   Since the foreach() is the only place you use $program,
   you should limit its scope to the foreach (if you have
   a sufficiently modern perl).

   You don't need to put them into temporary variables. You
   can just put the paths as a list of stings:

      foreach my $program (qw(/bin/tar /bin/rsh /bin/ftp)) {

   But if this grew beyond a half dozen or so, I'd put

-----------------
my @programs = qw(
                   /bin/tar
                   /bin/rsh
                   /bin/ftp
                 );
-----------------

   somewhere near the top of the file (it is "config" info),
   and then just do:

      foreach my $program (@programs) {


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 08 Apr 1999 01:22:54 -0500
From: Andy Robertson <robertson@rocketmail.com>
Subject: Re: Which text editor should I use
Message-Id: <370C4B3E.30052453@rocketmail.com>

gabriel_john_cohen@my-dejanews.com wrote:
> 
> Hello,
> 
> I'm trying to learn PERL on a linux machine.  Which text editor should I use?
> 
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own

Use them all.  And, when you are completely frustrated with using them
all,
pick the one you found the least frustrating.

Good luck
     andy

-- 
Let us read and let us dance.  Two things which will never
bring any harm to this world.  Voltaire


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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