[12099] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5699 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 17 12:07:22 1999

Date: Mon, 17 May 99 09:00:17 -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           Mon, 17 May 1999     Volume: 8 Number: 5699

Today's topics:
        ADO and Perl <wesley@persup.com>
    Re: Duplicate Line - ignoring second line of text <gary@rdss.com>
        fetching specific info from a text file <ba@iamd.com>
        file locking <tk@toilets.freeserve.co.uk>
    Re: help, A Simple Question (Larry Rosler)
    Re: MacPerl (Chris Nandor)
    Re: Monadic classes, eponymous metaobjects, and translu <garethr@cre.canon.co.uk>
    Re: Monadic classes, eponymous metaobjects, and translu <tchrist@mox.perl.com>
    Re: Occasional user (Bart Lateur)
    Re: Perl "constructors" <jdporter@min.net>
    Re: Perl "constructors" <jdporter@min.net>
    Re: Perl "constructors" <jdporter@min.net>
    Re: Perl "constructors" (Larry Rosler)
    Re: Perl "constructors" (M.J.T. Guy)
    Re: Perl and Oracle <matte_8000@my-dejanews.com>
        Perl to C translator? cpeters7873@my-dejanews.com
    Re: Perl to C translator? <dataadm@elfi2.rz.ruhr-uni-bochum.de>
    Re: Problem with CGI.pm need an example bmccormack7477@my-dejanews.com
    Re: Sorting is too slow for finding top N keys... - UPD (M.J.T. Guy)
    Re: Sorting is too slow for finding top N keys... - UPD (Bart Lateur)
        Weird socket behaviour <engjs@cc.newcastle.edu.au>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 17 May 1999 17:16:49 +0200
From: "Wesley" <wesley@persup.com>
Subject: ADO and Perl
Message-Id: <7hpbu2$ea2$1@nickel.uunet.be>

Does anyone have an example on how to access a SQL server database using ADO
in Perl?

TIA (please reply to my e-mail address).

--
Wesley (wesley@persup.com)
Visit http://www.persup.com




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

Date: Mon, 17 May 1999 11:56:59 -0400
From: Gary Ebert <gary@rdss.com>
Subject: Re: Duplicate Line - ignoring second line of text
Message-Id: <37403C49.99E10589@rdss.com>



Robert Bruno wrote:
> 
> How do I have the write the code to ignore the second line of text since
> it is a duplicate of the first line? Also, I want the string to selectively
> take data from the line. My hunch was to match the code outright,
> however, I don't want to parse the duplicate line.
> 
>                          ---- NUMBER OF PRIMARY CALLS -----
> TIME                OFFRD   HAND  OTHER   ABAND
> ---------------------------------------------------------------
>  10:30-10:59           205       190       3      10   95.0   5.0
> 
> 10:30-10:59           205       190       3      10   95.0   5.0
> 
> Please help.

I am not sure if it is your e-mail program or my reader or what.  But as I
look at your data these are not duplicate lines!  The first line starts with a
" " and the second does not.  If this is a typo or whatever then follow Tad's
advice.  However, if the leading " " is not a typo the solution will be at
least a little more complicated.
			Good Luck,
					Gary
-- 
Gary Ebert                                 Operations Administrator
Voice:     (301) 428-2115                  Comtech Mobile Datacom Corporation
Fax:       (301) 428-1004                  19540 Amaranth Drive
Pager:     (800) 777-4681   PIN: 3981842   Germantown, MD  20875-2126


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

Date: Mon, 17 May 1999 23:49:43 +0800
From: "Brian Altman" <ba@iamd.com>
Subject: fetching specific info from a text file
Message-Id: <7hpdin$id2$1@news.skyinet.net>

Hi there,

I am just beginning to learn how to program in Perl.
Right now I am wondering if it is possible to 'get' specific data from an
existing file (any text based file), and write it to a new file.

