[6722] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 347 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 22 20:07:22 1997

Date: Tue, 22 Apr 97 17:00:37 -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           Tue, 22 Apr 1997     Volume: 8 Number: 347

Today's topics:
     Re: -Niki Cox Nude <eryq@enteract.com>
     Re: Back References (Tad McClellan)
     Re: Back References <ajohnson@gpu.srv.ualberta.ca>
     Re: C++Builder means Future. <knovitsk@dbna.com>
     date function for win32 <rhz@po.cwru.edu>
     Re: Document Contains No Data <minaret@sprynet.com>
     Re: executing perl scripts <minaret@sprynet.com>
     Re: Kudos to Tom Christiansen and problems with OO <alf@orion.it>
     Re: Lisp is neither (was Re: Ousterhout and Tcl lost th (Jason V. Robertson~)
     Re: Lisp is neither (was Re: Ousterhout and Tcl lost th (Bjxrn Remseth)
     Making bigperl 5.003 work (MSDOS) (Bruce Atherton)
     Re: need short script to replace txt file without fefre <minaret@sprynet.com>
     Re: Odd array sizing information (Mik Firestone)
     Re: Ousterhout and Tcl lost the plot with latest paper <graham.hughes@resnet.ucsb.edu>
     Perl and WTMP (SysAdmin)
     Re: Perl compiler <minaret@sprynet.com>
     Perl Documentation (Oren Civier)
     Re: pod2info or info pages (Ilya Zakharevich)
     Re: Redirecting to URL <minaret@sprynet.com>
     Re: Running Perl script on NT (Craig S. Riter)
     Re: sorting hashes on values (David Alan Black)
     Re: sorting hashes on values (Terrence M. Brannon)
     Re: Variable interpolation (substitution) (SysAdmin)
     Re: Who makes more $$ - Windows vs. Unix programmers? <scott@conxion.com>
     why cant I access/print a list-of-lists this way (Terrence M. Brannon)
     Why is perl math so slow? <kevina@clark.net>
     Win32 UNC path question (Jeff Lawrence)
     Re: Working perl script... not running with HTTP get. <alf@orion.it>
     Re: writing to text file from Perl ... (Tad McClellan)
     XSUB: hash -> C struct ? (Matt Garretson)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 22 Apr 1997 17:54:43 -0500
From: Eryq <eryq@enteract.com>
Subject: Re: -Niki Cox Nude
Message-Id: <335D41B3.76A83500@enteract.com>


This spam apparently originated from earthlink.net.
I went to their contact page:
 
	http://www.earthlink.net/company/contact_info.html

and sent mail regarding this incident to:  

	abuse@earthlink.net
	sales@earthlink.net
	kfitzsim@earthlink.net		(public relations)

I probably should have sent it to root as well.  

Legal or not, I think it's pretty clear that we're looking
at net abuse, and I want to stomp this kind of thing before
we're all hip-deep in spam.  

I suggest that anyone else who feels strongly about this 
abuse of c.l.p.misc, please feel free to send a CALM, SHORT EMAIL
regarding this incident to any of the above addresses... 
DO NOT MAILBOMB EARTHLINK OR THE SUSPECTED CULPRIT, OKAY?  
The WORST thing you can do is sink down to that level.

Regards, 		
-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@enteract.com)
 / _ \| '_| | | |/ _ ' /  Hughes STX, NASA/Goddard Space Flight Cntr.
|  __/| | | |_| | |_| |   http://www.enteract.com/~eryq
 \___||_|  \__, |\__, |___/\  Visit STREETWISE, Chicago's newspaper by/
           |___/    |______/ of the homeless: http://www.streetwise.org


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

Date: Tue, 22 Apr 1997 14:36:59 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Back References
Message-Id: <r04jj5.sb3.ln@localhost>

Stefano Barbato (mc4650@mclink.it) wrote:
: I would like to print from a HTML file all html tags needed to create a Form. 
: Then I would like to use a unique regular expression to do this work:
:  
: undef($/)'; #  all file
: $_ = <HTMLFILE>;
: /(<form.*?>).*?(<input.*?>).*?(<\/form>)/i
: print $1, $2, $3;

: This work but only for one <INPUT> field...to print all present input field I 
: tried to use di expr:

: /(<form.*?>).*?(<input.*?>.*?)*.*?(<\/form>)/i
: print $1, ?????????

: - How can I refer to the 3rd, 4th, 5th, etc. <input> field (if any, of course) 
:   to print them out?
: - I need to include (<input.*?>.*?)* to match all input field but what I need  
:  is only the complete INPUT tag not text between INPUTs field (.*?). How I 
: include nested ()s like  ((<input.*?>).*?)* to back reference only important 
: chars.


If you only want the <input> tags, then just match only the <input> tags.

If you are planning to ignore the .*? in between tags anyway, then why
match them at all?


Will this work for you?

push(@input, $1) while /(<input[^>]*>)/gi;

foreach (@input) {print "$_\n"}



:  I now that my english is terrible...;-( 

I've seen worse from native speakers...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 22 Apr 1997 15:55:30 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Back References
Message-Id: <335D25C2.2AB751CB@gpu.srv.ualberta.ca>


Stefano Barbato wrote:
!
! I would like to print from a HTML file all html tags needed
! to create a Form.  Then I would like to use a unique regular
! expression to do this work:
!  
! undef($/)'; #  all file
! $_ = <HTMLFILE>;
! /(<form.*?>).*?(<input.*?>).*?(<\/form>)/i
! print $1, $2, $3;
! 
! This work but only for one <INPUT> field...to print all
! present input field I tried to use di expr:
! 
! /(<form.*?>).*?(<input.*?>.*?)*.*?(<\/form>)/i
! print $1, ?????????
! 
! - How can I refer to the 3rd, 4th, 5th, etc. <input> field
!   (if any, of course) to print them out?
! 
! - I need to include (<input.*?>.*?)* to match all input
!   field but what I need is only the complete INPUT tag not
!   text between INPUTs field (.*?). How I include nested ()s
!   like ((<input.*?>).*?)* to back reference only important
!   chars.

I think you might be looking for something along the
lines of: 

undef($/); #  all file
$_ = <HTMLFILE>;
print "$1\n" while /(<form.*?>|<input.*?>|<\/form>)/ig;


regards
andrew


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

Date: Tue, 22 Apr 1997 17:14:38 -0400
From: knovitsk <knovitsk@dbna.com>
Subject: Re: C++Builder means Future.
Message-Id: <335D2A3E.41C6@dbna.com>

> > >I just got C++Builder and I have never seen a powerful RAD tool like
> > >this  one.
> > ....
> > And if only it was on Linux, we'd be in hog-heaven.  Thing is, it's on
> > MS-Windows.
> 
> Who needs it? We're already in "hog-heaven" with easily the most robust
> compiler around...and we have the source to it! Add gcc to a customized
> emacs environment under X! Short of having the code write itself, what
> else could one desire in a development environment?
> 

Have you ever used C++ Builder?
I used both gcc and C++ Builder and although GCC is a nice compiler
there is a light years of difference between them...not in a compiler
but in an environment and component architecture....


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

Date: Tue, 22 Apr 1997 18:26:06 -0400
From: Don't Ask Don't Tell <rhz@po.cwru.edu>
Subject: date function for win32
Message-Id: <335D3AFE.22EF@po.cwru.edu>

How do you call the date in a yymmdd format with perl in a win 32
enviroment

Thanks in advance


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

Date: 22 Apr 1997 23:37:19 GMT
From: "Geoff Mottram" <minaret@sprynet.com>
Subject: Re: Document Contains No Data
Message-Id: <01bc4f75$f5a795e0$c56eafce@cactus>

> I have a simple URL selection script that keeps giving me "Document
> Contains No Data" when using Netscape 3.01. The problem doesn't appear
> when I'm using MSIE 3.02. I recently moved the website from Unix to
> Window NT. All other Perl scripts work fine.

This usually means that the Perl script died or closed its socket
connection before sending anything out.  I have also experienced some wierd
things with the Netscape Browser when setting cookies.

-- 
Geoff Mottram
minaret@sprynet.com


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

Date: 22 Apr 1997 23:39:24 GMT
From: "Geoff Mottram" <minaret@sprynet.com>
Subject: Re: executing perl scripts
Message-Id: <01bc4f76$40862680$c56eafce@cactus>

> I have this perl script that will just not execute.  I have flaged it
> read and execute globally so that anyone can execute it, i have made
> html scripts that #exec it and i have run the script on its own, it just
> doesn't seem to work.  I have included a copy of the script for you to
> look at and if you can let me know of any problems please e-mail me at
> any of the addresses at the bottom of the page.

This is probably a HTTP server problem.  Are you sure that the script is in
a "cgi-bin" type directory.  Some servers also support the convention that
a cgi script must have a ".cgi" file name extension in order to execute the
program instead of just returning it as a text file.

-- 
Geoff Mottram
minaret@sprynet.com


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

Date: 22 Apr 1997 23:55:38 +0200
From: Alessandro Forghieri <alf@orion.it>
Subject: Re: Kudos to Tom Christiansen and problems with OO
Message-Id: <m1afmq67tx.fsf@aldebaran.orion.it>

pudge@pobox.com (Chris Nandor) writes:
> 
> While I understand your frustration, it sounds as though you feel it is the
> obligation of people here to help you.  That is a bit presumptuous.
> 

I would like to point out that the original poster was *thanking* Tom
for answering, *not* chastising the rest of the world for doing it.
At least, that was my perception.
And about giving (and taking) free time: isn' that just about the point
of usenet?
Cheers,
	Alessandro Forghieri

-- 
'There's nothing like eating hay, when you're faint', he remarked to
her, as he munched away.  'I should think throwing cold water over you
would be better' Alice suggested 'or some sal-volatile' 'I didn't say
there was nothing *better*' the King replied 'I said there was nothing
*like* it'

Alessandro Forghieri              http://www.orion.it/~alf


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

Date: 22 Apr 1997 19:38:34 GMT
From: jvrobert@sedona.intel.com (Jason V. Robertson~)
Subject: Re: Lisp is neither (was Re: Ousterhout and Tcl lost the plot)
Message-Id: <5jj43q$sk9@chnews.ch.intel.com>

In article <hbaker-2104972352300001@10.0.2.1>,
Henry Baker <hbaker@netcom.com> wrote:
>
>In article <slrn5lnl9m.la9.mike@ducky.net>, mike@ducky.net (Mike Haertel) wrote:
>
>>         * LispM's were not multi-user - they could have only
>>           one logged-in user at a time, although they did
>>           provide a degree of remote access.
>
>LispM's had a full multithreaded environment--something not seen in
>personal computers until very recently.  Apple is still having difficulties
>with this one.

Of course, being multithreaded has nothing to do with being multi-user.
Take NT, for example.

>>         * LispM's were not secure - the whole system, including
>>           the operating system kernel, ran in a single giant
>>           address space.
>
>A better way of saying this is that LispM's are much _more_ secure, because
>every item has its hardware datatype which is religiously checked on every
>access.  LispM's weren't the machines crashing when those internet worm
>attacks were going on!

Neither were PC's running Novell.  Of course LispM's wouldn't be affected - 
the worm targetted only Unix machines running Sendmail (I think?).
-- 
|Jason V. Robertson <jvrobert@sedona.intel.com> |
|Not speaking for Intel.                        |


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

Date: 22 Apr 1997 23:31:36 +0200
From: rmz@hridil.ifi.uio.no (Bjxrn Remseth)
Subject: Re: Lisp is neither (was Re: Ousterhout and Tcl lost the plot)
Message-Id: <aj912asq13.fsf@hridil.ifi.uio.no>


"M. Prasad" <prasadm@polaroid.com> writes:

> If this experience is BS, what is the truth?  Why _did_
> the Lisp machines die?  People keep blaming "marketing", but
> did LMI/Symbolics founders not have enough smarts or the money
> to hire some good marketing people?  I would doubt either
> of these two was the case.

Well, I am not too sure about that, I have seen worse examples of
misjudgement from management :)

My 0.02 USD worth of theory on the failure of the lisp-machines is:
The machines were pretty expensive. At least initially, they were also
targeted at a very limited market (the AI market) which then sort of
collapsed (details omitted :).  Now, the Lisp machines were truely
excellent at interoperability and communication with just about any
weird piece of hardware, language, file-format and network protocol,
so "not compatible" was probably a very minor issue. But you _did_
need to be very rich to get one in the first place.  If you had any
sanity at all (not all rich people do :), you probably also needed a
very good product idea before you could justify the kind of investment
such a machine represented, _and_ you needed to be pretty successfull
in the execution of your project to defend the investment afterwards.
This last issue was probably particularly true if your project ran
over budget, didn't complete properly or ran into any number of other
problem not necessarily related to your unconventional choice of
plattform

Now, are these kinds of issues marketing issues? Yes probably.


-- 
                                                    (Rmz)

Bj\o rn Remseth   !Institutt for Informatikk    !Net:  rmz@ifi.uio.no
Phone:+47 22855802!Universitetet i Oslo, Norway !ICBM: N595625E104337


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

Date: Tue, 22 Apr 97 20:52:46 GMT
From: bruce@flair.law.ubc.ca (Bruce Atherton)
Subject: Making bigperl 5.003 work (MSDOS)
Message-Id: <5jj8dh$9n6$1@nntp.ucs.ubc.ca>
Keywords: help MSDOS perl perl5 bug

I've been trying to get a working perl 5.003 for MSDOS.  I thought that 
bigperl was the answer, until I ran into a bug with "readdir".  Although the 
correct number of files are returned, the file names are all blank.

The "readdir" function is absolutely required by my script, as are backticks 
(which is why I'm not using the OS/2 port for MSDOS).

I am running 4DOS 5.52A, MS DOS 6.22 (also tried with MSDOS 7), PC-NFS (also 
tried Hummingbird NFS), bigperl 5.003 with EMBED, built under win95 Dec 21/96 
+ suidperl security patch.

Any help greatly appreciated.  Thanks.


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

Date: 22 Apr 1997 23:42:33 GMT
From: "Geoff Mottram" <minaret@sprynet.com>
Subject: Re: need short script to replace txt file without fefreshing screen
Message-Id: <01bc4f76$b10bb140$c56eafce@cactus>

> I'm new at this yet but with a little script that takes a get from html
one
> text field and submit and writes the variable to a .txt file with out
> refreshing the html page at all.
> needs to be simple and complete with html.
> thanks,

If the browser is submitting the form back to the server, you have to send
something back.  If you want the page to look the same, you will have to
send it back with all of the fields filled in with the same data you got
from the browser.

-- 
Geoff Mottram
minaret@sprynet.com


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

Date: 22 Apr 1997 19:40:01 GMT
From: mfiresto@vnet.ibm.com (Mik Firestone)
Subject: Re: Odd array sizing information
Message-Id: <5jj46h$ohu$1@mail.lexington.ibm.com>

In article <335CE558.57C2@nortel.ca>,
Dan Caugherty  <nospam!dcaugh@nortel.ca> wrote:
>TWIMC --
>
>Hi!  I ran across what I believe to be a Perl bug.
>Given the following snippet:
># --------------------------------------------
># For sake of argument, assume $#some_array == 25
>@new_array = ();
>print $#some_array, "   ";
>for($i = 0; $i < $#some_array; $i++)
Ouch, that'll hurt.  $#some_array is the subscript of the last element of
@some_array.  In this case, that would be 24.  What you really wanted was
@some_array.  Or you wanted to say:
 for( $i = 0; $i <= $#some_array; $i++ )

>Is this a bug?  If so, has it been fixed?  If not,
>what Perl nuance am I missing here?
Nope, no bugs here.

Mik
-----
Mik Firestone  mfiresto@mindspring.com
Evil Overlord Rule #4: Shooting is _not_ too good for my enemies.



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

Date: 21 Apr 1997 01:00:08 -0700
From: "Graham C. Hughes" <graham.hughes@resnet.ucsb.edu>
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <87wwpw6c0z.fsf@A-abe.resnet.ucsb.edu>

-----BEGIN PGP SIGNED MESSAGE-----

>>>>> "Bruce" == Bruce S Tobin <btobin@infinet.com> writes:

Bruce>   OO alone won't increase productivity significantly, but if
Bruce> you take a well-designed OO language (i.e., pretty much
Bruce> anything except C++), and add a good class library and
Bruce> application framework aimed at a particular problem domain,
Bruce> your productivity gains can be very impressive; often greater
Bruce> than what you get with a scripting language tailored to the
Bruce> same domain.

Interestingly, I've found that even C++ works this way.  A simple case
in point: often I need to read strings from an input channel into an
associative array.  I certainly could do this in Perl, where it is
very easy, or Python, also easy.  However, because of
	- the draft ANSI standard's string class
	- STL's map<>
	- and libg++'s Regex class
I can and have done it in C++ with very little effort.  Without these
classes, I wouldn't even think about doing it in C++.

A good case example is Perl.  Quite a lot of people think that the
popularity of Perl is because of some innate desire for `sinful'
languages.  I content that this has nothing to do with it; Perl is
popular precisely because there is a module for just about every need.
Before I found a special purpose C POP3 client, I hacked one up in
Perl in only a few lines, because I had a POP3 library available to
me.  Given a POP3 library in language x, I could do the same thing;
Tcl exists and is useful largely because of Tk.

I don't traditionally program in Scheme or Common LISP,
not because I don't have interpreters or compilers for them, but
because they aren't good enough at string processing to interest me.
Similarly for Ada.  On the other hand, Icon is beautiful at string
processing, but can't do other useful things like sockets.

Frankly, if you want me to use language x, you'll have to give me some
enticement.  I imagine that there are other programmers who
feel the same way I do.
- -- 
Graham Hughes    http://A-abe.resnet.ucsb.edu/~graham/     MIME & PGP mail OK.
const int PGP_fingerprint = "E9 B7 5F A0 F8 88 9E 1E  7C 62 D9 88 E1 03 29 5B";
   #include <stddisclaim.h>

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3
Charset: noconv
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQCVAwUBM1sekCqNPSINiVE5AQGuAQP+Iy/djVsUkdA6h+BtTuO8W/vP+yqS2tlw
wG7Y43d4If+5GVZHtx1nnpscM/nBByOB0uwXkbzOAZHWbZN/KrA9z2UUvlGuCUgm
CARtEfYrEwLVhAql9QvnShgSZKJS0xaervWt+QHTHjDHNp5X4LIBkz5nTMsHOFtM
MZ4VH2mD7SI=
=aUbv
-----END PGP SIGNATURE-----


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

Date: 22 Apr 1997 17:18:34 GMT
From: matrix@I_should_put_my_domain_in_etc_NNTP_INEWS_DOMAIN (SysAdmin)
Subject: Perl and WTMP
Message-Id: <5jirta$f0h@news.nfinity.com>

soo, anybody got any ideas on how to go about extracting data from the
linux /var/log/wtmp file through perl?  I've tried all the docs I could
find (ie, man wtmp, man login, and the camel book) and the best I've come
up with so far is

open(WTMP, "/var/log/wtmp");
while(read(WTMP, $wtmp, 36) {
	$line = unpack('A8A8A16l', $wtmp);
	print $line;
}

and all I can manage to make sense of is the date, which seems to be
right.

Has anybody else done this?  need help or divine intervention.

Thanks,

Tim
trussell@nfinity.com


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

Date: 22 Apr 1997 23:43:54 GMT
From: "Geoff Mottram" <minaret@sprynet.com>
Subject: Re: Perl compiler
Message-Id: <01bc4f76$e177eec0$c56eafce@cactus>

> Is there a Shareware Perl compiler?

There is a compiler that takes Perl and turns it into C.  Look at the CPAN
archive.

-- 
Geoff Mottram
minaret@sprynet.com


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

Date: Tue, 22 Apr 1997 22:52:15 GMT
From: tzvayor@mail.tlm.openu.ac.il (Oren Civier)
Subject: Perl Documentation
Message-Id: <E92ABG.28r@cs.openu.ac.il>

I was looking for the Perl Manuals in the HTML format.
Unfortunetlly I found all the manuals except the HTML pages discribing
the perl functions ( I don't mean to the page perlfunc.html but to the
pages for each function ). For some reason they don't appear on
any of the CPAN mirrored sites.

Please help me,
	The man page in his standard format is very hard to read
	( all functions appear in the same man page ! )




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

Date: 22 Apr 1997 21:15:28 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: pod2info or info pages
Message-Id: <5jj9pg$cfq$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Clark Dorman 
<dorman@s3i.com.ANTI-SPAM>],
who wrote in article <d7mhw5ins.fsf@s3i.com>:
> 
> I'm working on perl in emacs, and the easiest way to use the manual is
> to use GNU info pages in emacs.  However, I cannot find a pod2info.
> Does one exist?
> 
> The only thing that I have been able to find is pod2texinfo.  This
> works without crashing, but then makeinfo does not work on the
> outputs.
> 
> I was using:
> 
> pod2texinfo:	http://www.perl.org/CPAN/doc/pod2x/pod2texinfo
> makeinfo:	GNU Makeinfo (Texinfo 3.9) 1.67

Get the compiled version from CPAN (CPerl might even document the
location), and inform the author of pod2texinfo about the bugs.

Ilya


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

Date: 22 Apr 1997 23:30:53 GMT
From: "Geoff Mottram" <minaret@sprynet.com>
Subject: Re: Redirecting to URL
Message-Id: <01bc4e62$48224be0$b2ebaec7@cactus>

> I know the format to direct the user to a URL in Perl is:
> 
> 	print "Location: xxxxxxx.com\n";
> 
> But, let's say I have already printed some text in the browser window:
> 
> 	print "Content-type: text/html\n\n";
> 	print "blahblahblah\n";
> 
> How can I direct the user to a URL after doing this?

You have to send back the "Location" line first.  The work-around is to
build your HTML response in a Perl variable.  If you decide somewhere in
the middle of your response that you want to redirect the caller, you print
"location..."  otherwise you print $response.

-- 
Geoff Mottram
minaret@sprynet.com


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

Date: Tue, 22 Apr 1997 21:25:28 GMT
From: criter@lucent.com (Craig S. Riter)
Subject: Re: Running Perl script on NT
Message-Id: <335d2c21.23749253@nntp.cb.lucent.com>

I think you need to tell WinNT how to execute the Perl script.  WinNT
does not read the #! line to find out how to interpret the script.
You need to add a registry setting to tell IIS to execute all .cgi or
 .pl files with the Perl intepretor.  There are some pages around that
tell how to do this, try doing a search with dejanews


craig@riter.com

On Sun, 20 Apr 1997 16:51:21 -0600, jhardy@cins.com wrote:


______________________________________________________________________
Craig S. Riter         criter@riter.com         criter@povpartners.com
www.riter.com                           PGP key available upon request
It infuriates me to be wrong when I know I'm right.           -Moliere


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

Date: 22 Apr 1997 23:03:30 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: sorting hashes on values
Message-Id: <5jjg42$mal@pirate.shu.edu>


Hello -

Hans Suijkerbuijk <Hans.Suijkerbuijk@SD.BE> writes:

>Hi,

>specs: I'm using Perl 5.001 on NT 4.0.
>My problem:

>I get an undefined number of hashes as results of a query. (each hash is
>a record) In each hash i have three keys: code, title and a score. I
>want to collect the hashes (in a hash or in an array?) and then sort the
>collection of hashes according to the (integer) value of the key score
>before displaying the collection. How do I do this (i experimented a lot
>with sort-stuff, but nothing worked)?

Assuming this (the manner of arriving at the equivalent of
which will depend a lot on the context):

my @hashes = (
	    {   'code' => 'a',
                'title' => 'one',
                'score' => 93   },
            {   'code' => 'b',
                'title' => 'two',
                'score' => 89   },
            {   'code' => 'c',
                'title' => 'three',
                'score' => 99   } );

you could sort with this:
 
my @sorted = sort { $a->{score} <=> $b->{score} } @hashes;


David Black
dblack@icarus.shu.edu


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

Date: 22 Apr 1997 16:32:35 -0700
From: brannon@bufo.usc.edu (Terrence M. Brannon)
Subject: Re: sorting hashes on values
Message-Id: <ysizwwputz0c.fsf@bufo.usc.edu>

aml@world.std.com (Andrew M. Langmead) writes:

> 
> Maybe this should be mentioned in the
> FAQ. <http://www.perl.com/CPAN/docs/FAQs/> It does have a "How do I
> sort an array by (anything)?", but the answer doesn't give any
> examples where "(anything)" is a reference to an array or hash.

Try the Perl Data Structures Cookbook at CPAN/doc under FMTYEWTK

-- 
o============o  Sending  unsolicited commercial e-mail (UCE) to this address
 Legal Notice   is indication of your consent to pay me $120/hour for 1 hour
o============o  minimum for professional proofreading & technical assessment.
terrence brannon * brannon@kappa.usc.edu * http://rana.usc.edu:8376/~brannon


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

Date: 22 Apr 1997 17:15:05 GMT
From: matrix@I_should_put_my_domain_in_etc_NNTP_INEWS_DOMAIN (SysAdmin)
Subject: Re: Variable interpolation (substitution)
Message-Id: <5jirmp$f0h@news.nfinity.com>

John Adamson (j-adamson@tamu.edu) wrote:
: Could use some advice on variable interpolation (as Wall uses 
: the term) in a conditional statement.

: Consider this simple statement:
:   for ($i=1;$i<=10;$i++){print "$i\n";}

: Is it possible to use:
:   for ($arg1;$arg2;$arg3){print "$i\n";}
: where $arg1-3 are defined elsewhere?

try eval "for ($arg1;$arg2;$arg3) {print \"$i\n\";}" instead. eval,
although I try not to use it because of the overhead, works fine for small
programs. 

: Seems like it oughta be simple but haven't been able to get 
: it to work.  Thoughts will be appreciated and - if this is an 
: incredibly dumb question - well, heck, I'm sorry.  TIA ..
: ja


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

Date: Tue, 22 Apr 1997 15:36:39 -0700
From: Scott Sewall <scott@conxion.com>
To: Sometimes Brian <brianm@ricochet.net>
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <335D3D77.167EB0E7@conxion.com>

Sometimes Brian wrote:
> 
> On Sat, 22 Mar 1997 22:32:12 -0600, Marion Evans
> <marion.evans@wcom.com> wrote:
> 
> >Novell treated Unix with same reverance as WordPerfect alright
> >Noorda's sucksessor Frankenstein sold Unix and UnixWare to Sun
> >Even still the Unix - Sun deal was done bout a year before the
> >WP - Corel deal.
> 
> Actually,  SCO bought Unix from Novell, and currently own the Unix
> system.  I don't think that Sun owns Unix at all.
> 
> Brian Moffet
> brianm@ricochet.net      Brian D. Moffet
> 
> Be careful believing what I say, I have been known to be
> wrong before.

FYI

UNIX is a registered trademark in the US and other countries, licensed
exclusively through X/Open Company Ltd


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

Date: 22 Apr 1997 14:20:54 -0700
From: brannon@bufo.usc.edu (Terrence M. Brannon)
Subject: why cant I access/print a list-of-lists this way
Message-Id: <ysiz3esivjnx.fsf@bufo.usc.edu>

@vilist = ( [ $p, $s ] , [ $p, $s ] , [ $s , $p ] , [ $s , $p ] );
@ivlist = (0,1,0,1);

foreach $vi (@vilist) {
    foreach $invariant_value (@ivlist) {
	print "=" x 50;
	print "\n";
	$variant   = $vi[0]; # <--- this line
	$invariant = $vi[1]; # <--- and this line both fail
    
	$filename="$invariant" . "=" . "$invariant_value";
	print $filename, $/;

    }
}

-- 
o============o  Sending  unsolicited commercial e-mail (UCE) to this address
 Legal Notice   is indication of your consent to pay me $120/hour for 1 hour
o============o  minimum for professional proofreading & technical assessment.
terrence brannon * brannon@kappa.usc.edu * http://rana.usc.edu:8376/~brannon


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

Date: Tue, 22 Apr 1997 18:51:31 -0600
From: Kevin Atkinson <kevina@clark.net>
Subject: Why is perl math so slow?
Message-Id: <861752658.11197@dejanews.com>

Could some one explain to me why perl is so slow at arithmetic
compared to C++.

For example here are two programs that do exactly the same thing.

// file test.c
#include <iostream.h>
#include <time.h>

void main ()
{
  double a = 1, b;
  long start;
  cout.precision(15);
  time(&start);
  for (long i=0; i < 12345678; i++) {
    b=a*87.76;
    a++;
  }
  cout<<"a="<< a <<" b="<<b<<" This took: " << time(0) - start << "s\n";
}

#file test.pl

$a=1;
$start = time;
for($i = 0; $i < 12345678; $i++) {
   $b = $a * 87.76;
   $a++;
}
print "a=$a b=$b This took: ",time - $start, "s \n";

And here is the output

$ g++ test.c
$ a.out
a=12345679 b=1083456701.28 This took: 5s
$ perl test.pl
a 12345679 b=1083456701.28 This took: 100s

What is going on here.  It is doing arithmetic on a diffrent value of
a every time so it could not possibly be caching the answer.  I am
very puzzled by this.  (I expected it to be a but slower but not 20x.)

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Mon, 21 Apr 1997 01:40:01 GMT
From: jeff@qcsn.com (Jeff Lawrence)
Subject: Win32 UNC path question
Message-Id: <335ac4a3.31582032@news.qcsn.com>


I am relatively new to Perl and haven't found an answer
in any FAQ's.  I need to copy several files/directories to
a UNC path, i.e \\Server\share\dir

In addition, I need to see if this directory exist and if not
create it.  What are my options?  

Any answers or pointers to docs would be most appreciated.

TIA




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

Date: 22 Apr 1997 23:49:55 +0200
From: Alessandro Forghieri <alf@orion.it>
Subject: Re: Working perl script... not running with HTTP get.
Message-Id: <m1bu76683g.fsf@aldebaran.orion.it>

webmaster@componentweb.com (nick^) writes:

> Here's the script:
> #!/usr/bin/perl
> # Program to do the obvious
> #
> print 'Hello world xxx.';           # Print a message
> 

Does the obvious include

print STDOUT "Content-type: text/plain\n\n";

?

It's all in the FAQ....

Cheers,
	ALessandro Forghieri


-- 
'There's nothing like eating hay, when you're faint', he remarked to
her, as he munched away.  'I should think throwing cold water over you
would be better' Alice suggested 'or some sal-volatile' 'I didn't say
there was nothing *better*' the King replied 'I said there was nothing
*like* it'

Alessandro Forghieri              http://www.orion.it/~alf


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

Date: Tue, 22 Apr 1997 14:40:31 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: writing to text file from Perl ...
Message-Id: <f74jj5.sb3.ln@localhost>

Bob (xxbbell@voicenet.com) wrote:

: Mark Smith <mark@backlash.net> wrote:
: >I am trying to write to a text file through my perl script, however, I
: >want to post to the top of the files rather than the bottom without
: >having to write the entire file in an array and re-writing it.  By
: >re-writing the file over and over again, it seems like I am losing data
: >because it cuts the very bottom of the file off and I sometimes get
: >fifteen million squares in the middle of my file.  The whole procedure
: >is just unstable.  When I had the script writing to the bottom of the
: >file, I did not have any of these problems, however, I need the text
: >files to read in chronological order (top to bottom, as opposed to
: >bottom to top) because, well, that is what my boss said.  Please help! 
: >thanks!!!
: >
: >Lina
: >lina@ty.com

: 	I'm a newbie to Perl, but you could do what I did.  Recently I
: wrote a perl script to create MOTDs, with a log, and I wanted the most
: recent at the top.  What I wound up doing is appending to the file.
: The files are then in reverse order.  I then read the entries in when
: it was time to view the MOTD and just did a reverse.  Adding an MOTD
: was therefore fast, and since I was reading the  whole file when
: viewing an MOTD, the only extra bit was a "reverse" of an array after
: the array was already in memory, which didn't seem to be bad at all.
: Not sure if this will apply to you, or if there is a better way (>+?).
                                                                   ^^^

That is a worse way  ;-)

The original contents of the file will be *wiped out* that way.

I think reading about open() in the perlfunc man page would 
be a good idea...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 22 Apr 1997 14:53:24 -0400
From: garrem@rpi.edu (Matt Garretson)
Subject: XSUB: hash -> C struct ?
Message-Id: <5jj1f4$2ce2@alumni.rpi.edu>

Is there a commonly accepted "best" way to map a perl5.004 hash to a C
struct when doing XSUB programming?  Up to now, i've simply been doing
a lot of hv_fetch()es to get hash values into the proper spots of the
struct.  This strikes me as a little cumbersome.

I saw one module which used perl's pack() to form a string which the
XSUB pretty much just slapped onto a struct.  I guess that's quick, but
it bothers me that it assumes things about the alignment & storage in
the struct.

I assume that there are a number of alternative ways to do this kind of
thing.  Maybe there is a better way in perl than a hash to represent C
struct data?  Maybe i'm missing something obvious?

I'm just getting started in this, and while the man pages & FAQs have
been helpful, i've had trouble finding examples i could understand.
Any tips/pointers/RTFM's would be greatly appreciated.

Thanks,
-Matt



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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