[8435] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2052 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 8 15:07:29 1998

Date: Sun, 8 Mar 98 12:00:28 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 8 Mar 1998     Volume: 8 Number: 2052

Today's topics:
    Re: $0: which OSes? sneaker@mediaone.net
        change Htpasswd from a FORM**Newbie** <rae@vip.cybercity.dk>
    Re: Help with perl, immediate answers wanted! <camerond@mail.uca.edu>
    Re: HELP with SUBROUTINES and @_ <beans@bedford.net>
    Re: Help: avoiding eval() on a grep() function. <rjk@coos.dartmouth.edu>
        how do i scan my ppp port?? <danbmac@magma.ca>
    Re: Newbies question for Win32 <NerveGas@see_signature.com>
    Re: Perl - Beginner question [SEEDOC] (Martin Vorlaender)
    Re: Perl - Beginner question <jdf@pobox.com>
        Perl longfilenames w/ win95 bspiker@wiesbaden.netsurf.de
    Re: perl source (Bart Lateur)
    Re: Q: obscuring Perl scripts? <palincss@nicom.com>
    Re: RegEx help <joegottman@nospam.worldnet.att.net>
    Re: RegEx Quiz Question (Alan Schwartz)
    Re: remote registry on NT <rothd@xrxoxtxhx.xnxextX>
        running 2 procceses at the same time (WinNT) (Edwin)
    Re: Search Scripts (keefner)
    Re: Tom, grow up [Re: The -w switch (was Re: better way (Chip Salzenberg)
    Re: Using perl to do what a spreadsheet does but with a <jdf@pobox.com>
        Weekdays (GLEEMOTH)
    Re: Weekdays <friedman@uci.edu>
    Re: What is PERL? Learn JAVA instead? <evan@garrett.hpl.hp.com>
    Re: Win32 help request,  rename problem <rothd@xrxoxtxhx.xnxextX>
    Re: Win32 Perl and ODBC New User Problems (keefner)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sun, 08 Mar 1998 09:11:37 -0600
From: sneaker@mediaone.net
Subject: Re: $0: which OSes?
Message-Id: <6ducda$t4v$1@nnrp1.dejanews.com>

In article <6do94s$84t$1@ha1.rdc1.occa.home.com>,
  shaug@callamer.com wrote:
>
> In article <34ffaf37.41141913@news.gate.net>, Michael Kelly
<mkelly99@NOSPAMgate.net>'s keyboard spewed forth
> thus:
> >On Wed, 04 Mar 1998 11:58:08 GMT, Bill Jones
> ><webmaster@fccjmail.fccj.cc.fl.us> wrote:
> >
> >>Very interesting.
> >>Maybe on Solaris the $0 become a local assignment
> >>and does not propagate?
> >
> >Perhaps the /proc filesystem Linux uses is the link between the
> >app, $0 and ps?  Just a wild guess as I believe /proc is unique
> >to Linux.
>
> :r! uname -rsp
> SunOS 5.5.1 sparc
>
> :r! ls -ld /proc
> dr-xr-xr-x   2 root     root       16064 Mar  5 23:32 /proc
> --
> - O'Shaughnessy Evans
> - http://www.callamerica.net/shaug/
>

This really bites!

I wonder why my OTHER reply didn't show up?
Has my ISP news server totally died???

:-\  :-/ :-|

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 8 Mar 1998 15:44:29 GMT
From: "Rene Eriksen" <rae@vip.cybercity.dk>
Subject: change Htpasswd from a FORM**Newbie**
Message-Id: <01bd4aa9$f1869760$0500a8c0@ikre>

I am trying to make a perl script that can take a input from a form, and
then change/update the htpasswd file with the new username and password.
But I am having problem with the print PASS"$newpass"; section.
The first section opens the htpasswd program, and that respond back with
"New Password", it's here were my program fails, I expect it to print out
the $newpass, but nothing happens, I have tryed to run it from a telnet
prompth but eash time it stop at the "New Password" prompth
Is there anyone that have a good idea to overcome that ?????


$user = $FORM{'user'};
$newpass = $FORM{'newpass'};

open(PASS,"| $passprog  /somepath/.htpasswd $user") || return 0;
print PASS "$newpass";
close PASS;

Best Regards Rene
-- 
<rae@vip.cybercity.dk>




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

Date: Sun, 08 Mar 1998 13:38:03 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Help with perl, immediate answers wanted!
Message-Id: <3502F39B.B2B491A5@mail.uca.edu>

Some immediate answers: 
(1) Yes.
(2) No.
(3) 42 (well, this one actually took 7.5 mil years to come up with)
(4) Because.

Cameron

Brandon Blum wrote:
> 
> [inappropriate question for a perl NG snipped]


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

Date: 8 Mar 98 19:06:14 GMT
From: "TomH" <beans@bedford.net>
Subject: Re: HELP with SUBROUTINES and @_
Message-Id: <01bd46a6$07adfb80$519163ce@beans.bedford.net>


MercuryZ <mercuryz@mail.alabanza.com> wrote in article
<6dspks$ror@chile.earthlink.net>...
 ... 
> I have been studying Perl for about 5 months now and
> I have difficulty in only one area...subroutines.
> 
> I understand how to write subroutines and how to include
> them in my programs, but what I don't understand is
> how variables are made local and especially how @_ works.
 ...

What have you been studying for the last 5 months? Certainly not the
documentation in perlsub, the 3rd paragraph of Description states:

"Any arguments passed to the routine come in as the array @_. Thus if you
called a function with two arguments, those would be stored in $_[0] and
$_[1]. "

The fourth paragraph paragraph states:

"The return value of the subroutine is the value of the last expression
evaluated. Alternatively, a return statement may be used to exit the
subroutine, optionally specifying the returned value..."

and further down, under typeglobs, it says:

"Sometimes you don't want to pass the value of an array to a subroutine but
rather the name of it, so that the subroutine can modify the global copy of
it rather than working with a local copy."

> For example, here is a chunk of code that I fail to
> understand:
> ##################################################
> sub uppercase {
> local ( *string ) = @_;
> foreach $string (@string) {$string =~ tr/a-z/A-Z/; }
> return @string;
> }
 ...
> $string = "lower case";
> @change = ("Sean", "F");
> @return = uppercase( *change );
 ...
> I have many Perl books, and have studied hard,
> but I can't understand for one reason or another
> how file globbing...

This isn't file globbing, "local (*string) = @_" gives you a local name
that refers to the variable passed into the function. A local variable
hides a global variable of the same name. The "returned" statement returns
an array (since you call the function in an array context). 

So what happens here? You step through the @change, translating it to
uppercase (*string is a reference to @change, the global variable $string
is hidden), then return the translated value and store it in @return.
That's all there is to it.

-Tom


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

Date: Sun, 08 Mar 1998 13:59:00 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
To: Tommy <tkho@technologist.com>
Subject: Re: Help: avoiding eval() on a grep() function.
Message-Id: <3502EA76.FDF3DEB9@coos.dartmouth.edu>

[posted and mailed]

Tommy wrote:
> 
> grep(/$STR1/i&&/$STR2/i, @Array);
> #  this take only 0.3 sec for 600k records.
> 
> grep( eval(/$STR1/i&&/$STR2/i) , @Array);
> #  this take about 10 sec for 600k records.

Does adding /o to the regexes help any?

grep( eval(/$STR1/oi && /$STR2/oi) , @Array);

> Does anyone how to do the same task without using eval()?

Instead of creating a string like: $COND = '/$STR1/i && /$STR2/i && ...'
try creating a string like this:   $RE   = '$STR1|$STR2|...'
Then do the grep like this:

grep( /$RE/i ), @Array);

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 08 Mar 1998 18:05:15 GMT
From: Dan Macpherson <danbmac@magma.ca>
Subject: how do i scan my ppp port??
Message-Id: <352676F1.5FAE0AAD@magma.ca>

i wrote a very basic script to finger a user (me)
to find out what port they were using so that i
could access their dns (web server).  the reason
for this is because of when i dial up i get a new
(dynamic) ip/dns every time.  i wanted to put my
new ip on my web page so people could visit my
own server...( no disk space restriction). this only
works if i telnet to my local isp, and not via ppp.

how do i scan the ppp port of a bsd system so
that i can get my ip (dns)?  is there another way to
find out my dynamic ip/dns (when i am on line)?
has this been done before? is there a faq?
it would be much apriciated if someone can help.

my dns is always x2port*.magma.ca
where * is a number (modem) currently
between 1-100 (i think)

thanks for your reply
Dan
danbmac@magma.ca




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

Date: Fri, 06 Mar 1998 13:02:45 -0700
From: NerveGas <NerveGas@see_signature.com>
Subject: Re: Newbies question for Win32
Message-Id: <35005665.559F@see_signature.com>

> > Question #1. How can I save a file in Notepad with the .pl extension
> > I have try going in to my folder option in "My Computer\View\Option\Files
> > types\New type." and add a new type of file.

<Snip>

>   question #1: notebook doesn't do that to me ? hmmm...is the "save as file
> type" pull down menu in the "save as" dialog box on "text documents" or "all
> files(*.*)".It doesn't seem to matter on mine but it's all I can think of.

another way to ensure that notepad does not add on the extension is to
surround the file name in quotes - for example, type "filename.pl" ,
including the quotes, and it won't matter what file type is set in the
filter box.

steve


-- 

----------------------------------------
Domain name for replying is "inconnect".
----------------------------------------


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

Date: Sun, 08 Mar 1998 18:22:11 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Perl - Beginner question [SEEDOC]
Message-Id: <3502d3c3.524144494f47414741@radiogaga.harz.de>

Arundhati_Bhende@csx.com wrote:
: In the following construct, 'while' does not work as I think it
: should. Any ideas on why ?

Doc not read error!

:     while ((chomp ($guess = <STDIN>)) ne $secretword){

>From the perlfunc POD, section "chomp":

    It returns the total number of
    characters removed from all its arguments.

cu,
  Martin
--
                          | Martin Vorlaender | VMS & WNT programmer
 Ceterum censeo           | work: mv@pdv-systeme.de
 Redmondem delendam esse. |       http://www.pdv-systeme.de/users/martinv/
                          | home: martin@radiogaga.harz.de


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

Date: 08 Mar 1998 11:33:22 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Perl - Beginner question
Message-Id: <ra4dp2gd.fsf@news.concentric.net>

bhendeNOSPAM@ibm.net writes:

>     while ((chomp ($guess = <STDIN>)) ne $secretword){
>          print ("Wrong. Try again.");
>     }

You are comparing the secret word to the return value of the chomp
function.  Unless the secret word happens to be "1", you'll never
match, since chomp "returns the total number of characters removed
from all its arguments."  

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Sun, 08 Mar 1998 17:46:06 GMT
From: bspiker@wiesbaden.netsurf.de
Subject: Perl longfilenames w/ win95
Message-Id: <3502d7c9.5107069@news.wiesbaden.netsurf.de>


This might be a newbie question, but I can't figure out how you can
get a long-filename passed into Perl 5.03 as a long-filename.

I have create a short bat file that I've placed in the Windows
"SendTo" directory. This way I can use the Windows Explorer to click
on a dir and do something against it in Perl. The bat file is easy:

perl c:\bin\perl5\test\perl-test.pl %0 %1 %2 %3 %4 %5 %6 %7 %8 %9

I believe that my problem is that the "DOS Shell" is getting in the
way. However I can't find any means to invoke a perl script directly
from Windows 95.

I also tried a "side-affect" of allowing the 8.3 filename to be passed
in then chdir to it and allow Perl to tell me the CurDir name, but it
passed back the 8.3 name well.

Any clues?

My boring perl test script:

#!c:\bin\perl
#

use Cwd;

$path = `echo %PATH` ;
$inc  = `echo %INC` ;

print "argv[0] = $ARGV[0]\n" ;
print "argv[1] = $ARGV[1]\n" ;
print "argv[2] = $ARGV[2]\n" ;
print "argv[3] = $ARGV[3]\n" ;
print "argv[4] = $ARGV[4]\n" ;
print "\n" ;

chdir ($ARGV[1]);
$cwd = getcwd();
print "Current Directory = $cwd\n" ;

if (open(OUT, ">another-long-filename.txt"))
{
	print OUT "a simple line of text.\n";
	close OUT;
}



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

Date: Sun, 08 Mar 1998 16:09:09 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: perl source
Message-Id: <3502c243.3173950@news.tornado.be>

G Moore wrote:

>does anyone have a version of the non-tarred, non-zipped
>version of perl? my tar program is not working.

Simplest way to to download another untar or unzip program. Yes there
are some out there, available for free. The source for Perl is far too
huge to try and download uncompressed.

HTH,
Bart.


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

Date: Sun, 08 Mar 1998 08:39:54 -0800
From: Steve Palincsar <palincss@nicom.com>
To: John Stanley <stanley@skyking.OCE.ORST.EDU>
Subject: Re: Q: obscuring Perl scripts?
Message-Id: <3502C9DA.54FB@nicom.com>

Utter drivel, John.

In the first place, what has my mailer at home got to do with
anything?  If you think it does, shame on you.  Although unfortunately
widely shared, such attitudes IMO have no place in this forum.

In the second place, responding to the best possible interpretation of 
your ad hominem slur, to me there's a world of difference between apps 
distributed as binary code and those distributed as source, and a like
difference between C/C++ code that is greek to me (because my knowledge 
of those languages goes little further than their spelling) and perl 
source that is intentionally obfuscated.  

One doesn't need to read too far to discover a vast literature
of proper coding standards.  There are hairsplitting arguments
about exactly how many spaces one should indent, or whether the open
brace should come on the same line as the start of the block or on
the line following, but no general disagreement that code should be
readable, well formatted, well commented, and should make its intentions
clear.

By those standards, the example of obfuscated perl we saw was 
completely unsatisfactory, failing in every single respect.  Its
shortcomings are obvious for all the world to see.  


John Stanley wrote:
> 
> In article <35017756.B3F@nicom.com>,
> Steve Palincsar  <palincss@nicom.com> wrote:
> >This product could walk on water, double my agency's appropriation and
> >be totally free of charge and I wouldn't recommend we even test it.
> 
> I notice your article contained the following header:
> 
> X-Mailer: Mozilla 3.0 (Win16; I)
> 
> This implies that not only do you recommend such code be tested, you
> use it. Theoretically, you shouldn't be using it until the end of the
> month, assuming that the code Netscape releases isn't as obfuscated.


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

Date: Sun, 08 Mar 1998 11:28:35 -0500
From: Joe Gottman <joegottman@nospam.worldnet.att.net>
Subject: Re: RegEx help
Message-Id: <6duh3r$pbh@bgtnsc02.worldnet.att.net>



Grimoire wrote:

> I am in need of help with formating information with a regex.  The data
> looks like:
> [...]
> Name:cor150.anchor.net::199.90.111.102Name:boston-14.cisco.com::171.68.38.14...
> [...]
>
> I would like the information to come out like:
> [...]
> Name:cor150.anchor.net::199.90.111.102
> Name:boston-14.cisco.com::171.68.38.14
> [...]
>
> I thought the code would go something like this:
>         s/::(\d+\.\d+\.\d+\.\d+)/::(\d+\.\d+\.\d+\.\d+)\n/ig;
>
>         Unfortunatly, I was totally wronge in my thinking.  The result had
> the right formatting...but the wronge desired effect.  The results where:
> [...]
> Name:cor150.anchor.net::(d+.d+.d+.d+)
> Name:boston-14.cisco.com::(d+.d+.d+.d+)
> Name:99.163.17.209.shuttle.net::(d+.d+.d+.d+)
> Name:20715980148.bellatlantic.net::(d+.d+.d+.d+)
> [...]
>
>         I was hoping that there would be someone on this newsgroup that
> would be able to help.  I did look in the Llama and Camel book to no
> avail.  If you could help I would appreciate it.

   Try this:
    @list = map {$_ = "Name:$_"} split ($data, /Name:/);



--
Joe Gottman
joegottman@nospam.worldnet.att.net

[Remove nospam to reply]




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

Date: 8 Mar 1998 16:38:46 GMT
From: alansz@araw.mede.uic.edu (Alan Schwartz)
Subject: Re: RegEx Quiz Question
Message-Id: <6duhim$2e48$1@piglet.cc.uic.edu>

Bill Jones  <bill@astro.fccj.cc.fl.us> writes:
>No, I know nothing about RegEx
>(yes I own lots of Perl books,
>mainly all from ORA :-)  But
>I am embedded so far into
>'C' I cannot see Perl clearly
>sometimes :-)

I don't mean to be harsh, Bill, but this isn't really a 'quiz',
then, is it? It's asking for help. A quiz usually implies
that you know the answer and it will be educational for us.
As I often filter this group looking for 'quiz' in the subject,
messages like this seem a bit, well, sneaky, as a way to
get help.

>I can 'copycat' code til I am
>blue in the face, but no
>closer to understanding
>why d+, et al, is used,
>you know?

\d is any digit (0-9). \d+ means "one or more digits"
So, \d+\.\d+ means "one or more digits, a period (\. is a literal
period) and then one or more digits), like "3.999" 
Similarly, \d+\.\d+\.\d+\.\d+ matches four integers separated
by periods, which it a common representation of IP addresses,
as Jonathan Feinberg mentioned.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
         Alan Schwartz                  | Disclaimer: I represent no one
        <alansz@uic.edu>                |