Can someone help me with this ?
Thanks a lot in advance !!





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

Date: Mon, 17 May 1999 16:41:23 +0100
From: "Troy Knight" <tk@toilets.freeserve.co.uk>
Subject: file locking
Message-Id: <7hpd9k$8p2$1@news6.svr.pol.co.uk>

This is a multi-part message in MIME format.

------=_NextPart_000_0039_01BEA084.19AC44C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

How does file locking work, i've looked for ages done the posts but =
can't find anything about it anywhere

------=_NextPart_000_0039_01BEA084.19AC44C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2014.210" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#d8d0c8>
<DIV><FONT face=3DArial size=3D2>How does file locking work, i've looked =
for ages=20
done the posts but can't find anything about it=20
anywhere</FONT></DIV></BODY></HTML>

------=_NextPart_000_0039_01BEA084.19AC44C0--



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

Date: Mon, 17 May 1999 07:46:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: help, A Simple Question
Message-Id: <MPG.11a9cb7a42731928989a80@nntp.hpl.hp.com>

In article <373ff3b0@news.uk.ibm.net> on Mon, 17 May 1999 13:52:36 
+0200, Vincent Vanbiervliet <vvb@ibm.net> says...
> dickyart <dickyart@hkstar.com> wrote in message
> news:373FD758.A94574AA@hkstar.com...
 ...
> > $B=(10,9,8,7,6,5,4,3,2,1,'BOOM');
> > @A=$B;
> Sam's suggestion is the best, but if you want to use $B (a scalar), and
> convert it into an array, you could use:
> @A=split /,/, $B;

Did you try that suggestion out before posting it?  I look in vain for a 
comma in $B to split on.  The value of $B is 'BOOM'.

Compiling the snippet with the '-w' flag would have made clear (to the 
original submitter and to you) what is going on here.

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


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

Date: Mon, 17 May 1999 15:05:08 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: MacPerl
Message-Id: <pudge-1705991105100001@192.168.0.77>

In article <therzog-1705990927540001@therzog-host105.dsl.visi.com>,
therzog@knotech.com (Tim Herzog) wrote:

# In article <bsharvyNOSPAM-1605991617510001@dynip132.efn.org>,
# bsharvyNOSPAM@efn.org wrote:
# 
# >I recently downloaded MacPerl 5.2. I can't quite figure out what you can,
# >and cannot do with it. Could you, in theory, build applications like
# >Clarisworks or Quake with it? Is it just for CGI work? If you can make
# >full featured mac applictions with it, is there a book telling how?
# 
# MacPerl has some API hooks and GUI functionality, but if you want to build
# full-blown, distributable apps, use something else.  For one thing,
# anything you write in MacPerl is going to need a perl interpreter (i.e.,
# MacPerl) to run, so you can't really build stand-alone apps.

Yes, you can.  You just need to include the MacPerl interpreter, saving it
as a standalone, and then including shared libraries in a separate
folder.  Not much different than doing Java standalones.

MacPerl will, at some point probably, be good for "standalone" apps with
full GUIs.  Right now its second biggest problem is that, while you can do
standalones, they are kinda complex to put together.  Its biggest problem,
though, is that the GUI modules are still kinda buggy in some ways.  I
would much rather do a GUI in MacPerl than C, if it were more stable.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Mon, 17 May 1999 15:41:08 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
To: tchrist@mox.perl.com (Tom Christiansen)
Subject: Re: Monadic classes, eponymous metaobjects, and translucent data members
Message-Id: <sin1z3g0vf.fsf@cre.canon.co.uk>

Tom Christiansen <tchrist@mox.perl.com> wrote:
> =head2 Monadic Classes
> 
> [snip]
> 
> Another sort of class that pops up from time to time is one that
> supports a unique instance.  Such classes are called I<monadic
> classes>, or less formally, I<highlander classes>, since there can be
> but a solitary instance of that class in creation at any one time.

