[11160] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4760 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 27 11:07:24 1999

Date: Wed, 27 Jan 99 08:00:21 -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, 27 Jan 1999     Volume: 8 Number: 4760

Today's topics:
        Compiling PERL5.005_02 on a Sun Ultra 2 w/o Solaris 2.6 <Peter.J.Messore.1@gsfc.nasa.gov>
    Re: Compiling PERL5.005_02 on a Sun Ultra 2 w/o Solaris <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Deleting duplicates in a text file (Randal L. Schwartz)
        dupes in Perl, being a dope dturley@pobox.com
    Re: dupes in Perl dturley@pobox.com
    Re: dupes in Perl (Tad McClellan)
    Re: How to change @INC path permenantly? <mark.c.hamlin@bt.com>
    Re: How to change @INC path permenantly? <mark.c.hamlin@bt.com>
    Re: How to change @INC path permenantly? <mark.c.hamlin@bt.com>
    Re: how to return multiple values in perl? (Steve van der Burg)
    Re: HTML files exported from Quark <jc@uwm-dev.gte.com>
    Re: indexing binary data (Andrew M. Langmead)
    Re: Is s///ge non-reentrent? Or did I find a bug? <tchrist@mox.perl.com>
    Re: Is s///ge non-reentrent? Or did I find a bug? (Ilya Zakharevich)
    Re: Is this possible? <anaas@funb.com>
        Newbie Question (cba)
    Re: Newbie question: writing file <tbriles@austin.ibm.com>
        Passing variables between two Perl scripts a_s_hearn@yahoo.com
    Re: Passing variables between two Perl scripts <tchrist@mox.perl.com>
    Re: Perl Criticism aqumsieh@my-dejanews.com
    Re: Perl Criticism (Larry Rosler)
    Re: Perl print ("....."); command problems <jc@uwm-dev.gte.com>
    Re: stat() interpretation (Andrew M. Langmead)
    Re: system function, Pros and Cons?? <jc@uwm-dev.gte.com>
    Re: system function, Pros and Cons?? (Ilya Zakharevich)
        that "runops ... undefined" thing from perlcc mk@weconnectyou.com
    Re: WANTED: Perl Programmer (London/UK) <williams@openmic.com>
    Re: What's the character? (Tad McClellan)
    Re: Wnt: Simple script to search & replace through a ba <mark.c.hamlin@bt.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 27 Jan 1999 10:25:48 -0500
From: "Peter J. Messore" <Peter.J.Messore.1@gsfc.nasa.gov>
Subject: Compiling PERL5.005_02 on a Sun Ultra 2 w/o Solaris 2.6 OS
Message-Id: <36AF2FF9.DF2D007C@gsfc.nasa.gov>

Our group just recently got a new Sun Ultra 2 which is running Solar 2.6
for the operating system. We want to put Perl on our system so we can
continue to run several of the WWW CGI utilities we've written. We've
been using the instructions in the INSTALL file and using all of the
defaults the configure shell suggests. However when it comes to issuing
the make command we get nothing but errors.

Has anyone out there built this release of Perl on their Sun Solaris
system? Any help would be appreciated.

- Peter



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

Date: 27 Jan 1999 16:34:19 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Compiling PERL5.005_02 on a Sun Ultra 2 w/o Solaris 2.6 OS
Message-Id: <83pv804tms.fsf@vcpc.univie.ac.at>

Re: Compiling PERL5.005_02 on a Sun Ultra 2 w/o
Solaris 2.6 OS, Peter
<Peter.J.Messore.1@gsfc.nasa.gov> said:

Peter> utilities we've written. We've been using the
Peter> instructions in the INSTALL file and using
Peter> all of the defaults the configure shell
Peter> suggests. However when it comes to issuing
Peter> the make command we get nothing but errors.

And these errors would be...what?  Oh, you didn't
tell us.  I'll take a stab though: you don't have a
C compiler on the box.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: 27 Jan 1999 07:32:38 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Deleting duplicates in a text file
Message-Id: <m1lnio3f55.fsf@halfdome.holdit.com>

>>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:

Larry> Posted twice within three minutes, with different Subjects and email 
Larry> addresses!  Bad...

Maybe we should change the subject to "deleting duplicates in the
newsgroup"...

:)

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Wed, 27 Jan 1999 15:12:54 GMT
From: dturley@pobox.com
To: lr@hpl.hp.com
Subject: dupes in Perl, being a dope
Message-Id: <78nadc$21v$1@nnrp1.dejanews.com>