Asst. Prof. of Clinical Decision Making | Life is what happens to you while
University of Illinois at Chicago       | you're busy making other plans
Department of Medical Education         |          - J. Lennon
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



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

Date: 8 Mar 1998 18:33:04 GMT
From: "Dave Roth" <rothd@xrxoxtxhx.xnxextX>
Subject: Re: remote registry on NT
Message-Id: <01bd4ac0$f54ecb80$0101a8c0@main2>



Ely Mansour <elynt@ml.com> wrote in article
<34FDC9E3.81494503@ml.com>...
> Has anybody been able to connect to a remote registry on
NT ?

Works like a charm. But there is something I had to hack
the registry.pm file to get it to work. It may have been
corrected in a later version than mine (I use 313).
Add this to your registry.pm file:

############################################################
###########
#RemoteConnect
#Connect to a remote computer's registry.
#   Syntax: RemoveConnect($Computer);
#   Added 970513 by Dave Roth <rothd@roth.net>
sub RemoteConnect
{
    my $self = shift;
    if($#_ != 1){
        die 'usage: RemoteConnect($Computer, $Handle)';
    }
    local ( $Computer, $Handle) = @_;
    $Result = RegConnectRegistry($Computer,
$self->{'handle'}, $Handle);
    $_[1] = _new($Handle);
    if (!$_[1]){
        return 0;
    }
    if (!$Result){
        $! = Win32::GetLastError();
    }
    return ($Result);
}

