[12218] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5819 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 28 15:07:15 1999

Date: Fri, 28 May 99 12:01:32 -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           Fri, 28 May 1999     Volume: 8 Number: 5819

Today's topics:
    Re: Incrementing a value in a slice <cassell@mail.cor.epa.gov>
    Re: Incrementing a value in a slice (Greg Bacon)
    Re: Incrementing a value in a slice (Larry Rosler)
        LOG base setting in Perl5 <jdownie@uiuc.edu>
    Re: LOG base setting in Perl5 (Daniel S. Lewart)
    Re: LOG base setting in Perl5 (Sam Holden)
        method return values <bwaite@uswest.com>
    Re: PB writing an uploaded file in perl (size changes!) (Larry Rosler)
        Perl with ODBC consultant needed <rob@webteacher.com>
    Re: Strip "http" from URL's (Randal L. Schwartz)
    Re: Thanks man....HOWS THIS? <jeromeo@atrieva.com>
        to see who is online bababozorg@aol.com
    Re: Y2K infected Perl code ()
    Re: Y2K infected Perl code (Lane Core Jr.)
    Re: Y2K infected Perl code <tchrist@mox.perl.com>
    Re: Y2K infected Perl code (Scott McMahan)
    Re: Y2K infected Perl code (Scott McMahan)
    Re: Y2K infected Perl code ()
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 28 May 1999 10:19:17 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Incrementing a value in a slice
Message-Id: <374ED015.607F1056@mail.cor.epa.gov>

Kate wrote:
> 
> Greg Bacon <gbacon@cs.uah.edu> wrote in <7imcj5$jh2$3@info2.uah.edu>:
> 
> >In article <8DD46B23CXXkateXX@news.chiso.com>,
> >     kate_no_spam@for_me_chiso.com (Kate) writes:
> >: I basically want to read through a text file line by line, place
> >: each unique line in an array. When I hit a duplicate line, I want to
> >: increment a value in my array so I can keep track of how many times
> >: that line is duplicated. I'm not sure if I should be using a List of
> >: Lists or a Hash for this (like I said, my exposure to Perl is limited).
> >
> >Please read section four of the Perl FAQ.  Pay careful attention when
> >you reach "How can I extract just the unique elements of an array?".
> >
> >Greg
> 
> If I do it this way, I'm still not sure how to count how many times an
> entry occurs. Extracting the unique entries isn't my problem, its
> incrementing my counter.

But re-read that FAQ more carefully.  Try part (b), and print
out the hash %saw afterward.  The keys are your unique lines, and 
the values are your counts.  Once you see that this actually does
what you want, you'll wish to go read up on the cute pieces
which do this magic for you.  Part of this depends on the fact
that Perl automatically enlarges arrays and hashes when you
give them new pieces, and changes old values in hashes when you 
use new values with the previous keys.

> Thanks for the help,

You're welcome,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 28 May 1999 18:39:46 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Incrementing a value in a slice
Message-Id: <7imnti$mjh$1@info2.uah.edu>

In article <x7emk1i36u.fsf@home.sysarch.com>,
	Uri Guttman <uri@sysarch.com> writes:
: >>>>> "GB" == Greg Bacon <gbacon@itsc.uah.edu> writes:
:   GB>     my @uniq;
:   GB>     my %seen;
: 
:   GB>     while (<>) {
:   GB>         chomp;
: 
:   GB>         push @uniq, $_ unless $seen{$_}++;
:   GB>     }
: 
:   GB>     my $mode = shift @uniq;
:   GB>     for (@uniq) {
:   GB>         $mode = $_ if $seen{$_} > $seen{$mode};
:   GB>     }
: 
: greg, you can do better than that! why two loops? why the push into
: @uniq?

It's a pedagogical issue.  I wanted to show how to collect the
information she wanted and then show one possible way to use it.
Playing Perl golf (fewest (key)strokes wins!) with people who have lots
of experience is fine, but it's not going to help much for people who
are still trying to get the hang of it.

Greg
-- 
VMS is a text-only adventure game. If you win you can use Unix.
    -- Bill Davidsen


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

Date: Fri, 28 May 1999 11:51:36 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Incrementing a value in a slice
Message-Id: <MPG.11b88594c5965f8989b20@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed, so Uri can feel bad sooner :-).]

In article <x7emk1i36u.fsf@home.sysarch.com> on 28 May 1999 12:12:09 -
0400, Uri Guttman <uri@sysarch.com> says...
 ...
> greg, you can do better than that! why two loops? why the push into @uniq?

Uri, you can do better than that!  Why not post code that compiles?