I think that "Monadic Class" is a confusing choice of name for this
concept.

"Monadic" is widely used in the pure functional programming community to
describe a style of programming in which side-effects are emulated in
pure languages by encapsulating aspects of a program's state into a
continuation.  (The term "monad" comes from category theory where it
means a universal algebra.)  See Phil Wadler's tutorial "How to declare
an imperative", ACM Computing Surveys, 29(3):240-263, also at
http://cm.bell-labs.com/cm/cs/who/wadler/papers/monadsdeclare/monadsdeclare.ps

In the book "Design Patterns: Elements of Reusable Object Oriented
Software" (E. Gamma, R. Helm, R. Johnson and J. Vlissides;
Addison-Wesley 1995; see http://www.awl-he.com/titles/13933.html), your
"Monadic Class" is called a "Singleton".

I note that there's already a Class::Singleton module at CPAN.
http://www.cpan.org/modules/by-module/Class/Class-Singleton-1.03.tar.gz

-- 
Gareth Rees


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

Date: 17 May 1999 09:54:46 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Monadic classes, eponymous metaobjects, and translucent data members
Message-Id: <37403bc6@cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Gareth Rees <garethr@cre.canon.co.uk> writes:
:I think that "Monadic Class" is a confusing choice of name for this
:concept.
:
:"Monadic" is widely used in the pure functional programming community to
:describe a style of programming in which side-effects are emulated in
:pure languages by encapsulating aspects of a program's state into a
:continuation.  

Gosh, that's unfortunate.  Must rename variadic functions now, too? :-(

I'll think about it, but I don't find singleton as appealing as either
of my suggestions.  It reminds me of someone who can't get a date,
or something to short-suit into the blind.  I'd rather use highlander,
since THERE CAN BE ONLY ONE. :-)

--tom
-- 
There are probably better ways to do that, but it would make the parser
more complex.  I do, occasionally, struggle feebly against complexity...  :-)
            --Larry Wall in <7886@jpl-devvax.JPL.NASA.GOV>


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

Date: Mon, 17 May 1999 15:51:58 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Occasional user
Message-Id: <37403a35.442036@news.skynet.be>

Andre Giroux wrote:

>I am trying to convert a eps file into a pdf  file using a perl script
>(file created by Mathematica and to be included  in a pdf document).

I guess that's the EPS file, not the Perl script. The script probably
serves to do some processing on the file?

>Working on wintel, I downloaded perl and put my script in
>c:\perl\bin .

Bad place. Only stuff belonging to Perl itself should go there.

>The question is : what should I do next ? (Or is it : what should I have
>done before ? )
>A lost mathematician.

I guess you need to invoke the script with a command line like:

	perl script.pl thatfile.eps

where script.pl is the path to the script, and thatfile.eps is the path
to the epsfile.

My guess is that it's best to put the script next to the eps file, go to
the DOS prompt, chdir to that directory, and run the script with the
bare file names (no path). See what happens next.

	Hope this helps,
	Bart.


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

Date: Mon, 17 May 1999 14:45:16 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl "constructors"
Message-Id: <7hpa1r$grq$1@nnrp1.deja.com>

In article <7hjjuu$sbm$1@nnrp1.deja.com>,
  armchair@my-dejanews.com wrote:
> 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.

Heh.  If you were simply arguing that certain names are better than
others, and that programmers should therefore prefer them, then you
would have a point.  But (up to now, at least), you have been arguing
that perl should enforce a restriction on names, flagging some as
illegal.  That, of course, is the heresy.

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: Mon, 17 May 1999 14:58:45 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl "constructors"
Message-Id: <7hpar3$hdh$1@nnrp1.deja.com>

In article <7hjioj$rks$1@nnrp1.deja.com>,
  armchair@my-dejanews.com wrote:
> ... 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 know, an analogous situation exists in C++ (and in OO langs
in general, including Perl).

	class A;

	class B : A {
		public:
		int foo();
	};

	class C : A {
		public:
		int bar();
	};

	int f( A& a ) {
		a.foo();  // can I call this?
		a.bar();  // or this?  and how do I know?
	};

There are ways of dealing with this (ref. Meyers, item 39), but
they all involve quite a bit more machinery than an 'exists' test.

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: Mon, 17 May 1999 15:06:31 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl "constructors"
Message-Id: <7hpb9l$hra$1@nnrp1.deja.com>

In article <7hjk52$sd8$1@nnrp1.deja.com>,
  armchair@my-dejanews.com wrote:
> 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.

Suffice it to say that Perl is a highly context-sensitive language.
But the situation with curlies is not quite as you imply.
{} does not dereference a reference; to do that you need a type
symbol in front, i.e. ${}, @{}, %{}, &{}, *{}.  This eliminates the
ambiguity in this case.  From perlref:

         Because curly brackets (braces) are used for several
         other things including BLOCKs, you may occasionally have
         to disambiguate braces at the beginning of a statement
         by putting a + or a return in front so that Perl
         realizes the opening brace isn't starting a BLOCK.  The
         economy and mnemonic value of using curlies is deemed
         worth this occasional extra hassle.

In practice, I've never had a problem with this.  Ever.

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: Mon, 17 May 1999 08:18:47 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl "constructors"
Message-Id: <MPG.11a9d32f6894295c989a83@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <m1emkfsrxp.fsf@halfdome.holdit.com> on 17 May 1999 07:15:46 
-0700, Randal L. Schwartz <merlyn@stonehenge.com> says...
> >>>>> "Michael" == Michael Stillwell <mist@yoyo.cc.monash.edu.au> writes:
 ...
> Michael> #define X 0
> Michael> #define Y 1
 ...   
> Michael>   $self->[X] = $x;
> Michael>   $self->[Y] = $y;
 ...
> > This is precisely what "use fields" and the new pseudo-hash does in
> 5.005.  It's been tagged as an experimental feature, but give it a go
> and see what breaks.  From perlref for 5.005:
> 
>        Pseudo-hashes: Using an array as a hash
 ...
>        For this to work, the array must contain extra
>        information.  The first element of the array has to be a
>        hash reference that maps field names to array indices.
>        Here is an example:
> 
>           $struct = [{foo => 1, bar => 2}, "FOO", "BAR"];
> 
>           $struct->{foo};  # same as $struct->[1], i.e. "FOO"
>           $struct->{bar};  # same as $struct->[2], i.e. "BAR"
 ... 
> And if you "use fields" with this, the mapping is done at compile
> time, not runtime.

This approach requires a translation table in every array.  What are its 
advantages compared to declaring the array-index constants via

      use constant X => 0;
      use constant Y => 1;

or explicitly:

      *X = sub () { 0 };
      *Y = sub () { 1 };

These constants can be localized in a block to avoid global scoping 
problems, and the mapping of array indexes should be done at compile 
time, and there is no per-array storage overhead, right?

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


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

Date: 17 May 1999 15:52:58 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Perl "constructors"
Message-Id: <7hpe0q$nke$1@pegasus.csx.cam.ac.uk>

Larry Rosler <lr@hpl.hp.com> wrote:
>
>This approach requires a translation table in every array.

No.    A sensible implementation has one translation table per class,
shared between all instances of the class.

>                                                            What are its 
>advantages compared to declaring the array-index constants via
>
>      use constant X => 0;
>      use constant Y => 1;
>
>or explicitly:
>
>      *X = sub () { 0 };
>      *Y = sub () { 1 };

You can't have common code which can operate on objects of several
different classes, so in particular can only use inheritance in restricted
ways.


Mike Guy


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

Date: Mon, 17 May 1999 15:39:18 GMT
From: Matthew Evans <matte_8000@my-dejanews.com>
Subject: Re: Perl and Oracle
Message-Id: <7hpd76$jaq$1@nnrp1.deja.com>