It works for me. Try it like this...
  if (! $HKEY_LOCAL_MACHINE->RemoteConnect($Computer,
$RootKey)){
      print "Could not connect to $Computer.\n";
      exit;
  }else{
      print "Connected to the registry at $RootKey!\n";
      ...now use $RootKey->function();
  }

dave
-- 
============================================================
====
Dave Roth                               ...glittering
prizes and
Roth Consulting                     endless compromises,
shatter
rxoxtxdxxrxoxtxhx.xnXeXt               the illusion of
integrity

 My email address is disguised to fool automailers. Remove
the
                      X's to send me email.
************************************************************
****
Use of  this message or  email address  for commercial 
purposes
(including "junk" mailings) is strictly prohibited and
protected
under  current  international  copyright laws  and United
States
Code, Title 47, Chapter 5, Subchapter II.



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

Date: Sun, 8 Mar 1998 16:31:50 +0100
From: edwin@equilibrate.net (Edwin)
Subject: running 2 procceses at the same time (WinNT)
Message-Id: <MPG.f6cd850452e5e9e989682@news.xs4all.nl>

What i'm trying to do is run 2 proccesses at the same time, both 
procceses must run. As explained in the documentation wenn using exec u 
don't return to u'r parent program and wenn using system the parent waits 
for the child to close (what u want normally).