[CC'd (hopefully) to LR]

Okay, this thread might get as long as topmind's. Apparently I was the only
one who found Larry Rosler's email reply and post to be condenscending. Fine.
I apologize to Larry, although I am sure he couldn't care less about what I
have to say. I apologize to the 'neighborhood' for wasting bandwidth.

My plea for no more responses to topmind went ignored, why not my spouting
off? :-)

Anyway, please direct further responses to me via email and let's get back to
Perl.

I'll go back to read-only mode.

sigh.

cheers, david
--
____________________________________
David Turley
dturley@pobox.com

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


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

Date: Wed, 27 Jan 1999 14:45:47 GMT
From: dturley@pobox.com
Subject: Re: dupes in Perl
Message-Id: <78n8qo$m6$1@nnrp1.dejanews.com>

In article <x7ww29s36y.fsf@home.sysarch.com>,
  Uri Guttman <uri@home.sysarch.com> wrote:
>so calm down, take a bottle of valium and let each
> contribute here as they wish.
>

apology posted. can't find the valium. :-)

--
____________________________________
David Turley
dturley@pobox.com

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


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

Date: Wed, 27 Jan 1999 09:12:00 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: dupes in Perl
Message-Id: <0can87.7h.ln@magna.metronet.com>

dturley@pobox.com wrote:
: Larry Rosler send in email:

: In reply to your message entitled "Re: Deleting dupes with Perl":
: >[Posted and a courtesy copy mailed.]
: >
: >In article <78l8t4$dbh$1@nnrp1.dejanews.com> on Tue, 26 Jan 1999
: >20:34:45 GMT, dturley@pobox.com <dturley@pobox.com> says...
: >> In article <78km8q$ss6$1@nnrp1.dejanews.com>,
: >>   jxdub@my-dejanews.com wrote:
: >> > but now I need to delete the
: >> > duplicates...  Could anyone tell me a good way to do this? The file would
: >>
: >> here's one way. put the file into @out, sort it, then print it.
: >>
: >> @sorted = sort @out;
: >> $prev = 'nonesuch';
: >> @n_out = grep($_ ne $prev && ($prev = $_), @sorted); #remove duplicates
: >
: >This also deletes entries whose value is false, such as '0', as is
: >mentioned in the FAQ you copied this from.  Why not simply aim the
: >questioner to the FAQ (as two of us have already), so he can get the
: >whole story?

[snip quoted signature, which should never be quoted]

: Well, excuse the fuck out of me.
[snip]
: Also, dickhead, 
[snip]


   You kiss your mother with that mouth?

   Work on your vocabulary a bit, then you will be able to
   communicate without having to result to vulgarity.

   When I interview job candidates, I always search the 'net for
   their names. I expect others do the same.

   It will likely be Not So Good if your posting
   shows up in the hit list...

   Or maybe you are independently wealthy and are therefore
   unconcerned with such things?


: Or are you  such an
: asshole all the time?


   Are you?


[ I know what happened here, I bet. I've done it myself.

  You followed up immediately after reading Larrys' article.

  I have similarly stepped on my di^H^H... on a part of my anatomy
  that is very painful to step on, in the past.

  I embarrass myself less often now that I have imposed a policy
  of waiting at least one hour before responding to posts/emails
  that anger me greatly.

  Try it! 
]


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


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

Date: Wed, 27 Jan 1999 15:31:47 +0000
From: Mark Hamlin <mark.c.hamlin@bt.com>
To: Ron Savage <Savage.Ron.RS@bhp.com.au>
Subject: Re: How to change @INC path permenantly?
Message-Id: <36AF3163.DA7D00EC@bt.com>

Ron,

I'm not 100% sure what you mean/how to do it.  Do I just make a standard unix
shell envroment variable in my shell startup with an export? ,,,,rather than
something specific to/ embedded in perl or a particular perl config file?

Thanks very much for your invaluable help, Mark


> Use the environment variable PERL5LIB to point to one or more dirs.
>
> --
>
>
> Work: mailto:mark.c.hamlin@bt.com
> Personal: mailto:mark@dimitrinet.demon.co.uk
>
> Please use you auto reply where possible to distribute to both mailboxes.





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

Date: Wed, 27 Jan 1999 15:31:07 +0000
From: Mark Hamlin <mark.c.hamlin@bt.com>
To: Ron Savage <Savage.Ron.RS@bhp.com.au>
Subject: Re: How to change @INC path permenantly?
Message-Id: <36AF313B.EC57E9F8@bt.com>

