[6846] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 471 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 13 23:07:19 1997

Date: Tue, 13 May 97 20:00:23 -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, 13 May 1997     Volume: 8 Number: 471

Today's topics:
     [Q] Getting date of a file?? (Wing-yee Cheung)
     CGI Environment vars <nightshadow@thevortex.com.nospam>
     Re: Decimals in PERL5 (Brian Lavender)
     fork and file i/o (Cheryl L. Southard)
     Re: Help! Stupid Problem w Script <mishra.aditya@emeryworld.com>
     Re: How Does Someone Copy a File in perl? (Chipmunk)
     Re: IlyaZ OS2 perl and PDKshell (Ilya Zakharevich)
     Re: Memory Clearing (Craig Berry)
     Re: New draft of scripting white paper (Paul Wilson)
     Re: New draft of scripting white paper <ffcano@locf201.ztandem.nospam>
     Re: New draft of scripting white paper (Raymond Johnson)
     Re: Notice to antispammers - is there a list of spammer <reriksso@cc.helsinki.fi>
     Objects and Reference Count (Daniel Walton)
     private scalar for each instance of an object? <dmi1@ra.msstate.edu>
     Re: regular expression <dorman@s3i.com>
     Re: SOLUTION: Drawing a graph? <mkruse@shamu.netexpress.net>
     Re: Sorting by date with format MMDDYY (Craig Berry)
     Re: unlink vs. system("rm...") (Abigail)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 13 May 1997 21:47:10 GMT
From: wycheung@acs3.acs.ucalgary.ca (Wing-yee Cheung)
Subject: [Q] Getting date of a file??
Message-Id: <5langu$nt4@ds2.acs.ucalgary.ca>

Hello there,

I looked into Randal's learning perl..it mentioned about the ability to 
grab the last modification date of a file by doing -M file and it does 
returns value...but how to do it?? Or shoudl I do ($mtime) = (stat("file"));
which returns some weird numbers....thanks in advance!!

winnie