I know what i'm trying to do is dirty but trying to open two programs 
with an autorun.inf (The programs must come on a cd) It doesn't work 
either.

I tried something with the fork command, but when i tried that i got the 
error that the fork function is not included (probably missing a use:: 
but i can't find out which one gets me the fork function under WinNT.

Secondly i wanna try killing the parent once the child is finished but 
thats another story. If someone know's some FAQ's or has some pointers to 
help me on the way i would greatfull.

Thnx in front
Edwin Cools


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

Date: Sun, 08 Mar 1998 15:16:00 GMT
From: keefner@visi.com (keefner)
Subject: Re: Search Scripts
Message-Id: <3502b6da.86360589@news.visi.com>

On Wed, 4 Mar 1998 12:17:17 -0800, "Nitin Gupta"
<niting@raleigh.ibm.com> wrote:

>Are there any search scripts available which can deal with sites which have
>2000+ pages? The one's available work by opening each page and searching for
>the corresponding search term, this takes a long time on a large site.

There is a script called treesed in perl which i use to handle
global search/replace or find or specific page search/replace
and one of my sites is over 2000 pages.  Takes less than
a minute.

Craig


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

Date: Sun, 08 Mar 1998 19:34:41 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Tom, grow up [Re: The -w switch (was Re: better way to do this?)]
Message-Id: <6dus00$33a$1@cyprus.atlantic.net>

According to John Callender <jbc@west.net>:
>Sadly, all this will be a moot point if moderation passes, since many of
>Tom's most enjoyable postings will be banned under the new group's
>charter -- unless Tom's status as a proponent (and his presumed presence
>on the moderation panel) means he gets special dispensation.