Ron Savage wrote:

I'm not 100% sure what you mean/how to do it.  Do I just make a standard unix
shell envroment variable in my shell startup with an export? ,,,,rather than
something specific to/ embedded in perl or a particular perl config file?

Thanks very much for your invaluable help, Mark


> Use the environment variable PERL5LIB to point to one or more dirs.
>
> --
>
>
> Work: mailto:mark.c.hamlin@bt.com
> Personal: mailto:mark@dimitrinet.demon.co.uk
>
> Please use you auto reply where possible to distribute to both mailboxes.





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

Date: Wed, 27 Jan 1999 15:33:30 +0000
From: Mark Hamlin <mark.c.hamlin@bt.com>
To: Ron Savage <Savage.Ron.RS@bhp.com.au>
Subject: Re: How to change @INC path permenantly?
Message-Id: <36AF31CA.8A763766@bt.com>

Ron,

I'm not 100% sure what you mean/how to do it.  Do I just make a standard unix
shell envroment variable in my shell startup with an export? ,,,,rather than
something specific to/ embedded in perl or a particular perl config file?

Thanks very much for your invaluable help, Mark


> Use the environment variable PERL5LIB to point to one or more dirs.
>
> --
>
>
> Work: mailto:mark.c.hamlin@bt.com
> Personal: mailto:mark@dimitrinet.demon.co.uk
>
> Please use you auto reply where possible to distribute to both mailboxes.





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

Date: Wed, 27 Jan 1999 14:51:59 GMT
From: steve.vanderburg@lhsc.on.ca (Steve van der Burg)
Subject: Re: how to return multiple values in perl?
Message-Id: <78n8vi$4os@falcon.ccs.uwo.ca>

In article <78lv33$ved$1@nnrp1.dejanews.com>, scraig@my-dejanews.com wrote:
>A subroutine can return a list of references ( which are scalars ) to arrays
>and hashes. But then the referenced objects have to be global.

Nope.  A reference to an object that would have otherwise disappeared as it 
went out of scope keeps the object around as long as the reference is in 
scope.  Like this:
- - - - - -
#!/bin/perl
use strict;
sub make_em {
   my %h1 = ( a => 1, b => 2, c => 3 );
   my %h2 = ( d => 1, e => 2, f => 3 );
   return \%h1,\%h2;
}
my ($r1,$r2) = make_em();

print "$$r1{b}, $$r2{f}\n";
- - - - - - -

This prints
   2, 3
because, while %h1 and %h2 are out of scope by the time the "print" function 
executes, references to each ($r1 and $r2) are still in scope.

 ..Steve


Steve van der Burg
Technical Analyst, Information Services
London Health Sciences Centre
London, Ontario, Canada
Email: steve.vanderburg@lhsc.on.ca


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

Date: Wed, 27 Jan 1999 10:53:02 -0500
From: John Chambers <jc@uwm-dev.gte.com>
Subject: Re: HTML files exported from Quark
Message-Id: <36AF365E.76292B7C@uwm-dev.gte.com>

Eric Bohlman wrote:
> 
> David Buttrick <buttrick@sportingnews.com> wrote:
> : I am looking to parse some HTML documents.
> 
> Surprisingly, the best way to do that is to use HTML::Parser.

Well, that depends on whether you're really receiving HTML, or
a HTML-mimic that isn't legal HTML. On my last project, I did
start with HTML::Parser, and it worked just fine on the valid
HTML files that I fed it.  And then I started getting "HTML"
from Microsoft's FrontPage. All hell broke loose. Parser would
miss chunks of the text, and scramble others.  It turns out
that FrontPage doesn't actually produce legal HTML as defined
by the specs; it produces a parody of HTML (also called "HTML")
that was invented by the FrontPage developers.  Their attitude
is "Hey, it works just fine with IE, so what's the problem?"

Eventually, I had to write my own parsing routines.  I did
this in much less time than I had already sunk into trying
to liberalize HTML::Parser's idea of HTML's syntax.  Let's
face it; HTML isn't all that difficult for a proficient perl
programmer to handle. (It's a lot easier than grokking a big
chunk of elegantly-written OO code with complex, undocumented
data structures. ;-)

Handling a document that is a single line isn't at all hard,
either.  Perl has no problem with a single string that's a
megabyte long, until you run out of memory.  Here's a little
prototype script that I've used as the base of a couple of
HTML-chomping programs.  It casually accepts HTML that is
one long line.  Feed it some HTML and watch what it does.

