[12076] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5676 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 15 21:07:22 1999

Date: Sat, 15 May 99 18:00:20 -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           Sat, 15 May 1999     Volume: 8 Number: 5676

Today's topics:
    Re: $var interpolation in regular expressions (Bart Lateur)
    Re: $var interpolation in regular expressions <aperrin@mcmahon.qal.berkeley.edu>
    Re: $var interpolation in regular expressions (Tad McClellan)
        Anyone out there have any static code metrics tools for <Dan@Gregson.com>
    Re: Hash arrays (I R A Aggie)
    Re: Hash arrays (I R A Aggie)
    Re: Hash arrays zenin@bawdycaste.org
        How to change unix password with perl.... (Ryan Ngi)
    Re: How to create an iterable list on the fly? <swarren@www.wwwdotorg.org>
        linkmanager database mikes3790@my-dejanews.com
        My script runs on win32, it won't run on Unix lazersa@my-dejanews.com
        mysql/perl question <mikes@athabascau.ca>
    Re: newbie problems with Perl CGI and Netscape <webmaster@chatbase.com>
    Re: Passing references <swarren@www.wwwdotorg.org>
    Re: Perl "constructors" <rra@stanford.edu>
    Re: Perl "constructors" <rra@stanford.edu>
    Re: Perl "constructors" <rra@stanford.edu>
    Re: Perl "constructors" <rra@stanford.edu>
        Please Help: My script runs on win32, it won't run on U lazersa@my-dejanews.com
    Re: Question: Updating an Array... (David Salvador Flores)
    Re: regexp problem (Andrew Johnson)
    Re: standard array and associative array <swarren@www.wwwdotorg.org>
    Re: TROLL ALERT (Re: Perl "constructors") (I R A Aggie)
    Re: TROLL ALERT (Re: Perl "constructors") <rra@stanford.edu>
    Re: TROLL ALERT (Re: Perl "constructors") <rra@stanford.edu>
    Re: uninitialized value <xyf@inetnebr.com>
        Using Apple's Sherlock plugins from perl mrowell@my-dejanews.com
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Sat, 15 May 1999 22:24:57 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: $var interpolation in regular expressions
Message-Id: <373ef3b2.5184425@news.skynet.be>

Rick Hensh wrote:

>According to (Win32 version) Learning Perl the following should work:
>
>$missOne = "\t[\-0-9]+\t[\-0-9]+\t[\-0-9]+\t(.+\b0[^\n])";
>
>if (/$missOne/) {
>    stuff;
>}
>
>I've tested the regex directly and so I know that it works. Did I
>misunderstand how var interpolation works in this case?

Yes. This is the third time this week something like this is asked.

Try printing the variable. The printed result should look EXACTLY like
what you would put in the pattern directly. Partly because of the double
quotes, I'm damn surethis won't be the case now. For one, there will be
no more backslashes. You need them. Desperately.

   HTH,
   Bart.


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

Date: Sat, 15 May 1999 17:13:06 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: $var interpolation in regular expressions
Message-Id: <373E0D92.4C5FA12B@mcmahon.qal.berkeley.edu>

Rick Hensh wrote:

> According to (Win32 version) Learning Perl the following should work:
>

no, it shouldn't.

> $missOne = "\t[\-0-9]+\t[\-0-9]+\t[\-0-9]+\t(.+\b0[^\n])";
>
> if (/$missOne/) {
>     stuff;
> }
>
> I've tested the regex directly and so I know that it works. Did I
> misunderstand how var interpolation works in this case?
>

No, you misunderstand how quoting and interpolation works:$missOne =
"\t[\-0-9]+\t[\-0-9]+\t[\-0-9]+\t(.+\b0[^\n])";

$missTwo = '\t[\-0-9]+\t[\-0-9]+\t[\-0-9]+\t(.+\b0[^\n])';

print "\$missOne: $missOne\n\n";
print "\$missTwo: $missTwo\n\n";

$missOne:  [-0-9]+ [-0-9]+ [-0-9]+ (.+0[^
])

$missTwo: \t[\-0-9]+\t[\-0-9]+\t[\-0-9]+\t(.+\b0[^\n])