I don't expect Tom to get much special treatment in the moderated group.
There is a difference between "Perl stuff" and "stuff of possible interest
to Perl people."  The plan is for the moderated group to cover the former,
while leaving the unmoderated group for the latter.
-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: 08 Mar 1998 11:23:04 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Using perl to do what a spreadsheet does but with a plain text file as a source?
Message-Id: <sootp2xj.fsf@news.concentric.net>

Tony Gonzalez <oak@crl.OmitThis.com> writes:

> but I don't know enough about perl to get started....can anyone
> suggest a way to get started with this sort of thing, and is it a
> feasable approach?

Perl is very well suited for text-processing applications (amongst many
other things).  The problem you describe in your post is solvable with
a few lines of code.  Personally, for the particular task you mention,
I'd use a spreadsheet if one were available...  But please do go about
learning Perl, if that's what you want to do!  I'd recommend the book
_Learning Perl_.  You can find out about that book and other resources
at www.perl.com .

Here's a preview.  To get this output from your input:

		      Mon.    Tues.    Total
		      ------------------------
   Joe Schmoe          5.3     1.2      6.5
   John Doe            2.5     4.6      7.1
   William Henry       1.3     3.2      4.5

you might write this program:

   #!/usr/bin/perl -w
   while (<DATA>) {
     ((print),next) unless /TOTAL\?/;
     my $sum = 0;
     foreach (m/((?:\d+)\.?(?:\d+))/g) { $sum += $_ };
     s/TOTAL\?/sprintf(" %2.1f",$sum)/e;
     print;
   }
   __DATA__
		      Mon.    Tues.    Total
		      ------------------------
   Joe Schmoe          5.3     1.2     TOTAL?
   John Doe            2.5     4.6     TOTAL?
   William Henry       1.3     3.2     TOTAL?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: 8 Mar 1998 18:09:04 GMT