> 	while(<>) {
> 		chomp ;
> 
> 		$count = ++$seen{$_} ;
> 		$max_line = $_ && $max_count = $count if $count > $max_count ;
> 	}
> 
> 	@uniq = keys %seen ;
> 
> or for you fans of shorter code:
> 
> 	$max_line = $_ && $max_count = $seen{$_} if ++$seen{$_} > $max_count ; 

Do you want me to spell out the problem for you, or would you prefer to 
own up to it yourself?

:-( for you, buddy.

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


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

Date: Fri, 28 May 1999 10:19:43 -0500
From: "J. Stephen Downie" <jdownie@uiuc.edu>
Subject: LOG base setting in Perl5
Message-Id: <374EB40F.F45510C0@uiuc.edu>

Hi group:

Simple question for you but tricky for me:

What is the easiest way to take the log of number to Base 2 rather than
Base e in
perl? It has me stumped.

Cheers,
Stephen



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

Date: 28 May 1999 17:52:45 GMT
From: d-lewart@uiuc.edu (Daniel S. Lewart)
Subject: Re: LOG base setting in Perl5
Message-Id: <7iml5d$dif$1@vixen.cso.uiuc.edu>

"J. Stephen Downie" <jdownie@uiuc.edu> writes:

> What is the easiest way to take the log of number to Base 2 rather than
> Base e in perl? It has me stumped.

log($x)/log(2)

Daniel Lewart
d-lewart@uiuc.edu


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

Date: 28 May 1999 17:53:17 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: LOG base setting in Perl5
Message-Id: <slrn7ktm0d.m1g.sholden@pgrad.cs.usyd.edu.au>

On Fri, 28 May 1999 10:19:43 -0500, J. Stephen Downie wrote:
>Hi group:
>
>Simple question for you but tricky for me:
>
>What is the easiest way to take the log of number to Base 2 rather than
>Base e in
>perl? It has me stumped.

I suspect you go back to your old math textbook and look up the logarithm
section and find a formula similar to this :

loga(b) = logx(b)/logx(a)

So substitute for x=e and a=2 and you may have the answer...

Of course I don't have a maths book with me and I may have got the
formula upside down, or back to front, or whatever.

-- 
Sam

The very fact that it's possible to write messy programs in Perl is also
what makes it possible to write programs that are cleaner in Perl than
they could ever be in a language that attempts to enforce cleanliness.
	--Larry Wall


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

Date: Fri, 28 May 1999 11:12:31 -0600
From: Brad Waite <bwaite@uswest.com>
Subject: method return values
Message-Id: <374ECE7F.F5F36489@uswest.com>

Morning (evening, night, etc) all.

I'm wondering how 'right' it is for a method in a package to croak().  As I
understand the docs, croak() works just like die() and shuts down the process. 
Shouldn't one be able to determine from the return value whether to croak or
not?  I'm using IPC::Shareable which calls croak() if it can't get a shared
memory segment.  I was trying to use the return value in a decision whether to
continue or not.  Shouldn't it rather return an undef or 0 or something, which
then allows the calling program to check ERRNO, and do what it wants?

-Brad


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

Date: Fri, 28 May 1999 11:43:43 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: PB writing an uploaded file in perl (size changes!)
Message-Id: <MPG.11b883b997cd8ba8989b1f@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <374ec12a@newsread3.dircon.co.uk> on 28 May 1999 17:15:38 
+0100, Jonathan Stowe <gellyfish@gellyfish.com> says...
> jns [pigment] $ perldoc -f binmode
> =item binmode FILEHANDLE
> 
> Arranges for the file to be read or written in "binary" mode in operating
> systems that distinguish between binary and text files.  Files that are
> not in binary mode have CR LF sequences translated to LF on input and LF
> translated to CR LF on output.  Binmode has no effect under Unix; in MS-DOS
> and similarly archaic systems, it may be imperative--otherwise your
> MS-DOS-damaged C library may mangle your file.  The key distinction between
> systems that need C<binmode()> and those that don't is their text file
> formats.  Systems like Unix, MacOS, and Plan9 that delimit lines with a single
> character, and that encode that character in C as C<"\n">, do not need
> C<binmode()>.  The rest need it.  If FILEHANDLE is an expression, the value
> is taken as the name of the filehandle.

This is the latest version, which is certainly a great improvement over 
the preceding one (and was changed as a direct result of its being 
posted periodically in this newsgroup -- thank you, TomC).

But TomC has made it clear that he, at least, will not adopt my 
suggestion on how to eliminate this question being asked ad nauseam:

'binmode' binary files on every implementation of perl!
'binmode' binary files on every implementation of perl!
'binmode' binary files on every implementation of perl!
'binmode' binary files on every implementation of perl!
'binmode' binary files on every implementation of perl!
'binmode' binary files on every implementation of perl!
'binmode' binary files on every implementation of perl!
'binmode' binary files on every implementation of perl!
'binmode' binary files on every implementation of perl!
'binmode' binary files on every implementation of perl!

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


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

Date: Fri, 28 May 1999 18:10:11 GMT
From: Robert Young <rob@webteacher.com>
Subject: Perl with ODBC consultant needed
Message-Id: <374EDABB.B451F15B@webteacher.com>

passme

If you are very experienced with the Win32::ODBC or DBD::ODBC modules
please contact me.  I'll respond with a full RFP.

Rob Young
Webteacher Software
mailto: rob@webteacher.com
(510) 790-6451
--
-------------------------------------------------------------------------------

Webteacher Software
  Making advanced web tools easy for non-programmers

Webdata - the first EASY database for the web
JavaScript for the Total Non-Programmer
CGI for the Total Non-Programmer

            http://www.webteacher.com
            mailto:rob@webteacher.com
-------------------------------------------------------------------------------





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

Date: 28 May 1999 11:52:40 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Strip "http" from URL's
Message-Id: <m1g14hf2mf.fsf@halfdome.holdit.com>

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

Larry> + > Given any URL such as:

Larry> + Maybe something like this:
Larry> + 
Larry> + use URI;
Larry> + $u1 = URI->new("http://www.perl.com/whatever/");
Larry> + $scheme = $u->scheme;
Larry> + $opaque = $u->opaque;
Larry> + $path   = $u->path;    # try printing this
Larry> + $frag   = $u->fragment;

Larry> Good Lord.  A new disease -- modulitis.

Larry>     s%^http://[^/]+%%;

Which doesn't work if it's *any* URL, as the spec said.

Modules are useful.  Don't knock them.

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


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

Date: Fri, 28 May 1999 09:50:39 -0700
From: Jerome O'Neil <jeromeo@atrieva.com>
To: jknoll@my-deja.com
Subject: Re: Thanks man....HOWS THIS?
Message-Id: <374EC95F.199EA582@atrieva.com>

jknoll@my-deja.com wrote:
> 
> Thanks man.  I picked up a perl book yesterday, ask a question and now I
> get this.  What is this NG for if I cant get help?

To thicken your skin?

> When you are printing a SINGLE-QUOTED STRING LITERAL, how do you make it
> look like this:
> 
> WORDSWORDS
> WORDSWORDS
> 
> Instead of this:
> WORDSWORDSWORDSWORDS

HIWWTDI:

print q{WORDSWORDS}, qq{\n}, q{WORDSWORDS};

But somehow I don't think that's what you want.

What is the apprehension about making them double-quoted strings?

Good Luck!


-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: Fri, 28 May 1999 18:16:17 GMT
From: bababozorg@aol.com
Subject: to see who is online
Message-Id: <7immhf$ugm$1@nnrp1.deja.com>

hi
i was wondering if there is any way that i can see who is in my website
right now and display the details of that person, or if he is my member
how can i know he is online right now!.
i did try to make a file in the tmp dir when my users came online.
but i didnt know how to remove that file afterwards when they go
offline or go to another website. i tryed to pass them to a script that
removes the file after they closed the page or onloaded the page by
javascirpt, but i cant really trust the javascript and it didnt work
70% ofthe time :)
i thought there must be a way to do this with cgi even using shell
things :)
can you please tell me if there is any way to make it work? or see the
members online (in separat page) when they logged in to my website?
(i also use the htaccess login at the moment)
thanks
hamed




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


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