--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting -  (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
     http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------




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

Date: Sat, 15 May 1999 15:16:15 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: $var interpolation in regular expressions
Message-Id: <v5hkh7.qa5.ln@magna.metronet.com>

Rick Hensh (hensh@math.msu.edu) wrote:
: According to (Win32 version) Learning Perl the following should work:

: $missOne = "\t[\-0-9]+\t[\-0-9]+\t[\-0-9]+\t(.+\b0[^\n])";

: if (/$missOne/) {
:     stuff;
: }


: I've tested the regex directly and so I know that it works. Did I
: misunderstand how var interpolation works in this case?


   No, what you misunderstand is *when* var interpolation happens  :-)

   It happens in the assignment to $missOne because you have use
   double quotes.

   Print the value of $missOne after the assignment.

   [ you do not need to escape hyphens when they are first (or last)
     in a character class either
   ]


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


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

Date: Sat, 15 May 1999 16:17:38 -0600
From: Dan Gregson <Dan@Gregson.com>
Subject: Anyone out there have any static code metrics tools for Perl?
Message-Id: <373DF282.39A50340@Gregson.com>

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

Is there anyone out there that has some scripts that measure cyclomatic
code complexity and other code health type metrics?

Thanks in advance,

Dan Gregson

--------------A7CD19B0D6B3AD77DCFC877F
Content-Type: text/x-vcard; charset=us-ascii;
 name="Dan.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Dan Gregson
Content-Disposition: attachment;
 filename="Dan.vcf"

begin:vcard 
n:Gregson;Dan 
x-mozilla-html:FALSE
version:2.1
email;internet:Dan@Gregson.com
note:http://www.Dan.Gregson.com
x-mozilla-cpt:;0
fn:Dan  Gregson
end:vcard

--------------A7CD19B0D6B3AD77DCFC877F--



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

Date: 15 May 1999 23:21:57 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Hash arrays
Message-Id: <slrn7js0hj.qlg.fl_aggie@stat.fsu.edu>

On Sat, 15 May 1999 11:22:08 GMT, armchair@my-dejanews.com
<armchair@my-dejanews.com>, in

+ You said that before. What is it? Do you just keep hitting the send key?
+ Here's a dime old fellow. Get a real computer, get a real newsreader,
+ get a good cup of coffee.

You obviously aren't cut out for perl...give it up, while you're still
behind...

James


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

Date: 15 May 1999 23:24:44 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Hash arrays
Message-Id: <slrn7js0mp.qlg.fl_aggie@stat.fsu.edu>

On Sat, 15 May 1999 11:27:18 GMT, armchair@my-dejanews.com
<armchair@my-dejanews.com>, in

+ So true Sam, very small brain. But nature balances things out and I'm
+ very large elsewhere. Is that why you guys seem so testy - jealousy?

Jealousy over a big mouth? Huh? I don't get it!

James


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

Date: 16 May 1999 00:34:35 GMT
From: zenin@bawdycaste.org
Subject: Re: Hash arrays
Message-Id: <926815016.915739@thrush.omix.com>

armchair@my-dejanews.com wrote:
: tchrist@mox.perl.com (Tom Christiansen) wrote:
:> By reading or grepping the manpages, just like the rest of us.  What part
:> of the standard Perl documentation included with each and every Perl
:> distribution did you happen to find less than clear on this matter?
: 
: At the crime of repeating myself, I have been reading "Perl From the
: Ground Up" and "Teach Yourself Perl in 21 Days" and did not see any
: examples of discussion of how to get the number of items in a hash in
: their sections on hashes.

	What part of, "included with each and every Perl distribution" did
	you not understand?

	The books you mentioned are simply that, books.  They are *not* the
	manual nore are they a replacement for it.