From: gleemoth@aol.com (GLEEMOTH)
Subject: Weekdays
Message-Id: <19980308180901.NAA17254@ladder03.news.aol.com>

Just a quick question. In my program I'm working on, I need to figure out the
weekday a date is on, given the year, month, and day. Thanks in advance for any
help.
             Shay Caron (Shay_Caron@letterbox.com
                                  -or-
                            gleemoth@aol.com)


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

Date: 8 Mar 1998 18:15:36 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Weekdays
Message-Id: <6dun88$j27@news.service.uci.edu>

In article <19980308180901.NAA17254@ladder03.news.aol.com>,
GLEEMOTH <gleemoth@aol.com> wrote:
<Just a quick question. In my program I'm working on, I need to figure out the
<weekday a date is on, given the year, month, and day. Thanks in advance for any
<help.

Look at the Date modules on CPAN.

-- 
Eric D. Friedman
friedman@uci.edu


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

Date: 08 Mar 1998 11:32:18 -0800
From: Evan Kirshenbaum <evan@garrett.hpl.hp.com>
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <v9hogzhm119.fsf@garrett.hpl.hp.com>

bart.mediamind@tornado.be (Bart Lateur) writes:

> Evan Kirshenbaum <evan@garrett.hpl.hp.com> wrote:
> 
> >On second thought, it appears that I may be being to charitable.  A
> >reading of perlobj points out that yes, there is true garbage
> >collection going on, but it happens *only* at interpreter shutdown (by
> >running a mark/sweep).  A test confirms that this appears to be what
> >happens.  This does guarantee that destructors are (eventually)
> >called, but it also means that a program that needs to repeatedly
> >build large temporary graphs is still going to find itself rapidly
> >growing and/or running out of memory due to uncollected garbage.
> 
> It seems like letting the programmer manually invoking the (full)
> garbage collector, just like happens at interpeter shutdown, might be a
> worthwile addition to the Perl kernel.

[Damn! I lost my connection halfway through typing a reply to this,
and I don't have any idea where xemacs might've squirreled it away.]