Heres an example of a query from a sun to an oracle 8 DB.

#!/usr/local/bin.sun4/perl5

#set up oracle env vars
$|=1;
$ENV{'ORACLE_BASE'}="/oracle";
$ENV{'ORACLE_SID'}="RD02";
$ENV{'ORACLE_HOME'}="/oracle/oracle8.0.4";
$ENV{'OH'}="/oracle/oracle8.0.4";
$ENV{'TWO_TASK'}="RD02";

#Include the libraries
require 5.0004;
use lib "/home/project/stats/lib/perl5/site_perl";
use lib "/home/project/stats/lib/perl5/site_perl/sun4-solaris";
use DBI;
use English;

#log-in to oracle
$db = "";
$db = DBI->connect("dbi:Oracle:", "stats/stats", "") || &errprn
($DBI::errstr);
$db->{LongTruncOk} = true;
$db->{LongReadLen} = 10000;

#get data from oracle
$sql = "SELECT IP FROM AAHOST WHERE IP = \'194.222.77.192\'";

$get_csr = $db->prepare($sql) || &errprn($DBI::errstr);
$get_csr->execute || &errprn($DBI::errstr);
($ip) = $get_csr->fetchrow;
print "IP >: $ip\n";


#########################
# Starts the subroutines#
#########################

sub errprn
{
	my($stin) = @_;

	open(LOG, ">>/home/project/stats/logs/summary.log")||die("Cant
open error file");
	$sysdate = `date`;
	print LOG ("$sysdate: $stin occured\n\n");
	close(LOG);
	exit(-1);
}


Hope  this helps,

Matt


In article <7hogqn$8ni$1@fleetstreet.Austria.EU.net>,
  "Thomas Klinger" <t.klinger@mobilkom.at> wrote:
> Hi there!
>
> Maybe this might be a simple question but because I'm a bit new to
PERL I
> cannot answer myself.
>
> I have a system on HPUX 10.20, clustered with MC/SG, with a comm-, a
db- and
> a spare-package.
> Additional I use a Linux system with an Apache-webserver.
> Those 2 systems are connected within a large TCP/IP net.
>
> What I want to do is doing some SQL-queries from a CGIscript on my
Linuxbox
> on the db-package(btw, the db-package is an ORACLE database, version
7.3.2).
> I know that I have an installed DBI package and a DBD:Oracle package.
> But how do I have to work with? How does the connection string is
looking
> like?
> What environment have I to build that my project would work exactly?
>
> Every message is welcome. Please excuse my sometimes worse English.
>
> --
> Best regards,
>                   Thomas Klinger
> ========================================
> ......E-Mail: t.klinger@mobilkom.at.....
> .........WWW: http://www.mobilkom.at....
> ========================================
>
>


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


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

Date: Mon, 17 May 1999 15:20:14 GMT
From: cpeters7873@my-dejanews.com
Subject: Perl to C translator?
Message-Id: <7hpc3a$iem$1@nnrp1.deja.com>

Hi, I have been writing perl programs for a while and I have a question
for anyone out there who can help.  Are there any perl to C/C++
translators out there?  I know of a2p and s2p, and since I believe perl
is written in C/C++, perhaps there is a "p2c" utility out there
somewhere?

I have searched the xman pages and read thru the perlfaq, but haven't
found anything on this subject.

Thanks


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


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

Date: Mon, 17 May 1999 17:40:30 +0100
From: Sebastian Ahrens <dataadm@elfi2.rz.ruhr-uni-bochum.de>
Subject: Re: Perl to C translator?
Message-Id: <3740467E.6AF8A67F@elfi2.rz.ruhr-uni-bochum.de>

cpeters7873@my-dejanews.com wrote:

> Hi, I have been writing perl programs for a while and I have a question
> for anyone out there who can help.  Are there any perl to C/C++
> translators out there?  I know of a2p and s2p, and since I believe perl
> is written in C/C++, perhaps there is a "p2c" utility out there
> somewhere?
>
> I have searched the xman pages and read thru the perlfaq, but haven't
> found anything on this subject.
>
> Thanks
>
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---

  perlcc is your friend (perldoc perlcc should bring up the man page)...


                    -Sebastian-





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

Date: Mon, 17 May 1999 14:51:53 GMT
From: bmccormack7477@my-dejanews.com
Subject: Re: Problem with CGI.pm need an example
Message-Id: <7hpae8$h0h$1@nnrp1.deja.com>

In article <7hosp4$7u8$1@nnrp1.deja.com>,
  smnayeem@my-dejanews.com wrote:
> does anyone have an example of the correct way of using the label and
> the values for say a radio group?
> heres my cgi script but its not giving the desired output.
>
> #!g:/perl/bin/perl
>
> use CGI::Carp qw(fatalsToBrowser);
> use CGI;
>
> $query = new CGI;
>
> print $query->header;
> print $query->start_html("Agni Billing System");
>
> print_prompt($query);
>
> print $query->end_html;
> exit;
>
> ## Subroutines ##
>
> sub print_prompt {
>   my ($query) = @_;
>   print $query->start_multipart_form;
>   %labels = ('male'=>'m','female'=>'f');
>   print
>     "Login ",
>     $query->textfield(-name => 'LOGIN', -size => 10),"<BR>",
>     "User name ",
>     $query->textfield(-name => 'USERNAME', -size => 25),"<BR>",
>     "Sex",
>     $query->radio_group(-name => 'SEX', -values => ['m','f'],
>       -default => 'm', -label=>\%labels);
>    print $query->checkbox(-name=>'checkbox_name',
>
>                                              -checked=>'checked',
>
>                                              -value=>'ON',
>
>                                              -label=>'CLICK ME');
>
> }
>
> if i run the above script the SEX radio group field should be
displaying
> male and female and internally storing m or f. however its displaying
m
> and f. anyone knows where i went wrong?
> please help me on this :)
> thanks
>
> smnayeem
> smnayeem@agni.com
>
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---
>
Make your values "values %labels"
and your labels "keys %labels"
cgi doesn't automatically dereference
the keys of the named hash at labels=>'\%hash'
with the named values at values=>'\@array'


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


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