: I hope you can find it in your heart to forgive me for not looking at
: FAQ4, where the answer is most easily found.

	No, sorry.  There is no excuse for not looking in the FAQ,
	especially with the availability of tools expressly for it such
	as: `perldoc -q hash'.

-- 
-Zenin (zenin@archive.rhps.org)         Caffeine...for the mind.
                                        Pizza......for the body.
                                        Sushi......for the soul.
                                             -- User Friendly


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

Date: Sun, 09 May 1999 23:37:44 GMT
From: ryanngi@hotmail.com (Ryan Ngi)
Subject: How to change unix password with perl....
Message-Id: <3554e84c.7183939@news.inet.co.th>

how to (not using system())?


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

Date: Sat, 15 May 1999 22:33:00 GMT
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: How to create an iterable list on the fly?
Message-Id: <wCm%2.55$fx5.89@news.rdc1.sfba.home.com>

tbrannon <brannon@quake.usc.edu> wrote in message
news:ysizbtfm6scd.fsf@nunki.usc.edu...
>
> I want to create a simple list of strings which I sort dereference,
> but, I can't seem to create the list on the fly:
>
> $num=10;
> $den=22;
>
> for (split "num den") {
>   print "$$_\n";
> }
>
> for qw(num den) {
>   print "$$_\n";
> }

You're trying to use symbolic references. Whilst this can be made to work,
it isn't the best way of doing it. You should put your 'symbols' into a
hash:

    #!/usr/local/bin/perl -w
    use strict ;

    my %h = ( 'num' => 10, 'den' => 22 ) ;

and iterate thus:

    for ( split / /, 'num den' )
    {
        next if ! exists $h{$_} ;
        print $h{$_}, "\n" ;
    }

Note that you also needed to tell split the regex to split on ('/ /')

--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com                http://www.techhouse.com/
mailto:swarren@wwwdotorg.org                http://www.wwwdotorg.org/
              MIME, S/MIME and HTML mail are acceptable





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

Date: Sat, 15 May 1999 23:30:21 GMT
From: mikes3790@my-dejanews.com
Subject: linkmanager database
Message-Id: <7hl02e$o0t$1@nnrp1.deja.com>

question: I want to write a linkmanager to manage
links by topic, like yahoo. I want to be able
to retrieve links in a hierarchal fashion like
yahoo.

I'll be using MySQL. All i wanted was advice on
the database scheme. I was thinking of simply
storing the hierarchy in a seperate row along with
each link something like

/Sociology/Canadian Society/Native Studies but was
wondering if anyone could suggest a more
efficient/flexible way to do it.

reply to mikes@athabascau.ca


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Sat, 15 May 1999 22:21:49 GMT
From: lazersa@my-dejanews.com
Subject: My script runs on win32, it won't run on Unix
Message-Id: <7hks1s$lk9$1@nnrp1.deja.com>

Hi,
I have written a perl script based on a tutorial which I downloaded, in
this tutorial, the author suggested i use win32 (Activeperl) to debug my
perl scripts. The script runs without any glitches on a windows-based
system. When I try it on a unix server, it just returns an error message
- I do not have access to the log files, so i can't get any more
information than that.

Does anyone have any ideas as to why it won't run, or is there any Url
where i can see the dfferences(or how to modify a script for unix)?

Thanx

Warren


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: 15 May 1999 17:47:30 -0700
From: Mike Sosteric <mikes@athabascau.ca>
Subject: mysql/perl question
Message-Id: <m3r9ohvo0t.fsf@athabascau.ca>


Just a quick question, I want to create a WWW link database using Perl/MySQL. I want to be able to retrieve links like at yahoo /Sociology/Journals/ or History/Canadian/Nice People

i have it in my head to store links in a simpel table with two rows, one the link, and 
the other the hierarchy

ROW1____________________   ROW2_____________________
http://www.somelink.com/   /sociology/journals/


before I go ahead and code this though, any advice on whether this is a good/efficient method or whether or not there are other options?

tia
Mike Sosteric (remove you know NADA to email)
mikes@NADA.athabascau.ca


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

Date: Sat, 15 May 1999 15:15:46 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: newbie problems with Perl CGI and Netscape
Message-Id: <373DF212.FB0A70A4@chatbase.com>

Drifter wrote:
> 
> When I print out html code in my cgi script it works great in IE but in
> Netscape,

IE ignores the standards, don't trust your CGI script to be correct by
using IE only, unless you at least know what you're doing.

Speaking of CGI, that's where this post belongs, in the CGI NG. :-)

> all i get is a listing of the code and not the web page.

What do you mean? It prints the HTML code, OR the Perl code?
 
> i have tried using  print "Content-type: text/html";

Have you tried:
print "Content-type: text/html\n\n";

** Notice the two new lines (\n\n).
 
> tried cgi-lib.pm

Or try CGI.pm :-)
 
> &PrintHeader;
> 
> &HtmlTop;
> .
> .
> html code
> .
> .
> 
> &HtmlBot;
> 
> everything works great in IE, but nothing works in Netscape!

IE is ****, they have problems conforming to the standards with many
things.
 
> Can neone help me?

Try your question in a CGI NG, but *after* reading some help files, etc.
on CGI and if you have a question that deems posting to an NG, then
people will probably be very helpful. :-)

Sorry I don't retain a listing of sites a with help.. I believe I'll get
a good/reliable list going to post for people such as yourself. :-)
-- 
Regards,
Tim Greer:  chatmaster@chatbase.com / software@linkworm.com   
The Chat Base:  http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software & The Link Worm:  http://www.linkworm.com
Custom chat server scripts, CGI scripting in Perl/C, Trouble shooting,
Security, Modify & Debug, Freelance Scripting and more!


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

Date: Sat, 15 May 1999 22:14:15 GMT
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: Passing references
Message-Id: <Xkm%2.49$fx5.200@news.rdc1.sfba.home.com>

Briggs Reschke <briggs@texas.net> wrote in message
news:373D6642.1796DE6F@texas.net...
> I am trying to do something like, in C, passing a pointer to an array of
> structures to a subroutine and I'm getting nowhere.  The docs that I've
> come across are just confusing me more.

Well, read what you get from executing:

    perldoc perlref
    perldoc perldata
    perldoc perldsc
    perldoc perllol

But, if you've already tried docs and found them confusing, then that
might be too!

Always remember to:

    #!/usr/local/bin/perl -w
    use strict ;

Lets start from scratch. You want an array of structures. In Perl, a
structure is stored in a hash:

    my %s1 = ( 'key' => 'value' ) ;
    my %s2 = ( 'otherKey' => 'otherValue' ) ;

If you want to store them in an array, you *really* want to store
references to these hashes into your array. A Perl reference is roughly a
C pointer. You get a reference by prefixing your variable name with \:

    my $refToS1 = \%s1 ;

Notice *dollar* refToS1: References are scalar values. These can easily be
stored in arrays:

    my @a1 = ( \%s1, \%s2 ) ;

Now, we have an array of hashes.

You can read them back in stages:

    my $h = $a1[ 0 ] ;
    my $v = $$h{ 'key' } ;

Note that we use $ twice. Once to indicate that we wished to access
variable scalar h. Once to dereference the value stored in $h, since it's
a reference. We can put this into a single step:

    my $v2 = ${$a1[0]}{ 'key' } ;

Or:

    my $v2 = $a1[0]->{ 'key' } ;

The latter syntax works out being cleaner. It basically says read $a1[0],
de-reference it (the '->') and then apply the {} operator to it (which is
the read-a-value-from-hash operator, if you will)

Now, you want to pass it to you function. You can either do:

    sub sub1
    {
        my @aparam = @_ ;
    }

    sub1( @a1 ) ;

Which passes the entire array by value. You can then use the syntax listed
above to read from the array. However, you can't modify it, because you
have a copy of the array. You *can* modify the contents of the hashes in
the array, because you've copied the contents of the array (the references
to the hashes), not the hashes themselves...

Or, if you want to change the array too, or you want a more efficient way
of doing things, you can:

    sub sub2
    {
        my $refToArrayParam = $_[0] ; # or = shift ;
    }

    sub2( \@a1 ) ;

In which case, you'd have two levels of references to go through to read
the data in the hashes in the array:

    sub sub2plus
    {
        my $refToArrayParam = $_[0] ; # or = shift ;

        my $val = $refToArrayParam->[0]->{'key'} ;
    }

    sub2plus( \@a1 ) ;

Hope this gives you enough to understand those perldoc.

--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com                http://www.techhouse.com/
mailto:swarren@wwwdotorg.org                http://www.wwwdotorg.org/
              MIME, S/MIME and HTML mail are acceptable





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

Date: 15 May 1999 17:35:21 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl "constructors"
Message-Id: <ylyaip4zsm.fsf@windlord.stanford.edu>

armchair <armchair@my-dejanews.com> writes:

> And what does your code look like?

> #constructor...
> if ( success )
> { return bless a; } else { return 0; }

Nope.  On failure, it calls die.

> my $reference = myclass->new();
> if ( $reference == 0 )
> {
>   print "constructor failed\n";
> }

> Correct?

No, if I'm calling a constructor that needs to be able to throw
exceptions, I do:

        my $object;
        eval { $object = My::Class->new };
        if ($@) {
            print "Constructor failed: $@\n";
        }

It turns out that most of the reason why constructors fail in C++ is due
to memory allocation problems, and in Perl you don't have to worry about
that.  So it's actually fairly rare for constructors to fail in Perl, and
you usually don't have to worry about it.  If you do, the constructor can
document that it throws exceptions, and you can catch them if you want.

If you're writing a quick little program, you usually don't need to catch
them.  Just let them propagate up and cause your program to exit.

> In C++ and Java, but not in Perl. Does it have them, and if so which
> perl HTML page section are they documented in?

perlfunc.  Search for exception and you'll find the documentation for die.

>> What, like $count = keys %hash?

> Very expensive,

No, it's not.

> not intuitive.

Let me get this straight.  Saying $count = keys %hash is an unintuitive
way of getting the number of keys in a hash?  Er....

> What is the hash has 2000 items. Create a matching array just to get a
> count of them?

You have a really bad Perl book.

> Asumming I just want to test emptiness. Thanks, just tried it, and it
> worked, but I do have one comment - non-intuitive, non-lookupable,
> obtuse.

*shrug*

Everything in Perl has a well-defined value of true or false.  It's a
basic language concept.  You find it non-intuitive because you don't know
Perl.  In Perl, arrays and hashes are true if they contain any elements,
and this is used *all the time* when writing Perl code.

-- 
#!/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: 15 May 1999 17:46:42 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl "constructors"
Message-Id: <ylso8x4z9p.fsf@windlord.stanford.edu>

armchair <armchair@my-dejanews.com> writes:

> If Perl doesn't enforce a name for a constructor, due to it's
> "libertarian attitude" that allows the programmer to do what they think
> is right, then you are commiting heresy by suggesting that anyone's
> naming of a constructor is wrong.

No.  The important concept is *responsibility*.  Perl is not going to tell
you what to name your constructors.  *You* need to decide what to name
your constructors.  One of the things you should keep in mind, as an
experienced programmer, is what names for your constructors will cause the
least amount of confusion for users of your code.  This will probably lead
you to the decision to call your constructors new() 99% of the time.

You're thinking of this from an authoritarian mindset.  You're effectively
saying that if something is a bad idea, it should be prohibited.  This is
not how Perl works.  Perl counts on *you* to determine whether or not it's
a bad idea.  Perl takes responsibility for making sure that even your bad
ideas will *function* because Perl is a humble language.  Perl doesn't
think it knows what's best for you.  Perl doesn't know every way in which
Perl can be used.  Perl doesn't know what reasons you may have for doing
something that would normally be a bad idea, and therefore doesn't try to
second-guess you.  This is what lets Perl be *flexible*.

Just because *Perl* isn't going to criticise you doesn't mean that other
*people* can't try to convince you you made the wrong decision.  People
are capable of dealing with exceptions, seeing reasons for odd usages, and
arguing over the issues and underlying intuitiveness.  Perl can't do any
of those things, so Perl stays out of it.

-- 
#!/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: 15 May 1999 17:40:29 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl "constructors"
Message-Id: <ylvhdt4zk2.fsf@windlord.stanford.edu>

armchair <armchair@my-dejanews.com> writes:

> Okay, I take your point regarding syntax similarity. It just takes some
> getting used to I suppose. But the oversight was referring to another
> difference: records are fixed in the number and type (but not possible
> in Perl) of fields they hold, whereas a hash or array can hold 0 to n
> fields and has to be checked if the code is going to be "robust" and
> handle invalid passed parameters gracefully.

You're thinking like a C++ programmer.  You're going to find Perl painful
when coming from that mindset.  In Perl, you don't need to check such
things.  You don't need to care.  Just stop worrying about it; it'll work
just fine as it is.  It doesn't matter if the hash has a few extra
elements; it doesn't have any impact at all on the correctness of your
program.

Your quest for robustness is a very good trait in a C++ programmer, but
it's largely an illusion for a Perl programmer.  With Perl, the *language*
is robust, so the *programs* don't have to worry about it nearly as much.
C++ is precisely the opposite; the language is a house of cards, so the
programmer has to supply all the robustness or watch the whole thing come
falling down.

-- 
#!/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: 15 May 1999 17:52:06 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl "constructors"
Message-Id: <ylpv414z0p.fsf@windlord.stanford.edu>

armchair <armchair@my-dejanews.com> writes:

> What is your opinion of the dual use of {} in variable context - either
> to specify a member of a hash, or to dereference a reference?  This
> leads to confusion in my opinion. There are already two other ways to
> dereference a reference.

What, you mean something like @{$record{array}}?  It's kind of ugly and
not one of my favorite parts of Perl, although dereferencing a reference
is a simplification of what the outer {}s are doing.  They're actually
just a code block, like they are in a lot of other places in Perl.

Unfortunately, there aren't a lot of good syntactic alternatives.  I think
$record{array}->@ was proposed a while back, but it has the problem of
being inconsistent with the rest of Perl; the type identifier is always in
the front of the expression.

@->$record{array} would be more consistent, but I'm not sure if that's
doable in the parser, and the use of the arrow there is a bit counter-
intuitive.

-- 
#!/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: Sat, 15 May 1999 22:12:02 GMT
From: lazersa@my-dejanews.com
Subject: Please Help: My script runs on win32, it won't run on Unix
Message-Id: <7hkrfg$l8n$1@nnrp1.deja.com>

Hi,
I have written a perl script based on a tutorial
which I downloaded, in this tutorial, the author
suggested i use win32 (Activeperl) to debug my
perl scripts. The script runs without any glitches
on a windows-based system. When I try it on a unix
server, it just returns an error message - I do
not have access to the log files, so i can't get
any more information than that.

Does anyone have any ideas as to why it won't run,
or is there any Url where i can see the
differences(or how to modify a script for unix)?

Thanx

Warren


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: 15 May 1999 22:14:38 GMT
From: dsf3g@node4.unix.Virginia.EDU (David Salvador Flores)
Subject: Re: Question: Updating an Array...
Message-Id: <7hkrke$ihb$1@murdoch.acc.Virginia.EDU>

In article <372F4608.5159BE7F@ixl.com>,
Dan Boorstein  <dboorstein@ixl.com> wrote:
>Steve Linberg wrote:
>> 
>> In article <7gn537$6k6$1@murdoch.acc.Virginia.EDU>,
>> dsf3g@node16.unix.Virginia.EDU (David Salvador Flores) wrote:
>> 
>> > Now, I know from "Learning Perl" that the push, pop, shift and unshift
>> > functions allow you to update the "left" or "right" end of an array.
>> > But is there a simple way of stuffing new values into the middle of
>> > an array without overwriting a previous value?
>> 
>> No.  Arrays are sequential.  You'll have to do some moving.
>
>Hmm, seems easy enough to me.
>
>#!/usr/bin/perl
>
>@foo = (1 .. 10);
>splice @foo, 5, 0, 'middle';
>print @foo;


Thanks a million!



I'm getting to luuuuv perl.


-Dave


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

Date: Sun, 16 May 1999 00:18:18 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: regexp problem
Message-Id: <e9o%2.12397$L4.571309@news2.rdc1.on.home.com>

In article <373DCACE.156C1DF0@cs.pdx.edu>,
 Mile Andric <andricm@cs.pdx.edu> wrote:
! I have a string of words that might have an apostrophe (') in them.
! However, I just need to extract words that have one or more consonants
! in the beginning of the word and that don't have apostrophe in the body
! of the word.

you don't say what to do about hyphens or underscores or other
pssibilities ... but here's an example showing two versions to
get either @words or @more_words which do not contain apostrophes
(for some version of "word"):

#!/usr/bin/perl -w
use strict;
while(<DATA>){
    chomp;
    my @words = grep /^[^aeiou][a-z]+$/i, split;
    my @more_words = grep /^[^aeiou][\w-]+$/i, split;
    print "@words\n";
    print "@more_words\n";
}
__DATA__
this isn't a word or
what about built-in and foo_bar
I'll just give a simple version
you can adjust for f123-09z :-)

regards
andrew


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

Date: Sat, 15 May 1999 22:35:16 GMT
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: standard array and associative array
Message-Id: <EEm%2.57$fx5.235@news.rdc1.sfba.home.com>

<bing-du@tamu.edu> wrote in message news:7hkl6h$h2q$1@nnrp1.deja.com...
> Hello there,
>
> I need to write a sub routine that is able to handle both standard array
> and associative array.
>
> If the parameter passed in is a standard array, then convert it to some
> sort of associative array first and then continue processing.  If the
> parameter passed in is already an associative array, then skip
> the conversion step and continue processing.

Depending on your situation, Perl may do this automatically:

    sub s1
    {
       my %h = @_ ;
    }

Now, if you do either of:

    s1( %someHash ) ;
    s1( @someArray ) ;

Then %h in s1 will be a standard hash. Of course, the relies on the values
in @someArray being in the standard order for a hash initialization i.e.
 key1, value2, key2, value2, ...)

--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com                http://www.techhouse.com/
mailto:swarren@wwwdotorg.org                http://www.wwwdotorg.org/
              MIME, S/MIME and HTML mail are acceptable





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

Date: 15 May 1999 23:28:57 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: TROLL ALERT (Re: Perl "constructors")
Message-Id: <slrn7js0un.qlg.fl_aggie@stat.fsu.edu>

On 15 May 1999 14:46:11 -0000, Jonathan Stowe <gellyfish@gellyfish.com>, in
<7hk1bj$223$1@gellyfish.btinternet.com> wrote:

+ Just killfile the sucker and get on with the day.

Yes, yes, in moment...but why do I get the feeling this is topmind
getting around to learning perl?

James


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

Date: 15 May 1999 17:54:42 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: TROLL ALERT (Re: Perl "constructors")
Message-Id: <yln1z54ywd.fsf@windlord.stanford.edu>

Jonathan Stowe <gellyfish@gellyfish.com> writes:

> Come on guys cant you see this for the troll that it so obviously is.
> Just killfile the sucker and get on with the day.

I enjoy an occasional opportunity to try to express what I think is the
essence of Perl.  Even if someone's trolling, giving me an opportunity to
do that is something that I'm grateful for.  :)

And I don't think he's really trolling.  I just don't think he's used
enough different programming languages, so he's uncomfortable with things
working very differently when he changes programming languages.  But
that's just a guess, without much basis.

-- 
#!/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: 15 May 1999 17:58:27 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: TROLL ALERT (Re: Perl "constructors")
Message-Id: <ylk8u94yq4.fsf@windlord.stanford.edu>

Arved Sandstrom <Arved_37@chebucto.ns.ca> writes:

> But a fixed name for an object constructor ('new') is a feature of C++
> and Java, for example. Why should Perl be defiantly different?

I don't think this is quite entirely true.

To me, a constructor is a function that I call to get a new object of a
given type.  This isn't how C++ uses the term, but it's the *intuitive*
definition of the term for me.  C++ therefore has all sorts of
constructors that aren't named "new()"; anything that creates a new object
and returns it is a constructor.

If you really want to use C++'s definition for constructor, Perl *does*
only have one constructor.  bless().

-- 
#!/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: Sat, 15 May 1999 17:47:19 -0500
From: ktb <xyf@inetnebr.com>
Subject: Re: uninitialized value
Message-Id: <373DF977.402BB06C@inetnebr.com>

I just want to apologize for the multiple postings.  It was not
intentional.
Thank you for the responses.
kent


Bart Lateur wrote:
> 
> ktb wrote:
> 
> >> > Hi, I'm writing this script to search a database.  It works fine when I
> >> > search the first split, "$parts[0]" but if I try to search "$parts[1]" I
> >> > get the following errors:
> >>
> >> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> >> > 11461.
> >> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> >> > 11461.
> 
> >Yes the data is separated by a tab between the bottle description and
> >the citation.  I'm sure there are a few mistakes but there are 6000 +
> >entries and as far as I can tell all entries but the ones containing the
> >word searched spit out the error.
> 
> >> >         @parts = split(/\t/, $line );
> >> >         $PartsFile = $parts[1];
> 
> A warning. Even if this line contains a tab, split() removes all empty
> fields at the end of the (would be) array. So
> 
>         $_ = "let's go\t";
>         @parts = split/\t/;
> 
> You might expect @parts to be
> 
>         ("let's go", "")
> 
> but in fact you have
> 
>         ("let's go")
> 
> If you then try to access the non-existent field $part[1], this is
> automatically filled in as undef() by Perl.
> 
> I guess that a nonexistent field isn't interesting to search through,
> anyway, so you could just do
> 
>         next unless defined($PartsFile = $parts[1]);
> 
> which does both the assignment and the test in one line.
> 
>    HTH,
>    Bart.


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

Date: Sun, 16 May 1999 00:20:19 GMT
From: mrowell@my-dejanews.com
Subject: Using Apple's Sherlock plugins from perl
Message-Id: <7hl302$ps2$1@nnrp1.deja.com>

I would like to be able use Apple's Sherlock plugins to conduct searches
of the major internet search engines from within perl.
I think that it would not be to hard to interpet the sherlock plugins
with perl, but as I am fairly new to perl I'm not sure if anybody else
would have already done this already. (is there any standard way to find
out - I've searched the newsgroups & CPAN already)
And if nobody has I think I shall take it on as project to get a good
handle on perl.

Marcus.


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

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

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