Yes, that would be useful, as would running it when you run out of
memory.  The problem is that mark/sweep is a particularly nasty form
of GC in that it has to walk all of the allocated memory, which can
take a *long* time (seconds or even minutes with a large memory).
This is why most garbage collected languages switched to incremental
schemes long ago.  Such schemes (e.g., generation scavenging or
incremental copying) do a "little bit of collection" every time a
pointer is copied or deleted.  The problem is that this imposes a bit
more overhead than reference counting for programs which don't have
circular structures (most perl programs) and which don't have to worry
about refcount overflow (the other big problem with refcounting).

It would be interesting to investigate adding a modern garbage
collector to Perl, but I doubt if I have sufficient expertise (not to
mention the time to understand all of the ramifications for the perl
source--garbage collection is something that is a *lot* easier to add
up front rather than bolting it onto a working system).  I suspect
that a great deal of efficiency can be regained by splitting the
collection strategy between those objects blessed in packages with
DESTROY methods and others (which can safely be simply dropped on the
floor). 

> In the meantime, a workaround might be manually breaking the circular
> chain, once you know you're through.

Yeah, that's the normal workaround.  There are two problems.  First,
you have to "know you're through".  This is, of course, the problem
that automatic memory management schemes are supposed to solve for
you.  This is compounded by the fact that with complex graphs, often
only part of it (around the edges) becomes garbage while there remains
a core of live data.  The second problem is that breaking the
circularity can be difficult.  In the case of a simple loop, it's
pretty straightforward.  To collect a doubly linked list requires
walking the entire list.  Breaking the circularity in an arbitrary
graph usually *doesn't* require breaking every link, but it takes a
full walk to decide which links need to be broken.

> In another part of this thread, Evan Kirshenbaum
> <evan@garrett.hpl.hp.com> wrote:
> 
> >By introspection, my litmus test for "true" garbage collection is
> >roughly "if I try to allocate a block of memory and there is a larger
> >block of garbage in a compatible heap, the allocation should succeed".
> 
> Well, yes. If Perl runs out of memory, the full GC should be invoked
> too. (Doesn't this already happen?)

It does, but only because running out of memory causes the interpreter
to exit, which invokes the GC.  You get cleaned up, but the script
doesn't get to use any of the memory that it reclaims.

-- 
Evan Kirshenbaum                       +------------------------------------
    HP Laboratories                    |The vast majority of humans have
    1501 Page Mill Road, Building 1U   |more than the average number of
    Palo Alto, CA  94304               |legs.

    kirshenbaum@hpl.hp.com
    (650)857-7572

    http://www.hpl.hp.com/personal/Evan_Kirshenbaum/


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

Date: 8 Mar 1998 18:23:47 GMT
From: "Dave Roth" <rothd@xrxoxtxhx.xnxextX>
Subject: Re: Win32 help request,  rename problem
Message-Id: <01bd4abf$a9323210$0101a8c0@main2>

Jack Lavender <jackal@fastlane.net> wrote in article
<6dps63$91d@news.cybernews.net>...
> I am running the ActiveState port of perl 3.15 on a NT
box with MS Personal
> Web Server.
> 
> I have a problem using the rename function.  If I run the
following script
> from the command line and the destination file exists,
then rename fails.
> If I run the script
> from the Server, it fails every time.
> 
> Anyone else have this kind of problem?  I am just
learning, so I am not sure
> about the expected behaviors.

In the Win32 world the rename is the same as move and move
fails if there already exists a file with the same name as
the new file name you are specifying.
Have you tried to check for an existing file and delete
(unlink) it if it does exist:
	unlink( $lock_file ) if ( -e $lock_file);

dave


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

Date: Sun, 08 Mar 1998 15:11:50 GMT
From: keefner@visi.com (keefner)
Subject: Re: Win32 Perl and ODBC New User Problems
Message-Id: <3502b5b1.86063893@news.visi.com>

On Wed, 04 Mar 1998 05:37:05 GMT, davidg@teleprompt.com (David
Griffis) wrote:

>I'm trying to get Activeware Win32 Perl 5.003 build 315 and Dave
>Roth's ODBC extention working with my NT 4.0 ODBC for Oracle 733 but
>I'm getting a 'parse error'.  What could I have done wrong?

You likely have the stock odbc driver for Oracle installed
and there is a documented problem with it. Make sure
you get the latest from Oracle.

Depending on how you want to access the Oracle
db (stored functions/procedures/etc) you may want
to consider the DBI/DBD modules and the perl port
for it.

Craig


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

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

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