Date: 17 May 1999 15:43:34 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Sorting is too slow for finding top N keys... - UPDATE
Message-Id: <7hpdf6$mh5$1@pegasus.csx.cam.ac.uk>

Larry Rosler <lr@hpl.hp.com> wrote:
>
>In article <7h3nn1$68t$1@xenon.inbe.net> on Sun, 09 May 1999 10:24:17 
>GMT, Michel Dalle <michel.dalle@usa.net> says...
>
>> BTW, I understand the O(M log M), but why does it take seconds to
>> sort a list with random numbers between 1 and 30000, and minutes
>> to sort a list with a lot of equal numbers ?
>
>The O(M log M) behavior for quicksort is an average for random data.  
>The worst-case behavior for pathological data is O(M**2).  Without my 
>Knuth or Sedgewick at hand, I recall that already sorted data is a 
>pathological case.  Perhaps highly duplicated data is also.

Sorted data shouldn't be pathological, but highly duplicated data can be,
if the qsort implementor hasn't thought of the case.  Here's some examples,
run under Solaris 2.6.   The cases are all straightforward numeric sorts,
with data

     Sorted:   Michel's data set, sorted
    Reverse:   Michel's data set, in decreasing order.
    Shuffle:   Result of applying random shuffle to Michel's data.
     Random:   An array of 31012  rand(32768).
Sort-Random:   Random, sorted into order.
 Rev-Random:   Random, sorted into reverse order.