$| = 1;
$intag = 0;
line:
    for $line (<>) {
    chunk:
        while ($line) {
            if ($intag) {
                if ($line =~ s/^([^>]*)>//) {
                    print "Atr: $1\n" if $1;
                    $intag = 0;
                    next chunk;
                }
                print "Atr: $line\n";
                next line;
            }
            if ($line =~ s/^<([^\s\r>]*)//) {
                # $1 contains an HTML tag that is now removed.
                # The tag's attributes and the '>' are still in $line.
                &tag($1);
                $intag = 1;
                next chunk;
            }
            # $line starts with a non-tag.
            if ($line =~ s/^([^<]*)//) {
                # $1 is a chunk of text.
                &txt($1);
                next chunk;
            }
            # $line contains no more tags.
            &txt($line) if $line;
            next line;
        }
    }
sub tag {
    local($t) = @_;
    print "Tag: $t\n";
}
sub txt {
    local($t) = @_;
    print "Txt: $t\n";
}

Of course, making sense of the HTML tags will take a bit longer.
In particular, you want to deal with !-- and SCRIPT tags first.
But your typical HTML-chomping program is usually only interested
in the contents of a few tags, so it's usually not all that
difficult a job.

(Note that I'm not criticising the author(s) of HTML::Parser
here. I've thought about how one might write a similar parser 
that not only handles a given language, but all vaguely similar
languages that anyone might come up with, and I have a lot
of sympathy.  But sympathy doesn't get the job done in the
Real World(TM), where Microsoft has discovered the Internet
and is busy tossing monkey wrenches into the works.  ;-)


BTW, what are the prospects for an HTML parser that can accept
all the bizarre illegalities that are appearing in the world
of commercial HTML editors?


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

Date: Wed, 27 Jan 1999 15:14:14 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: indexing binary data
Message-Id: <F684zq.1n7@world.std.com>

Edan Idzerda <edan@mtu.edu> writes:

>I had to break down and use C to make this work, but I want to believe
>that Perl could do it just as well.  I want to be able to read binary
>data into an unsigned char buffer, then index it char by char.

After reading the string into the buffer, use "split //, $buffer" or
to split it into an array of individual characters. Or another option
would be to leave it in the scalar use substr() to extract the
character you want.

But you might want to look over your overall design. Very often when
people are looking to split a string and deal with individual
characters, they can change their overall algorithm to use Perl's
other text manipulation features.

-- 
Andrew Langmead


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

Date: 27 Jan 1999 08:38:53 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Is s///ge non-reentrent? Or did I find a bug?
Message-Id: <36af330d@csnews>

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

:This is a multi-part message in MIME format.
:--------------785B4AC4617AED659C666F5F
:Content-Type: text/plain; charset=us-ascii
:Content-Transfer-Encoding: 7bit

Oh, please.  Must you?  That's just gratuitous silliness.  

In comp.lang.perl.misc, AAron nAAs <anaas@funb.com> writes:
:When an "s///ge" calls a routine which ultimately recurses back to the original
:command, things flip out with the original substitution. My guess is that the
:'g' is saving a static state which is lost when it is re-entered due to 'e'
:which allows functions to be called. 

Yes, that's right.  It's know to be not re-entrant.  And I believe
that this is not documented because we'd like to fix it someday.
Check with p5p.

:-=-=-=-=-=-
:[Attachment type=application/x-unknown-content-type-perlfile, name=unknown]
:-=-=-=-=-=-

Blech.  More MIME crud.  Just read in the file, ok?  Usenet is a text
medium, and that's a bogotic type anyway.

--tom
-- 
    The debate rages on: Is PL/I Bachtrian or Dromedary?


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

Date: 27 Jan 1999 15:55:19 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Is s///ge non-reentrent? Or did I find a bug?
Message-Id: <78nct7$24l$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Christiansen 
<tchrist@mox.perl.com>],
who wrote in article <36af330d@csnews>:
> In comp.lang.perl.misc, AAron nAAs <anaas@funb.com> writes:
> :When an "s///ge" calls a routine which ultimately recurses back to the original
> :command, things flip out with the original substitution. My guess is that the
> :'g' is saving a static state which is lost when it is re-entered due to 'e'
> :which allows functions to be called. 
> 
> Yes, that's right.  It's know to be not re-entrant.  And I believe
> that this is not documented because we'd like to fix it someday.
> Check with p5p.