Date: Fri, 28 May 1999 17:28:45 GMT
From: docdwarf@clark.net ()
Subject: Re: Y2K infected Perl code
Message-Id: <hnA33.118$K2.4143@iad-read.news.verio.net>

In article <374eb1a0@newsread3.dircon.co.uk>,
Jonathan Stowe  <gellyfish@gellyfish.com> wrote:
>In comp.lang.perl.misc docdwarf@clark.net wrote:
>> In article <7ils7e$ptu$2@ash.prod.itd.earthlink.net>,
>> Bob Trieger <sowmaster@juicepigs.com> wrote:
>>>[ courtesy cc sent by mail if address not munged ]
>>>     
>>>elcore@sgi.net (Lane Core Jr.) wrote:
>>>>On 27 May 1999 22:47:28 -0400, Uri Guttman <uri@sysarch.com> wrote:
>>>>
>>>>>so fucking what if cgi
>>>>>routines and perl routines can be infected with y2k. that is the
>>>>>programmers problem and not the language's.
>>>>
>>>>same with cobol.
>>>>same with any language.
>>>>so it's still a problem.
>>>>so, like, what's your point?
>>>
>>>It's not still a problem if you don't have a retard writing your code 
>>>for you!
>>>
>> 
>> And is it a problem if you have, say, a McCracken writing code which
>> *must* ( = 'will not get into Prod if it doesn't') adhere rigidly to specs
>> written by a 'retard'?
>> 
>
>Sorry,  are you saying that you have seen a specification for a *Perl*
>program that prescribes the use of: $year = '19' . $year ?  Whoaaa .

No, I am not saying that at all... in response to the assertion that there
is no difficulty if one does not have a 'retard writing code' I asked what
happens if the person writing code is not a 'retard' but the specs demand
certain standards be adhered to.

My apologies for the obscurity, I hope this clarifies matters.

DD



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

Date: Fri, 28 May 1999 18:01:11 GMT
From: elcore@sgi.net (Lane Core Jr.)
Subject: Re: Y2K infected Perl code
Message-Id: <374ed9b7.2337186@news.sgi.net>

On 28 May 1999 12:04:34 +0100, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:

>In comp.lang.perl.misc Lane Core Jr. <elcore@sgi.net> wrote:
>> On 27 May 1999 22:47:28 -0400, Uri Guttman <uri@sysarch.com> wrote:
>> 
>>>so fucking what if cgi
>>>routines and perl routines can be infected with y2k. that is the
>>>programmers problem and not the language's.
>> 
>> same with cobol.
>> same with any language.
>
>Not entirely true - there are languages with a DATE type that is completely
>transparent to the programmer:

Yes, I should have said, not "any language", but "not just perl".

>I love it when it when a crosspost goes bad ...
>
>I think that uri's point is that basically if someone is too dumb to have
>read and understood the documentation for the localtime function then its
>basically tough shit - it is not a problem with Perl its a problem with
>the meatware.

Yeah, but it's still a problem. :-(

---------------------------------------------------------------------------
Mr. Lane Core Jr.  elcore@sgi.net  http://users.sgi.net/~elcore/elc_y2k.htm
---------------------------------------------------------------------------

"More software projects have gone awry for lack of calendar time than for
all other causes combined". Frederick P. Brooks, _The Mythical Man-Month_


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

Date: 28 May 1999 12:22:55 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Y2K infected Perl code
Message-Id: <374edeff@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    docdwarf@clark.net () writes:
:happens if the person writing code is not a 'retard' but the specs demand
:certain standards be adhered to.

Have you considered toiling under a slightly less mind-numbingly
fascist regime?

--tom
-- 
    "It's later than you don't think." --Larry Wall


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

Date: 28 May 1999 18:54:39 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: Y2K infected Perl code
Message-Id: <374ee66f.0@news.new-era.net>

Erik van Roode (newsposter@cthulhu.demon.nl) wrote:


>   Besides, what's the problem with 1999->2000 transition anyway.

I quit worrying about Y2K when I went to Wal-Mart and tried
to purchase a book which had NATIONAL BESTSELLER written on it.
The book wasn't in their computer system! At that point, I
pretty much decided that no one would even notice Y2K disruptions.

Scott


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

Date: 28 May 1999 18:56:17 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: Y2K infected Perl code
Message-Id: <374ee6d1.0@news.new-era.net>

> Sorry,  are you saying that you have seen a specification for a *Perl*
> program that prescribes the use of: $year = '19' . $year ?  Whoaaa .

The nice thing about Open Source is, you can always hack
the interpreter to change any string concatenation of
a three-digit number to the literal "19" to be an addition.
Problem solved.

Scott


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

Date: Fri, 28 May 1999 18:41:46 GMT
From: docdwarf@clark.net ()
Subject: Re: Y2K infected Perl code
Message-Id: <KrB33.129$K2.4278@iad-read.news.verio.net>

In article <374edeff@cs.colorado.edu>,
Tom Christiansen  <tchrist@mox.perl.com> wrote:
>     [courtesy cc of this posting mailed to cited author]
>
>In comp.lang.perl.misc, 
>    docdwarf@clark.net () writes:
>:happens if the person writing code is not a 'retard' but the specs demand
>:certain standards be adhered to.
>
>Have you considered toiling under a slightly less mind-numbingly
>fascist regime?

Why yes, I *have* considered such things.  My considerations, however, do
not have any effect on situations like these which exist, in my
experience, in a goodly number of environments.

Please be so kind, then, as to address the situation posed and not my
responses to it... what happens if a person writing code is not a 'retard'
but the specs demand the adherance to certain standards?

DD



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

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

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