perl5.004_04:
     Sorted: 24 secs (24.36 usr  0.00 sys = 24.36 cpu)
    Reverse: 23414 secs (22790.07 usr  0.05 sys = 22790.12 cpu)
    Shuffle: 7736 secs (7516.21 usr  0.01 sys = 7516.22 cpu)
     Random: 35 secs (35.34 usr  0.00 sys = 35.34 cpu)
Sort-Random: 36 secs (35.32 usr  0.00 sys = 35.32 cpu)
 Rev-Random: 35 secs (35.31 usr  0.00 sys = 35.31 cpu)

perl5.004_05:
     Sorted:  3 wallclock secs ( 2.65 usr +  0.00 sys =  2.65 CPU)
    Reverse:  3 wallclock secs ( 2.85 usr +  0.00 sys =  2.85 CPU)
    Shuffle:  3 wallclock secs ( 2.90 usr +  0.00 sys =  2.90 CPU)
     Random: 29 wallclock secs (28.16 usr +  0.00 sys = 28.16 CPU)
Sort-Random: 28 wallclock secs (28.15 usr +  0.00 sys = 28.15 CPU)
 Rev-Random: 27 wallclock secs (27.00 usr +  0.00 sys = 27.00 CPU)


Versions of Perl up to 5.004_04 relied on the platform-provided qsort(),
while later versions include their own qsort() code provided by
Tom Horsley.    And you can see the difference.

If a large fraction of the data is equal, with high probability the
pivot will be chosen equal to that value.   The traditional quicksort
algorithm divides the the data into two parts, below the pivot and
above the pivot, with values equal to the pivot being put into one or
other set.     So one of the partitions will contain all the equal
values, and won't be much smaller than the original set.    And so
the next pass will do much the same, leading to O(M) passes and O(M**2)
total running time.

More careful implementations, such as Tom's, divide into three parts,
below, equal and above.    The equal values won't need to be processed
again, so cases like Michel's become *very* fast to sort as you can see.

I strongly recommend having a look at Tom's code, which can be found
near the end of the pp_ctl.c file in the Perl distribution.    It's an
excellent demonstration of how quicksort should be coded, and also
(unlike most of the Perl source :-() an excellent demonstration of clear
commenting of C code.


Mike Guy


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

Date: Mon, 17 May 1999 15:58:27 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Sorting is too slow for finding top N keys... - UPDATE
Message-Id: <37413c59.990407@news.skynet.be>

M.J.T. Guy wrote:

>More careful implementations, such as Tom's, divide into three parts,
>below, equal and above.    The equal values won't need to be processed
>again, so cases like Michel's become *very* fast to sort as you can see.
>
>I strongly recommend having a look at Tom's code, which can be found
>near the end of the pp_ctl.c file in the Perl distribution.    It's an
>excellent demonstration of how quicksort should be coded, and also
>(unlike most of the Perl source :-() an excellent demonstration of clear
>commenting of C code.

What are you saying? That there's a smarter quicksort (for the
pathological case) part of Perl's source, but it's not used in the final
binary?

	Bart.


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

Date: Tue, 18 May 1999 00:59:04 +1000
From: James Smith <engjs@cc.newcastle.edu.au>
Subject: Weird socket behaviour
Message-Id: <37402EB8.AE83A315@cc.newcastle.edu.au>

I have written a perl program to open an internet socket and download
a webpage, the sort of thing Netscape does. It works fine in some cases
and not in others. The problem appears to be with the site I am
downloading from (which is one of a number of such sites).

If I connect to the site using netscape, it connects to the right
page. If I connect using my program, it returns a totally different
page. If I connect to the site using Netscape, using numbers rather
than a name, then Netscape returns the wrong page.

The problem appears to be that the site has a number of different
names that translate to the same set of numbers. I have been unable
to figure out how Netscape works out that this is happening and
deals with it.

Does anyone know what's going on? Can anyone quote some perl code to
get around the problem?

Any help you can give me will be greatly appreciated.

Jim


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

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

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