Let me note that this is not an *absolute* statement (though most
probably it is correct).  I would not try to decide what it is before
I see the code.  First of all, the substitution part of s/// is
executed *outside* of REx engine, so this avoids one type of
non-reinterability.  Second, at least theoretically s///g does not
need to preserve state in Perl data, it may keep in C data while it
loops.

Ilya


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

Date: Wed, 27 Jan 1999 10:30:39 -0500
From: AAron nAAs <anaas@funb.com>
To: Jim Matzdorff <syran@best.com>
Subject: Re: Is this possible?
Message-Id: <36AF311F.4DD30354@funb.com>

The require technique you have should work.
Here is the subroutine reference syntax you are looking for:

%subs = (
        sub1    => \&ThisSub,
        sub2    => \&AnotherSub,
        sub3    => \&CoolSub,
        sub4    => \&NotSoCoolSub,
        );
$mySub = $subs{sub1};
&$mySub("Hello", 25);

-AAron

Jim Matzdorff wrote:

> I have a hash that has subroutine names defined in it (or at least, this
> is what I *want* to be able to do)
>
> %subs = (
>         sub1    => "ThisSub()",
>         sub2    => "AnotherSub()",
>         sub3    => "CoolSub()",
>         sub4    => "NotSoCoolSub()",
>         )
>



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

Date: 27 Jan 1999 15:39:42 GMT
From: cba@xs1.xs4all.nl (cba)
Subject: Newbie Question
Message-Id: <78nbvu$8j7$1@news2.xs4all.nl>


Hi there...

i just started doing some programming in Perl and have the following question...

i have a simple program :