--
       .
      ';;,        ,;
      ':;      ,;'    ;,
       ::;,  ,;;;,,,,,;;,
     ;'::';;  `'       ';;'   "Charm is deceitful and beauty
    ;;'::  ;'   ,                 is passing.  But a woman who fears
   `;  ::     ,;;;,,,,;;,              the LORD, she shall be praised."
       ::    ,;;       `;;             
       ::     `;        ;'            		-Proverbs 31:30
       :;      ;  ...   ;		
        ;      ;;''''';;'
	    ************************************************
            *.....until I get flamed for long sig again....*
	    ************************************************


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

Date: Tue, 13 May 1997 22:36:13 -0700
From: The Nightshadow <nightshadow@thevortex.com.nospam>
Subject: CGI Environment vars
Message-Id: <33794F4D.7B93@thevortex.com.nospam>

Can some1 pls give me a pointer to a list of environment variables
used in CGI? Thanks.

-- 
                          ,A
                         .A.    n
                 THE    .888   8
               |      .88'q88 d8
          ]====O(=====88==='q88'=ightshadow====*
               |     d8     q8
                    d"       '
                  .'

 [Remove .nospam from my e-mail to reply]


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

Date: Sun, 11 May 1997 22:24:40 GMT
From: brian@brie.com (Brian Lavender)
Subject: Re: Decimals in PERL5
Message-Id: <33763da6.5997258@nntp.netcruiser>

posted on comp.lang.perl.misc and cc to author

On 10 May 1997 17:25:34 GMT, "Greg Satterfield"
<Gssatte@Bellsouth.net> wrote:

>
>Can someone tell me how to format numbers in perl to 2 decimal points?
>Example, after a math calculation, how can I change the number
>859.68542567832 to 859.68?

I checked the faq for the answer to this one, but I could not find it.
Long ago I posed the same question and Rosely Flam Zalcman
<flamshep@idirect.com> sent me this answer. It works well for printing
to two decimal places.

>$scalar_var=14.3456;
>printf "The formated number is |%-5.2f|\n",$scalar_var;

>NB: This ROUNDS OFF your variable (try as I might "not" too).
>    The | bars | are to show you the white spaces added 
>    (if any, make it 10.2 and you'll see what I mean).
>    The % means print the attached variable in this spot ($scalar_var).
>    The - means left justified. 
>    The 5.2 = five characters wide, two following the decimal place.
>    The f means a floating point number.
>    
>Your $436.34 would be:

>$value_var=436.34467;
>printf "you owe me: \$|%-8.2f|\n", $value_var;  

>It'll print:

>$|436.34  |  

>Remove the |bars| and you "$" sign is o.k.


Now lets say you want to commafy your answer. This is in the faq, but
I am not sure to the solution if you wanted to commafy it and print it
to two decimal places. If you want to see the faq answer for
commafying go to

http://www.perl.org/CPAN/doc/FAQs/FAQ/PerlFAQ.html

and search for the question 

How can I output my numbers with commas added? 

If you combine the answer for placing commas in the number and then
using printf to print it to two decimal places it does not work. The
sample code is below (nonworking of course)

#!/usr/bin/perl

$initial_var= 98654436.34467;

$value_var = commify($initial_var);
printf "you owe me: \$|%-11.2f|\n", $value_var;   # This will print
you owe me: $|98.00      |  

sub commify {
        local $_  = shift;
        1 while s/^(-?\d+)(\d{3})/$1,$2/;
        return $_;
}

But of course there is a way to do it. The code below will print with
a dollar sign and commafy. (Working code follows)

#!/usr/bin/perl

$value_var = 98654436.34467;
$value_var *= 100;
$value_var = int($value_var);
$value_var /= 100;

$value_var = commify($value_var);

print "you owe me: \$$value_var\n";  # prints $98,654,436.34

sub commify {
        local $_  = shift;
        1 while s/^(-?\d+)(\d{3})/$1,$2/;
        return $_;
}

Brian
----------------
Brian Lavender
Napa, CA
Brie Business Directory - Napa Valley     http://www.brie.com/bbd 
(707) 226-8891

"Have you heard of the new improbability drive?"


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

Date: 12 May 1997 15:56:02 -0700
From: cld@yankee.caltech.edu (Cheryl L. Southard)
Subject: fork and file i/o
Message-Id: <5l8762$18h@yankee.caltech.edu>

Hi All,

Included is a very short perl script that does NOT do what I expect it
to do.  It is supposed to open a file, then print each line once.
However, what it does for me is to print out all the lines in the file,
rewind the file, then print them again, and sometimes a third time and 
fourth time, and sometimes it skips lines in the file.

Any clues on what's going on?  I would understand if the child was 
reading from the HOSTS stream, but it's not. What I THINK is going on is
that the "exit" from the child is somehow rewinding the HOSTS stream.
I've tried adding "use POSIX", but then the print statements aren't
re-directible (i.e. ./test.pl | less).

I'm running Perl version 5.003 under Solaris 2.5.  

Thanks,

Cheryl

--------------------------- test.pl---------------------------
#!/usr/local/bin/perl 
open(HOSTS, "./hosts") or die "Can't open ./hosts\n";
while($machine = <HOSTS>) {
        print "machine is $machine\n";
        if ($pid = fork) { 
        # in parent section
        } else {
        # in child's section
        exit;
        }
}
 
-- 
Cheryl Southard
cld@astro.caltech.edu


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

Date: Tue, 13 May 1997 17:14:45 -0700
From: "A. Mishra" <mishra.aditya@emeryworld.com>
To: Bob Clarke <sjguitar@comet.connix.com>
Subject: Re: Help! Stupid Problem w Script
Message-Id: <337903F5.15DB@emeryworld.com>

Bob Clarke wrote:
> 
> This is driving me nuts, not to mention the amount of time it's eating up.
> open (GUEST,">>guestbook.txt") || die "Can't Open guestbook.txt for outputting: $!\n;This is now

open (GUEST,">>guestbook.txt") || die "Can't Open guestbook.txt for outputting: $!\n";

Adi


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

Date: 11 May 1997 22:13:36 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: How Does Someone Copy a File in perl?
Message-Id: <5l5gag$7nt$1@dartvax.dartmouth.edu>

In article <5kvsfa$o95@sf18.dseg.ti.com>
simonson@skopen.dseg.ti.com (Kevin M Simonson) writes:

> ,-------------------------------------------------------------------.
> | i32^Perl/Cp} Hmm                                                  |
> | Search pattern not terminated in file Hmm at line 2, next char ^? |
> | Execution of Hmm aborted due to compilation errors.               |
> | i32^Perl/Cp} ls ../Hmm.Hmm                                        |
> | ../Hmm.Hmm*                                                       |
> | i32^Perl/Cp} cat Hmm                                              |
> | #!/usr/local/bin/perl                                             |
> | cp ../Hmm.Hmm .;                                                  |
> | i32^Perl/Cp}                                                      |
> `-------------------------------------------------------------------'

It thinks that the / in 'cp ../Hmm.Hmm .;' is the beginning of a search
pattern (i.e., $foo =~ /abc/).  Why are you trying to execute a shell
command with the perl interpreter?  If you want to use the perl
interpreter, you have to write perl code.
You have a couple of options:

#!/usr/local/bin/perl
`cp ..\/Hmm.Hmm .`;

#!/bin/sh
cp ../Hmm.Hmm .

alias Hmm cp ../Hmm.Hmm .

If the only thing you're doing is copying a file from one place to
another, it's rather silly to use perl.

Chipmunk


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

Date: 11 May 1997 23:30:52 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: IlyaZ OS2 perl and PDKshell
Message-Id: <5l5krc$rf0$1@mathserv.mps.ohio-state.edu>
Keywords: IlyaZ perl port, DOS, PDKshell

[A complimentary Cc of this posting was sent to whams
<whams@xs2.xs4all.nl>],
who wrote in article <5kln9k$ca0$1@news0.xs4all.nl>:
> Problem: _DOS_ Perl Scripts using the Shell.
> 
> Hello.
> 
> I'm using Ilya Zakharevitch's PERL5.003_93 OS2 port under
> MS-DOS6.20, with 4DOS5.50 as the DOS commandline processor;
> RSX 5.10 works as the 32-bit DOS extender running under the
> CWSDPMIv.0.9 DOS DPMI-server;
> As a Shell I'm using the PDKSH port from Ilya's FTP directory.
> 
> All of these programs, when started separately, seem to work as
> they should!
> 
> The PERL_SH_DIR environment variable is set to E:/PERL/BIN, which is
> also where PERL.EXE and RSX.EXE live, and which is in the PATH.
> 
> As far as I can see, this is conformant to Ilya's prescriptions in
> his README.os2.
> 
> Everything works fine - even fork() - but I'm having a bad time time
> trying to use the shell from within a perl script, as in these examples:
> 
> __BEGIN__
> #!/usr/bin/perl -w
> 
> $test = system q{c:\\4dos\\4dos.com /c dir};
> print $test;
> exit;
>   # actually shows the DIR listing, but then prints:
>   # can't spawn e:/perl/bin/sh.exe : function not implemented
>   # at e:\perl\bin\perltest.pl line 3
>   # 65280

Confirmed (with older RSX).  Looks like a bug in RSX, but to trace it
(and find a workaround) I need to get to my development machine, which
is not going to happen until end of June.

People having this problem may want to fallback to version 5.003_05,
which used a different calling mechanics. (Do not forget to set
PERL_SH_DIR instead of wronly spelled PERL_SHPATH, and use forward
slashes only in PERL_SH_DIR!)

> #$test = system `dir`;

   system `dir`;

is equivalent to

   $var = `dir`;
   system $var;

Are you sure you want this?

Ilya


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

Date: 12 May 1997 23:07:49 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Memory Clearing
Message-Id: <5l87s5$83l$1@marina.cinenet.net>

Torsten Naumann (Torsten.Naumann@informatik.tu-chemnitz.de) wrote:
: I filling a very big hash and then deleting every entry, but the ps -u
: shows me no change in the momory allocation of my perl program.
: How can I check that perl is freeing the memory ?

The best way I know is to write a prgram that accepts a count parameter N 
on the command line.  The pseudocode looks like

  do N times {
    fill the big hash
    empty the big hash
  }

  sleep long enough for ps -u to have a look at memory size
  exit

If the storage overhead does not vary as a function of N, then you can 
conclude that the 'empty' step is (internally) reclaiming memory.  It's 
quite likely that Perl never gives memory back to the OS other than on 
exit; many well-designed programs (in which category Perl *definitely* 
falls) manage their own memory internally, going to the OS only if more 
than the initial internal heap is needed, and keeping whatever they get 
from the OS until shutdown.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 11 May 1997 17:06:44 -0500
From: wilson@cs.utexas.edu (Paul Wilson)
Subject: Re: New draft of scripting white paper
Message-Id: <5l5ftk$qh0$1@boogie.cs.utexas.edu>

In article <5l325h$41h$1@engnews2.Eng.Sun.COM>,
John Ousterhout <ouster@tcl.eng.sun.com> wrote:
>This is to announce that I've posted a new revision of my scripting white
>paper.  You can get HTML and PostScript versions at the following URLs:
>
>	http://www.sunlabs.com/people/john.ousterhout/scripting.html
>	http://www.sunlabs.com/people/john.ousterhout/scripting.ps
>

This is a big improvement.  I still disagree with the strict
scripting/systems dichotomy, but the paper seems much more reasonable.
The earlier draft read too much like Tcl propaganda---even though
I'm sure that's not how you meant it---and this one seems much
more clearly centered on the actual issues.  

The last sentence of the conclusions section (saying you look forward to
more powerful scripting languages) hits just the right note.

The "other languages" section is too brief for my taste, but it's
reasonable in a short paper.  What you do say makes it clear that you
have considered other languages, and recognized some of their various
strengths.

One suggestion: you might want to briefly note that Smalltalk pioneered
GUIs built into interactive languages, which was really important.  One
of the very good things about Tcl and other scripting languages with 
graphics toolkits like Tk is that they restored that combination, which
is incredibly convenient.  

I, for one, really appreciate the fact that you've listened to criticisms
of the earlier draft, and improved the paper considerably.  Thank you.
-- 
| Paul R. Wilson, Comp. Sci. Dept., U of Texas @ Austin (wilson@cs.utexas.edu)
| Papers on memory allocators, garbage collection, memory hierarchies,
| persistence and  Scheme interpreters and compilers available via ftp from 
| ftp.cs.utexas.edu, in pub/garbage (or http://www.cs.utexas.edu/users/wilson/)      


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

Date: 13 May 1997 18:09:15 -0700
From: Jonathan Cano <ffcano@locf201.ztandem.nospam>
Subject: Re: New draft of scripting white paper
Message-Id: <k9qvi4mj1vo.fsf@prism.loc201.tandem.com>

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

>>>>> "JO" == John Ousterhout <ouster@tcl.eng.sun.com> writes:
In article <5l325h$41h$1@engnews2.Eng.Sun.COM> ouster@tcl.eng.sun.com (John Ousterhout) writes:


JO> This is to announce that I've posted a new revision of my
JO> scripting white paper.  You can get HTML and PostScript versions
JO> at the following URLs:

JO> 	http://www.sunlabs.com/people/john.ousterhout/scripting.html
JO>     http://www.sunlabs.com/people/john.ousterhout/scripting.ps

Could you possibly produce a PS version with change bars?

Just asking...

  --Jonathan

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

iQCVAwUBM3kQpdg65GR/Kx7xAQEfeQP/ZBp2K+jLsO+ChWh7SZ3zIT5x/LNS0Xrp
hgsJj9vDg5oqqJ+IPt39wgtx0p994Cz2Ih/fvv/54+Joqa7o29rkw5vJTZU2qRa9
n3BUAgT8IV0WZH4TkFwt2n370mZWnRh/kGSbQz/0SQXCxAbjYPKSAFYxZPJcl+Xc
RCoR2NTIcGY=
=ZGg3
-----END PGP SIGNATURE-----
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% WARNING: My "from:" mail header has been despamified. to get a valid
% address, delete all occurances of the character 'f', 'z' and replace
% .nospam with .com
%-------------------------------------------------------------------------
% Jonathan Cano  <ffcano@locf201.ztandem.nospam>
%                 ^^        ^    ^      .com
%-------------------------------------------------------------------------
% AGA 4-kyu, IGS 8k*            |  Waaay cheee dude!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


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

Date: 11 May 1997 22:48:15 GMT
From: rjohnson@Sun.COM (Raymond Johnson)
Subject: Re: New draft of scripting white paper
Message-Id: <5l5ibf$f0r$1@engnews2.Eng.Sun.COM>

Cimarron Taylor (cimarron@dis.org) wrote:
: 	I would like to claim that the current interest in general-purpose
: 	scripting and systems programming languages (e.g Tcl / Java) is 
: 	rapidly approaching a local maximum and in the beginning of the
: 	next century as more and more of our world's culture learns how 
: 	to represent business concepts in domain-specific computing languages 
: 	we will see a decline in the use of scripting and systems 
: 	programming and an increase in the use of domain-specific languages 
: 	supported by new generations of more powerful language construction 
: 	and analysis tools.  

I think I would agree that domain-specific languages will continue to
frow in usage.  However, I don't think that general purpose language
usage will shrink at all - what evidence do you have of it's decline?
I think the use of both domain-specific and general purpose languages
will grow as more of the world increases computer use.

Tcl is interesting in this space because it is often used to create domain
specific languages.  The extension mechanism in Tcl is powerful enough to
develop any type of new command, language construct, or programming paradigm
that makes sense for a given domain.  That's really what application level
scripting languages are all about.  Tcl is just one easy way to do that.

Ray Johnson


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

Date: 11 May 1997 17:57:12 +0300
From: era eriksson <reriksso@cc.helsinki.fi>
Subject: Re: Notice to antispammers - is there a list of spammers to pluginto procmail?
Message-Id: <p20207e6oqf.fsf@kontti.Helsinki.FI>

On 07 May 1997 10:34:18 -0400, Clark Dorman <dorman@s3i.com> posted to
comp.lang.perl.misc, comp.mail.misc:
 > regan@ao.com (Dave Regan) writes:
 >> In article <336f1c67.116909796@news.diac.com>,
 >> sitaram@diac.com (Sitaram Chamarty) writes:
 >> >My question, for Nathan or Tom or anyone else who knows, is: is there
 >> >a frequently updated list of spammers that I can periodically plug
 >> >into my procmail recipe as an include file?  (I do use procmail, but I
 >> >got tired of constantly adding addresses to it, hence this question).
 >> There is a list that AOL maintains.  It isn't necessarily in a format
 >> for directly plugging into procmail.  See:
 >> http://www.idot.aol.com/preferredmail/
 >> With a short Perl program I'm sure you can remove the HTML wrapping
 >> and get straight to the addresses.  From there it should be easy
 >> to add the wrapping to make it fit into procmail.  Then you can fire
 >> the whole mess off with cron and not have to worry about it anymore
 >> (except for when AOL changes the format of the file. :))
 > Ok, I've just started using procmail, and have had the same problem,
 > namely that spammers come from many addresses.  Here's a first cut
 > script.  Procmail gurus please let me know how to improve the procmail
 > file format.  If there is a better or additional source of spammers, I
 > can add that to the script as well.

There are a couple more that I'm aware of. 

 $ lynx -dump http://www.iki.fi/~era/procmail/links.html | tail -4
   52. http://www.panix.com/rc.shared
   53. http://www.rahul.net/dhesi/nojunk.txt
   54. http://www.idot.aol.com/preferredmail/
   55. http://www.cyberpass.net/~fekete/agis.rc

(I would welcome pointers to more. Private e-mail please?)

As a side comment, your Perl script could be generalized a bit if it
didn't assume anything about the name of the file to read and took
anything from standard input instead. That way, you could feed it any
ole file of domain names you happen to stumble over. (Stripping the
fancy HTML from AOL's file would of course then have to be outsourced
into a separate script, or made optional.) Similarly, you could spew
the results to standard output and let the user of the script decide
where it should be redirected. I'd probably wrap the whole mess up in
a Makefile -- including downloading of the AOL page when it's updated,
etc. and maybe add a cron job to run make in the right directory
occasionally. 

 > # Make the proper procmail file.  Note the lack of chop of $_ and
 > # resulting non-use of \n when printing $_ into the file.
 > while (<AOLPAGE>) {
 >    last if /^<\/MULTICOL>/;
 >    print PROC_ALT ":0:\n";
 >    print PROC_ALT "* ^From:.*$_";
 >    print PROC_ALT "IN.SPAMMER\n\n";
 > }

(This could then be expressed as sed -e 's/.*/:0:\
* ^From:.*&\
IN.SPAMMER\
/' instead -- short enough to go in the Makefile itself [if you can
figure out how to get make to cope with the newlines ;-].)

As regards the result of the main loop, I would in principle be
slightly wary of using a blanket wildcard to match. If you download a
block file with "usa.net" in it, it will also ditch mail from
"netusa.net" (to cite Eli's favorite example). You could construct a
slightly less free-form regular expression (something like 
 .*@([^ ,@]\\.)?$_\\> perhaps) without adding much overhead, although
it is less obvious for the casual reader what it's supposed to
accomplish. 
  You could also use scoring and add infinity for each match to reduce
duplication in the script. It will not really buy you much; it should
make the output slightly smaller but I wouldn't even bet on that.

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>


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

Date: Mon, 12 May 1997 23:09:59 GMT
From: dan@okdirect.com (Daniel Walton)
Subject: Objects and Reference Count
Message-Id: <3377a0a9.305074423@207.126.101.81>



I have some code that has a particular object instance (lets call it
Instance-A) which creates & owns another object instance (lets call
that Instance-B).  Along the course of execution, Instance-B decides
it needs to remove itself from Instance-A and then get garbage
collected to free up the memory space.

So Instance-B calls a method of Instance-A which makes Instance-A
remove the reference to Instance-B.  Now Instance-B has no reference
to it except, I am assuming, the reference on the function call stack.
So the method should return to Instance-B and finish any remaining
instructions in that function call and then proceed back to Instance-A
again which called Instance-B in the first place.  At this time,
Instance-B would be garbage collected and released from memory.

My question is, is this correct?  Perl won't core dump on me or
perform strangely if I do this will it?  

Thanks!


  _______________________________________________________________________
 | Daniel Walton <dan@okdirect.com> | OK Direct Internet Services, Inc.  |
 |     http://www.optichat.com      |      http://www.okdirect.com       |
 |-'`//`'-.,__,.-'`//`'-.,__,.-'`//`'-.,__,.-'`//`'-.,__,.-'`//`'-.,__,.-|
 |   CGI Programming            Web Chat          Domain Name Hosting    |
  ///////////////////////////////////////////////////////////////////////


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

Date: 11 May 1997 17:58:06 -0500
From: David Ishee <dmi1@ra.msstate.edu>
Subject: private scalar for each instance of an object?
Message-Id: <m34tc97h1d.fsf@gsubc.dot.edu>

I am trying to write my first perl object. In this object, I need to
have a private scalar variable that is global for the object, but each
instance of this object needs to have it's own private copy. I've got
a get_data subroutine to give $data to the outside world if someone
wants it. 

My first attempt was to say: 

my $data = undef; 

in the new() subroutine 
for the object. But with multiple instances, each instance is
operating on the same $data and it is causing problems. In C++, I
would declare $data to be private, then each object would get its own
copy. 

My question is: how do I create a global variable $data for an object,
but each instance gets its own copy to play with? 
-- 

David

+--------------------------------------------------------------------+
| David Ishee                                                        |
| MS grad student, Mechanical Engineering        dmi1@ra.msstate.edu |
| Mississippi State University                                       |
|                                                                    |
+------------- http://www2.msstate.edu/~dmi1/index.html -------------+


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

Date: 11 May 1997 17:42:53 -0400
From: Clark Dorman <dorman@s3i.com>
Subject: Re: regular expression
Message-Id: <dhgg9fzxe.fsf@s3i.com>


Zaheed Haque <zaheed.haque@ein.ericsson.se> writes:
> Just started to learn about regex. This learning is killing me.. I
> have bought the book "Mastering Regular Expression" still it's super
> tough stuff.. 
> 
> I am just wondering If there is any regular expression software or
> something out there anyone aware of.. Someting that takes input
> and shots out the correct regular expression in other words something
> thats makes regular expression easier.. I am just trying to
> find out if there any shortcut! -:)

There really are no shortcuts.  Regular expressions are special; they are
very powerful, flexible, and general.  With power and flexibility comes
complexity.  Perl adds many additional functions / operations that can be
used with regular expressions (ex. s/// and =~) with their own syntax and
rules.  

Hardly anyone knows everything about regular expressions.  However, learning
about them is possible, but requires practice and patience.  Perl is a good
mechanism since it is fast and easy at the basic level, and you can add as
you go on.  Just keep a script handy, and plug in all the examples you find
and dont fully understand.  Play with them, take them apart, rearrange them.
Most of the regex stuff that you need comes quickly.  The more esoteric stuff
is not needed often, but the important thing is to be able to eventually
figure it out when you need to.  

-- 
Clark Dorman				"Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html                -Francis Crick


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

Date: 14 May 1997 01:43:34 GMT
From: Matt Kruse <mkruse@shamu.netexpress.net>
Subject: Re: SOLUTION: Drawing a graph?
Message-Id: <5lb5c6$sfa@news1-alterdial.uu.net>

http://mkruse.netexpress.net/perl/

Here you will find my start of a module - Graph.pm

It uses GD.pm to do the graph creation entirely in perl (and is therefore 
totally portable!  yippee!).  It will do what you want - you give it some 
points and and it will create a graph that looks good.  Of course, you have 
total control over everything in the graph too if you want.

Right now, it just does bar graphs.  I don't have time to keep working on it 
right now, but I'd *LOVE* to have someone add functionality.  I think I have 
a great start on it, and adding to it wouldn't be too tough.

It's been working great for me at work in several applications (which is why 
i started writing it).

hope this helps...

David Combs <dkcombs@netcom.com> wrote:
: In article <1997050915094542258@rhrz-ts2-p2.rhrz.uni-bonn.de>,
: Michael Schuerig <uzs90z@uni-bonn.de> wrote:
: >Nathan V. Patwardhan <nvp@shore.net> wrote:
: >
: >> Michael Schuerig (uzs90z@uni-bonn.de) wrote:
: >> 
: >> : I'm looking for a module that draws a graph for me. I only want to input
: >> : nodes (with labels) and edges (with labels) and have the module do
: >> : everything else. Is there such a thing?
: >> 
: >> Yes.  Check CPAN for the Graph modules - I think there's one called GIFGraph
: >> which might do what you want.
: >
: >That's not what I had meant. I want to draw graphs, not charts. And I
: >don't even want to draw myself, I want the module to do the hard layout
: >work.
: >
: >Michael
: >
: >---
: >Michael Schuerig           Nothing helps a bad mood like spreading it.
: >mailto:uzs90z@uni-bonn.de                                     -Calvin
: >http://www.uni-bonn.de/~uzs90z/

: Very recently, there are suddenly MANY programs that do this --
: but I don't know of any in perl.  Nonetheless, you can always
: CALL them FROM perl.

: Every year since '94 there has been a symposium on the very subject
: you are interested in -- automatic drawing of (hairy) graphs (of the
: type you mean: edges, nodes, directed, non-directed, 3-d even, etc).

: Much of it is freely downloadable.  Lots of work is happening in
: your own country, Germany.

: Buy ALL THREE of these books (symposium proceedings), all from Springer
: Verlag, "Lecture Notes in Computer Science":

: '94: LNCS #894
: '95: LNCS #1027
: '96: LNCS #??? (It's here somewhere (the book), but I can't
:     find it right now).

: The titles all begin the same: "GRAPH DRAWING .*".

: Like I say, you want ALL THREE.  (as a little extra, each year
: they have a contest: they put out three or so problems (nodes, edges),
: and judge what programs generate either the most beautiful or
: maybe the most interesting graphs.

: Hope this helps!


-- 
Matt Kruse
mkruse@netexpress.net
http://mkruse.netexpress.net/                       http://www.mkstats.com/
---------------------------------------------------------------------------


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

Date: 12 May 1997 00:50:11 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Sorting by date with format MMDDYY
Message-Id: <5l5pg4$lmm$1@marina.cinenet.net>

Jack L. Owens (jlowens@ptconnect.infi.net) wrote:
: I need to sort an array of filenames by date. Unfortunately they are in
: the format "aMMDDYY.zip". What would be the simplest way to do this
: without reinventing the wheel?

I've done almost precisely that.  What worked for me was writing a sort
comparison function which knew how to pull apart the date subfields in the
name, then applying that to the array.  However, for a big enough array of
file names, that would get needlessly expensive, as each comparison
involves (re)deriving the sort information for each file name.  So for a
big list, it might be worthwhile creating a hash, keyed by the rearranged
date string ("YYMMDD"), with the corresponding value being the original
file name.  Then you could sort the keys of this array using a straight
string-compare ('cmp'). 

Also, if this is something you'll be doing regularly, you might want to 
think about changing the file name format for new data (if that's an 
option).  Not only could you make the names themselves lexically 
sortable, you could add a century guard to make it work past 1/1/2000.

Hope this helps!

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Wed, 14 May 1997 00:23:37 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: unlink vs. system("rm...")
Message-Id: <EA5AFE.2t0@nonexistent.com>

On 13 May 1997 22:07:35 GMT, Mike Stok wrote in comp.lang.perl.misc
URL: news:5laon7$4rd@news-central.tiac.net:
++ In article <3378D666.2E46@mathematica-mpr.com>,
++ the count  <eglamkowski@mathematica-mpr.com> wrote:
++ >if i create a file in a perl program (via open(FOO, ">foo.tmp"), and 
++ >later in the same program want to delete that file, which would be
++ >the preferred method of doing this:
++ >
++ >unlink("foo.tmp"); or
++ >system("rm -f foo.tmp");
++ 
++ unlink is likely to be more efficient as you don't have to run another
++ process, and also if you ever generate files with "odd" characters in
++ their name then you don't end up worrying about whether the a shell will
++ get spawned for you and if it does whether it'll mangle your file name.

True, but note that 'rm -f' will always succeed; that's what the -f
is doing. unlink however may fail, when you don't have permission to
delete it, or when it doesn't exist.

unlink and rm -f just aren't comparable. Unless you choose to ignore
return values anyway; then it hardly matters.

[To get around the effect of characters meaningful to the shell,
 avoid calling the shell: system ('rm', '-f', 'foo.tmp');]


Note that there is a difference between "rename ($file1, $file2);" and
"system ('mv', $file1, $file2);" - at least on certain platforms.



Abigail


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

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

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