@a = ('one ',' two',' three);
$count = @a;
for ($i = 0; $i < $count;) {
print @a[$count++]; 
}

What i dont get is that if i include a IF statement that would search for example 'Two', how then
to print : 

one three

as result...

When i use 

if (@a[$count] = 'two') { $count++ }

The $count doenst skip the two...

anyone can explain me a way how to do it ... 

i looked trough man perl and searched the Faq but could not find anything about it.

Niels Alkema




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

Date: Wed, 27 Jan 1999 08:58:37 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: Newbie question: writing file
Message-Id: <36AF299D.EB4E3BA9@austin.ibm.com>

Eugene Sotirescu wrote:

> Kevin D. Chester wrote:
> >
> > Hello Tom,
> >
> > Thank you for your reply!!! This little "x" has solved the problem and it seems to be
> > working.
>
> And it created another problem: you now have a directory  wide open for
> anybody to write to.

Well, that depends upon where he added the execute perm.

>
> At the least you should use the -T switch in your CGI script.
>

Can't argue with that one.  It's generally a good idea for any CGI script.

- Tom



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

Date: Wed, 27 Jan 1999 15:18:19 GMT
From: a_s_hearn@yahoo.com
Subject: Passing variables between two Perl scripts
Message-Id: <78nang$2e7$1@nnrp1.dejanews.com>

Hello!

(Sorry if you have this twice)

I'm wanting to pass three variables between two perl scripts, rather like
passing from a HTML form to a script, but from one script to another.

I want the first perl script to end once it has passes the variables.

If any one could send an example of how to do this, then I'd be grateful.

Many trhanks.

Andrew Hearn.

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


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

Date: 27 Jan 1999 08:41:33 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Passing variables between two Perl scripts
Message-Id: <36af33ad@csnews>

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

In comp.lang.perl.misc, 
    a_s_hearn@yahoo.com writes:
:I'm wanting to pass three variables between two perl scripts, rather like
:passing from a HTML form to a script, but from one script to another.
:I want the first perl script to end once it has passes the variables.
:If any one could send an example of how to do this, then I'd be grateful.

>From the command line:

    % program1 various args go here

Now, in program1

    #!/usr/bin/perl -w
    use strict; 
    ...
    # process @ARGV, do your thing, then
    exec("program2 more various args go here");

If you don't want to chain/polymorph/exec the other program,
use system() instead of exec().

Why have people forgotten the way for one program to call
another one, and how to give it arguments or input?  What's
going on?  Too much point-and-drool?

--tom
-- 
A successful tool is one that was used to do something undreamed of by
its author.  --S. C. Johnson


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

Date: Wed, 27 Jan 1999 14:18:58 GMT
From: aqumsieh@my-dejanews.com
Subject: Re: Perl Criticism
Message-Id: <78n78a$v37$1@nnrp1.dejanews.com>

In article <78gpsb$qfq$1@nnrp1.dejanews.com>,
  topmind@technologist.com wrote:

> How about somebody take that cryptical signiture that
> somebody here keeps posting at the bottom and turn it
> into Pascal or Java. Let's see if they can make it
> equally confusing to reverse engineer.

As far as I'm concerned, that's a feature in Perl that is lacking in Pascal
and Java. It is true that it is *easier* to write obfuscated code in Perl,
but at the risk of sounding redundant, that is a feature. If you worry about
maintainability and readability, then Perl offers alternatives which can be
used to construct nicely-written, well-documented code.

On the other hand, if you are merely writing a quick script to hack some
specific data, and reformat it into something human-readable (which is why
Perl was invented in the first place), then maintainability is not an issue
as you are (most likely) never ever going to use that same piece of code
again. What is important in this case is the speed at which you code your
script and the results it produces. From this point of view, I see no
competitor to Perl. Did I mention that I see this as a feature in Perl??

PS. Try writing a C/Java/Pascal program that simply substitutes all
occurences of THIS to THAT in a file, only if the word 'Perl' occurs
somewhere in the line. Compare that to the perl one-liner and you might just
understand my point.

Ala

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


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

Date: Wed, 27 Jan 1999 07:48:43 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Criticism
Message-Id: <MPG.1118d52c124ee6659899cf@nntp.hpl.hp.com>

In article <slrn7au5am.ivr.dformosa@godzilla.zeta.org.au> on 27 Jan 1999 
13:32:07 GMT, David Formosa (aka ? the Platypus) <dformosa@zeta.org.au> 
says...
 ...
> However optimisations like this have a magour impact in code running
> time and useablity.  if ($a != 0 and $b/$a>10) { is not something that
> I can do without.

Certainly you could do without it, as all it is is a sequence of 
decisions:

    if ($a != 0) {
        if ($b/$a > 10) {

>                     Indeed I would argue that given that these are
> quite commen in most langages most programers will be expecting them
> and therefore a lanague without them would be more confising.

Compound conditionals are indeed common and convenient.  But they are 
not indispensable.  If one were designing a bare-bones, TIOOWTDI 
language, one could leave them out, but not without some pain.

Consider this snippet:  Assign the first TRUE result of a set of 
alternative, costly computations (possibly with side effects), or a 
default:

    $x = f() || g() || h() || $y;

This is beautiful, spare, clean Perl (but not C, by the way, where the 
result would be a Boolean!).  The following is both Perl and C (ignoring 
variable-naming syntax):

    $x = ($t = f()) ? $t : ($t = g()) ? $t : ($t = h()) : $y;

Ouch.  Now try that again in a language that doesn't have conditional 
expressions either:

    if ($t = f()) {
        $x = $t;
    } elsif ($t = g()) {
        $x = $t;
    } elsif ($t = h()) {
        $x = $t;
    } else
        $x = $y;

As you can see, it gets 'old' really fast.  But it certainly can be 
done, and even in assembly language, God forbid!

Remember the 'Perl baby talk' metaphor in the introduction to the Blue 
Camel (and probably elsewhere)?  Fortunately Perl lets those who are 
able to do so talk 'adult talk' also.

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


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

Date: Wed, 27 Jan 1999 09:20:35 -0500
From: John Chambers <jc@uwm-dev.gte.com>
Subject: Re: Perl print ("....."); command problems
Message-Id: <36AF20B3.317096DD@uwm-dev.gte.com>

expoinfo@globalexpos.co.nz wrote:
> 
> Hullo... :o)
> 
> I am currently having a problem with a script..
> 
> It is to be installed onto a Unix Server, yet this part of teh script is
> bothering me when porting from Win32 to Unix.
> 
>  print qq!
> 
>  <table border=0 width=550><tr><td valign=top width=450>
> 
>  !;
> 
> I dont seem to be able to change it to the ...
> 
> print ("<table border=0 width=550><tr><td valign=top width=450>");
> 
> .. and have it still work
> 
> WHAT IS THE PROBLEMO :oP


Hard to say exactly with so little info, but I notice one major
difference between the two:  The first print generates three
lines, each ending with a line terminator. The call of print(),
however, has just a quoted string with no \n at the end.

I'd guess that you're stumbling across the stdio package's
buffering of output.  By default, it accumulates output in
a buffer until a newline is encountered and then writes the
entire line with a single write.  This is a common problem
with CGI scripts.

Try two things.  First, add the command
   $| = 1;
at the start of your script.  This turns off the buffering,
and causes print() to send the chars right away.  This may
solve your problem, if there's nothing else in the pipeline
that does its own buffering.

The other thing is to add \n to the end of the printed string,
of course.  In HTML, this shouldn't hurt anything as long as
you're not in a <PRE>, which you obviously aren't.  And it 
should unstick any buffers in any part of the pipeline.

The "$| = 1" command should be used in all CGI scripts.  You'd
be amazed at all the "stuck" communications that it'll unstick.
And if you're sending HTML, it's a good idea to be liberal with
newlines.  This will defeat most buffering schemes, and make
the output more readable by humans trying to debug it.


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

Date: Wed, 27 Jan 1999 15:00:48 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: stat() interpretation
Message-Id: <F684DC.Dzp@world.std.com>

jimrsmith@unn.unisys.com writes:

>Can you tell me how I interpret the output from:
>@array = stat($filename) ;
>$mode = $array[2] ;
># print $mode at this point gives a number: 16877 for a subdirectory
>#                                           32742 for a file
>How do I translate this to read,write, execute permissions ?

If you print out the number in octal instead of decimal, (as well as
strip out the upper bits with "& 0777" to get rid of the filetype
bits) it may look a more familiar. (Assuming modes like "755" look
familiar)

Otherwise, maybe the Stat::lsMode module may be interesting to you:
<URL:http://www.perl.com/CPAN/modules/by-module/Stat/Stat-lsMode-0.50.tar.gz>
-- 
Andrew Langmead


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

Date: Wed, 27 Jan 1999 09:09:10 -0500
From: John Chambers <jc@uwm-dev.gte.com>
Subject: Re: system function, Pros and Cons??
Message-Id: <36AF1E06.87AF7899@uwm-dev.gte.com>

Abraham Grief wrote:
> 
> Using the system function is not portable.  If you
> write a perl script that uses the system function, you
> might have to rewrite it for every operating system
> you want to run it on.

Yeah, and you might even have to rewrite it for another
unix-like system.  The system() call is inherently not
portable.  (Maybe that's why it's called "system"? ;-)

But having agreed with that, I'd point out also that
one of perl's intended uses is as a "shell scripting"
language.  That is, it was intended as a tool for
writing little programs that control other programs.
No matter what you do, this sort of job is inherently
not portable, because it depends on the behavior of
the subprocesses that you're calling.  If you call
anything out of the system libraries, you can't rely
on them working the same on the next system.

Nothing wrong with this.  You just need to be aware
that a program that invokes other programs isn't
going to be very portable, no matter what language
you write it in.  Or you'll have to carry along all 
the programs that you're calling, and install them 
on the next system.

(BTW, as a scripting language, perl itself is more
portable than most of the Unix shells.  About the
only shell that approaches perl's consistency across
platforms is the Bourne shell, and we all know its
serious limitations.  No criticism of Mr. Bourne,
of course; the fact that his shell has survived for
a quarter century is remarkable.  But if you need
a script of more than a dozen lines, you're probably
better off writing it in perl.)


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

Date: 27 Jan 1999 15:50:41 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: system function, Pros and Cons??
Message-Id: <78nckh$1u0$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Christiansen 
<tchrist@mox.perl.com>],
who wrote in article <36aef8cc@csnews>:
> Plus, doing it this way doesn't require the obscene rigamarole that you
> would need to include proper support for multi-threaded, object-oriented,
> persistent, distributed, platform-independent, and language-neutral (i18n)
> support in your module, complete with transparent access via Java RMI
> and as a COM object -- the way the frothing fanantics keep espousing.
> These poor deluded folks constitute a cult of complexity, one whose
> credo breeds fragile overengineering and inscrutable overabstraction.
> 
> Please don't encourage them.

Right.  Use the tools you have.

There is absolutely no need to learn any Perl operator except `` and chop.
Say, why do you need split if you can just do something much more
intuitive like

  @arr = `IFS=":"; for x in "$var"; do echo \$x; done`;
  chop @arr;

You do not need to learn all the endless particular cases of split,
all the details of regular expression engine - and you avoid all the
bugs in it!

Or why would one want to learn how to use modules and objects to
calculate with big numbers in Perl.  Listen to Abigail: let GNU
calculator do it for you!

Keep it simple, dude!

Ilya


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

Date: Wed, 27 Jan 1999 10:35:38 -0500
From: mk@weconnectyou.com
Subject: that "runops ... undefined" thing from perlcc
Message-Id: <36AF324A.A8F39375@weconnectyou.com>

Good-Day!

I have a script (in use for quite some time) that I would like to build
into an executable.

So I waited fot the long awaited perlcc, and compile and built
perl_5.005_02 and tried a simple "hello world"... it was fine!

I perlcc'd my script and it compiled fine, but linking produced the
"runops: undefined..." error.
(I have seen mention of this by others in this group)

There was a posting about it being an "eval" problem... (no help)(don't
use any eval's in my script)

There was a posting about the runops... problem being fixed in
perl_5.005_54, so I built and tested that.

The problem remains... is there any solution? Is this about the compiled
file size?

I grepped through the sources (to per) (and my script) there is no
"runops" object or function that I can find???

Anyone got a grip on this???

Thanks to all!


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

Date: Wed, 27 Jan 1999 09:12:58 -0600
From: Steve Williams <williams@openmic.com>
Subject: Re: WANTED: Perl Programmer (London/UK)
Message-Id: <36AF2CFA.181CB88A@openmic.com>

what is the salary range???

Christof Damian wrote:

> Internet Programmer (Unix, Perl, SQL) permanent London/UK
>
> Job Title: Internet Programmer (Unix, Perl, SQL)
> Location:  London UK (Highgate)
> Duration:  permanent
>
> mediaconsult ltd. is a internet consulting company based in london
> (uk) and cologne (germany). For a new project we are looking for
> programmers.
>
> We are a looking for programmers with experience in developing
> internet application in a unix enviroment. The project will be the
> development of databases with an internet frontend.
>
> Skills required are: Perl, HTML, SQL and Unix administration.
>
> Desireable skills are knowledge of Linux, Apache, Java, C++ and MySQL.
>
> mediaconsult ltd.
> 33 Greenwood Place
> London NW5 1LB
>
> jobs@mediaconsult.com
> http://mediaconsult.com/
>
> --
> Christof Damian                [ we are looking for perl and linux
> Technical Director               programmers, more information @
> http://mediaconsult.com/         http://mediaconsult.com/wanted.html ]



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

Date: Wed, 27 Jan 1999 08:36:18 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: What's the character?
Message-Id: <298n87.7h.ln@magna.metronet.com>

om7@cyberdude.com wrote:

: What I'm storing is the following data, by doing "ls -1 dir1 dir2 dir3...".
: (That's a number one and not the letter l.)

: dir1:
: file1
: file2
: file3

: dir2:
: file4
: file5

: I'm having trouble determining what the line separting the data is.  


   Looks like a blank line to me.


: I've
: tested for it being undef and also a \n character, but that doesn't match.


   We cannot help you fix your code if you do not show 
   us your code (hint!)


: I
: need to determine what it is and how to check for it.  


   print "line number $. has only whitespace on it!\n" if /^\s*$/;


: I know I could get
: round it by checking if it's a string or something (or doing separate "ls
: -1"'s; I will do if I can't figure out anything else.  And I don't want to do
: separate "ls -1" because that gives me a long list and I can't determine what
: files came from which directory.

: Can anyone help??


   The whole problem goes away if you Do It Right.

   Use Perl's built-in directory access functions, then you don't
   need 'ls', nor do you need to parse its output.

      perldoc -f opendir
      perldoc -f readdir

   See also the '-X' file test operators in 'perlfunc.pod'. You can
   use these to determine what is a directory and what is a plain file.


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


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

Date: Wed, 27 Jan 1999 15:44:20 +0000
From: Mark Hamlin <mark.c.hamlin@bt.com>
Subject: Re: Wnt: Simple script to search & replace through a batch of files
Message-Id: <36AF3454.F4286B1B@bt.com>

Ted,

Thanks for the tip.  Love the way you use the find command and how damn simple the
whole thing is,,, lovely!

p.s If you know a really good book on Perl could you let me know.  All the O-Reilly
books have there strengths, but none of the books I've seen have convinced me to buy
(I'm very tight for cash at the moment).  I find the manuals very useful but its
often not easy to find what you want, so what I'm after is something which will
complement them.  I found very useful info about how the simple expression you gave
me works in the Perlrun page, but this was a rare success for me.

Thanks again,
Mark Hamlin

Tad McClellan wrote: UNTESTED!

> perl -p -i.bak -e 's/oldURL\.com/newURL.com/g' `find . -name '*.html' -print`
>
> --
>     Tad McClellan                          SGML Consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas





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

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

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