[18782] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 950 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 21 14:15:59 2001

Date: Mon, 21 May 2001 11:15:28 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <990468928-v10-i950@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 21 May 2001     Volume: 10 Number: 950

Today's topics:
    Re: Random Numbers Script <rebelvideo@hotmail.com>
        RegEx Problem, Please?! <ofirb1@netvision.net.il>
    Re: RegEx Problem, Please?! <peb@bms.umist.ac.uk>
    Re: RegEx Problem, Please?! <ren@tivoli.com>
    Re: Sending wav-file through perl-script <rebelvideo@hotmail.com>
    Re: Sending wav-file through perl-script <flavell@mail.cern.ch>
        splitting string into an array <Laszlo.G.Szijarto@grc.nasa.gov>
    Re: splitting string into an array (Helgi Briem)
    Re: splitting string into an array nobull@mail.com
    Re: splitting string into an array <peb@bms.umist.ac.uk>
        Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
        Storing a filehandle in an object (Will)
    Re: Storing a filehandle in an object <rlogsdon@eris.io.com>
    Re: Storing a filehandle in an object nobull@mail.com
    Re: Storing a filehandle in an object nobull@mail.com
    Re: time of a file <Rene.Scheibe@gmx.net>
    Re: time of a file (E.Chang)
    Re: time of a file <tony_curtis32@yahoo.com>
    Re: time of a file <rlogsdon@eris.io.com>
        unlinking files under -T <webmaster@webdragon.unmunge.net>
    Re: unlinking files under -T (Mark Jason Dominus)
    Re: Why can't I localize a lexical variable? (Clinton A. Pierce)
    Re: Why can't I localize a lexical variable? nobull@mail.com
    Re: xtropia - Web_store <hartleh1@westat.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 19 May 2001 11:33:25 +0930
From: Chris <rebelvideo@hotmail.com>
Subject: Re: Random Numbers Script
Message-Id: <3B05D46D.75495D49@hotmail.com>

Hey Godzilla

we must think along the same lines :)

if sas needs to generate his unique number on the fly from say a cgi
script

the chance of two users hitting the script at the same time is fairly
high

so the time algorithm needs a mod
this is the one I use

sub CreateId {
#creates a unique id
#uses pre if provided

my $pre = shift || '';
my $rand = int (rand 100);# use rand in case two users access at the
same time
	"$pre" . time . $rand;
}

It is pretty good as far as not generating identical id's
 
-- 
Regards

Chris
rebelvideo@hotmail.com

"Godzilla!" wrote:
> 
> sas wrote:
> 
> > Does anyone have a script that will generate random numbers? Someone told me
> > I could do it with Perl but I don't know where to start. It must be a 5
> > digit random number which will be associated with a specific name, (an "ID"
> > number), I want to check against a log file to be sure the number hasn't
> > been used already and then add the number and associated name to that log
> > file.  Any help will be greatly appreciated.
> 
> This is the second post of your article within the past
> month. My presumption is you are not satisfied with the
> numerous answers provided the first go-around.
> 
> I am going to ignore your parameter of five digits
> and post some code this time rather than discussion
> only, as I posted last time I answered your article.
> Perhaps you will not post this article a third time,
> in turn. Maybe, you think?
> 
> There is a better method than use of random numbers.
> This method of mine does not require opening of a
> log file to check for pre-existing numbers. My method
> provides automatic sorting both numerically and by
> creation date of an entry. It assures no two numbers
> will be the same. This method is very simple, very
> fast and very efficient. It is an easy and rather
> quick method of using epoch seconds.
> 
> My test script below my signature includes a sleep
> method to highlight how you can control data base
> entries if needed. Should you be making entries
> only occasionally, there is no need for a sleep.
> You may also write code to turn this sleep function
> on and off, at will. This is exceptionally easy.
> My hunch is you have no need for a sleep function.
> I doubt you will be running large batch files of
> entries. If you were, you wouldn't be here asking.
> You would be looking at binary executable software
> for commercial applications.
> 
> There will be a major numerical rollover of epoch
> seconds in September. This does not present any
> significant problem if you allow one extra space
> in your data base for an added digit. This should
> not be a problem anyhow; a logical database does
> not use space padding nor restricted formatting.
> 
> This second time around, why don't you select a few
> methods provided by many people and, try them? You
> will not be provided with any different answers by
> returning and asking a third time.
> 
> This line is the heart of my code in conjunction
> with the timelocal module.
> 
>   print timelocal (localtime()), "\n"; sleep (1)
> 
> Godzilla!
> --
> 
> #!perl
> 
> use Time::Local;
> 
> print "Content-type: text/plain\n\n";
> 
> for ($iterate = 0; $iterate <= 6; $iterate++)
>  { print timelocal (localtime()), "\n"; sleep (1) }
> 
> exit;
> 
> PRINTED RESULTS:
> ________________
> 
> 990140344
> 990140345
> 990140346
> 990140347
> 990140348
> 990140349
> 990140350


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

Date: Sun, 20 May 2001 21:38:04 +0200
From: "biG" <ofirb1@netvision.net.il>
Subject: RegEx Problem, Please?!
Message-Id: <9e92vh$fmv$1@news.netvision.net.il>

Hi all!

I want to get specific part out of a document.
I go like this:

$MyStart =~ m/This is the beginning of the part I want/; # get the matching
starting part of the document
$MainBody = $';  # get the part AFTER the match
$MyEnd =~ m/End of match/; # get the end of the matching part
$BeforeBody = $`; (that's a backtick...) # get the part BEFORE the end of
match
Print $MainBody;

Why doesn't it work? Am I missing something?
Thanks in advance,
--
Ofir
Capital letters were always the best way of dealing with things you didn't
have a good answer to. - Douglas Adams





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

Date: Mon, 21 May 2001 18:18:23 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: RegEx Problem, Please?!
Message-Id: <3B094DDF.493B3768@bms.umist.ac.uk>

biG wrote:
> 
> Hi all!
> 
> I want to get specific part out of a document.
> I go like this:
> 
> $MyStart =~ m/This is the beginning of the part I want/; # get the matching

Here you're just testing to see if $MyStart contains the string in the
m//;
This doesn't put the match into the variable (I assume this is what you
wanted to do). 

> starting part of the document
> $MainBody = $';  # get the part AFTER the match
> $MyEnd =~ m/End of match/; # get the end of the matching part
> $BeforeBody = $`; (that's a backtick...) # get the part BEFORE the end of
> match
> Print $MainBody;
> 
> Why doesn't it work? Am I missing something?

you could try something like:

$string = "start this is the main body end";
($start, $main, $end) = $string =~ /^(start)(.*?)(end)$/;

or if you're looping through a file and you just want to print out or
store the part of the document you're interested in you could try
something like:

while(<DOCUMENT>){
	push(@interesting, $_) if (/start regex/../end regex/);
}

this results in the line with the start and end regexes being placed
into the @interesting array along with the main body that you wanted to
parse out.  If you don't want these a simple pop and unshift should sort
that out.

HTH

Paul


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

Date: 21 May 2001 12:26:06 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: RegEx Problem, Please?!
Message-Id: <m3lmnqehqp.fsf@dhcp9-172.support.tivoli.com>

On Sun, 20 May 2001, ofirb1@netvision.net.il wrote:

> $MyStart =~ m/This is the beginning of the part I want/; # get the matching
> starting part of the document

What's in $MyStart?  This matches against the string in $MyStart.

> $MainBody = $';  # get the part AFTER the match

This saves the portion of $MyStart after the match into $MainBody.

> $MyEnd =~ m/End of match/; # get the end of the matching part

This matches against the string in $MyEnd.

> $BeforeBody = $`; (that's a backtick...) # get the part BEFORE the end of
> match

This saves the portion of $MyEnd before the match into $MainBody.

> Print $MainBody;
> 
> Why doesn't it work? Am I missing something?

In what way does it not work?  You haven't said what you expect.  You
haven't said what the input data looks like.  You haven't said what
the output data looks like.

Based on what you've given, all we can do is look for syntax errors or
obvious logical errors.  We're going to need more than that to go on.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Sat, 19 May 2001 13:17:52 +0930
From: Chris <rebelvideo@hotmail.com>
Subject: Re: Sending wav-file through perl-script
Message-Id: <3B05ECE8.22AA878B@hotmail.com>



"Alan J. Flavell" wrote:
>
> On Fri, 18 May 2001, Chris wrote:
>
> > > based on content type. My opinion is browsers should be
> > > able to assign an extension based on content type, such
> > > as mid, ra, ru, wav and others.
> >
> > You are right, perhaps all it would take is the adoption of mime
>
> You seem to be advocating the opposite.  MIME informs the recipient
> via the content-type information.  File naming conventions are to be
> considered non-portable.

As far as I can see and I haven't read the rfc's so I am probably wrong
each part of a multi part message does have the filename in it

look at any email with an attachment
(browsers do use Mime I have realised, just send a file using a html
form)

>
> > in a multipart message the filename is included as part of the message
>
>
> > My biggest complaint in this area is that if the browser doesn't get a
> > content-type it ASSUMES the content is text and mangles it accordingly
>
> May we see an example of this happening?  I can't help suspecting
> you're confusing with the default _server_ assumption, and subsequent
> creation of a text/plain content-type by the server.

You are correct the default SERVER assumption I was incorrectly blaming
the browsers
me = dickhead :)

>
> > whoever made that stupendous blunder has caused countless headaches
>
> It's easily solved: configure your server to send
> application/octet-stream as the default instead.  Then wait for the
> complaints to roll in.

only particularly dumb text rendering software such as NoteBook in M$
has trouble reading unix text.

I don't know about the other way around as I work in an M$ environment

But next time you download a 3 Meg Zip file over a modem and you find it
is corrupted you tell me what you'd prefer

poorly formatted text or a working zip file

give me  application/octet-stream any day hands down!!!!!

Oh and for those who don't realise it, many of us have to work with
virtual servers, we can't all afford the luxury of our own server.

We cannot simply change a servers settings, we have to negotiate with
often inflexible ISP's who either take forever or simply refuse to
change settings on the server to accomodate special requirements, such
as a custom file format

for example I created a program that would take a zip file that had been
broken down into more managable chunks
recombine it and then unzip them.

each part was simply called

something.p01
something.p02 etc...

Simple enough hey!

No F@#$%^& way when I uploaded it to the server it would send the plain
text bullshit to the browser which would mangle it and the process
failed.

It took over a week for me to discover the reason, and then required
fix.
Yes I was/am a novice, we all have to start somewhere.

it took several weeks to convince my ISP that I NEEDED to change the
servers settings to allow for my custom extensions

So sorry the idiot who decided to use plaintext as a default, was in
fact a dickhead.

default = text/plain = mangle = dickhead; logical isn't it.

there now that's off my chest I feel better

>
> > But Hey arent we a little of topic :)
>
> Yes.  f'ups prophylactically set.

Chris
rebelvideo@hotmail.com


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

Date: Mon, 21 May 2001 18:14:05 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Sending wav-file through perl-script
Message-Id: <Pine.LNX.4.30.0105211807290.10569-100000@lxplus003.cern.ch>


This is desperately O.T, so I'll be brief...

On Sat, 19 May 2001, Chris wrote:

> Oh and for those who don't realise it, many of us have to work with
> virtual servers, we can't all afford the luxury of our own server.

> We cannot simply change a servers settings,

 .htaccess in your web root directory.  Assuming the ISP is running
Apache, of course (and if not, why ever not...).

> we have to negotiate with
> often inflexible ISP's who either take forever or simply refuse to
> change settings on the server to accomodate special requirements,

I'd say the advice given at http://www.mnot.net/cache_docs/#META
applies here too

  If your site is hosted at an ISP or hosting farm and they don't give
  you the ability to set arbitrary HTTP headers [...], complain
  loudly; these are tools necessary for doing your job.

>
>
[much rudeness omitted]
>
>
> > > But Hey arent we a little of topic :)
> >
> > Yes.  f'ups prophylactically set.

Hmmm.



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

Date: Mon, 21 May 2001 11:52:06 -0400
From: "Laszlo G. Szijarto" <Laszlo.G.Szijarto@grc.nasa.gov>
Subject: splitting string into an array
Message-Id: <9ebdi9$e7d$1@sulawesi-fi.lerc.nasa.gov>

Hello, Everyone,

I apologize for my inexperience.  What is the most efficient way to split up
a string of text which has numbers delimited by single spaces into an array
of numbers?

for example, I have
"-64 23 -15 42 3 8" etc ...
I would like to split that up into an array where $arr[0]=-64 and $arr[1]=23
 ... and so forth.

Thank you very much,
Laszlo Szijarto




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

Date: Mon, 21 May 2001 16:47:26 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: splitting string into an array
Message-Id: <3b09461e.3546327188@news.isholf.is>

On Mon, 21 May 2001 11:52:06 -0400, "Laszlo G. Szijarto"
<Laszlo.G.Szijarto@grc.nasa.gov> wrote:

>Hello, Everyone,
>
>I apologize for my inexperience.  What is the most efficient way to split up
>a string of text which has numbers delimited by single spaces into an array
>of numbers?
>
>for example, I have
>"-64 23 -15 42 3 8" etc ...
>I would like to split that up into an array where $arr[0]=-64 and $arr[1]=23
>... and so forth.

This is a FAQ and you seem to know that split is
the function you want. Have a look at

perldoc -q split

It will tell you to do something like this:

my @array = split /\s/,$string;

Regards,
Helgi Briem


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

Date: 21 May 2001 17:45:13 +0100
From: nobull@mail.com
Subject: Re: splitting string into an array
Message-Id: <u97kzabqhy.fsf@wcl-l.bham.ac.uk>

"Laszlo G. Szijarto" <Laszlo.G.Szijarto@grc.nasa.gov> writes:

> I apologize for my inexperience.  What is the most efficient way to split up
> a string of text which has numbers delimited by single spaces into an array
> of numbers?

Use the split() function.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 21 May 2001 18:22:51 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: splitting string into an array
Message-Id: <3B094EEB.DD208152@bms.umist.ac.uk>

"Laszlo G. Szijarto" wrote:
> 
> Hello, Everyone,
> 
> I apologize for my inexperience.  What is the most efficient way to split up
> a string of text which has numbers delimited by single spaces into an array
> of numbers?
> 
> for example, I have
> "-64 23 -15 42 3 8" etc ...
> I would like to split that up into an array where $arr[0]=-64 and $arr[1]=23
> ... and so forth.

well firstly you should have checked the FAQ and had a look at the
documentation on split (you can get this using the commandline perldoc
program.  Try typing 'perldoc -f split').

Sorry, had to get the rant out of the way first.

The simple answer is :

$string = "-64 23 -15 42 3 8";
@arr = split(/ /,$string);

but if you're interested in preserving any null entries at the end of
the string you should use

@arr = split(/ /, $string, -1);

HTH

Paul


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

Date: Mon, 21 May 2001 15:17:53 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <tgicd16mmtg5a9@corp.supernews.com>

Following is a summary of articles spanning a 7 day period,
beginning at 14 May 2001 15:31:11 GMT and ending at
21 May 2001 14:28:33 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" email address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 2001 Greg Bacon.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Excluded Posters
================

perlfaq-suggestions\@(?:.*\.)?perl\.com
faq\@(?:.*\.)?denver\.pm\.org

Totals
======

Posters:  331
Articles: 1201 (481 with cutlined signatures)
Threads:  260
Volume generated: 2270.3 kb
    - headers:    996.4 kb (19,415 lines)
    - bodies:     1207.1 kb (38,730 lines)
    - original:   758.3 kb (26,644 lines)
    - signatures: 65.6 kb (1,573 lines)

Original Content Rating: 0.628

Averages
========

Posts per poster: 3.6
    median: 1 post
    mode:   1 post - 168 posters
    s:      7.1 posts
Posts per thread: 4.6
    median: 3.0 posts
    mode:   1 post - 60 threads
    s:      7.5 posts
Message size: 1935.7 bytes
    - header:     849.6 bytes (16.2 lines)
    - body:       1029.2 bytes (32.2 lines)
    - original:   646.5 bytes (22.2 lines)
    - signature:  55.9 bytes (1.3 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

   61   154.6 ( 55.7/ 98.4/ 74.8)  "Godzilla!" <godzilla@stomp.stomp.tokyo>
   49   106.4 ( 55.1/ 44.4/ 26.5)  tadmc@augustmail.com
   47    85.3 ( 35.4/ 49.8/ 20.2)  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
   37    54.1 ( 21.7/ 27.1/ 17.0)  Craig Berry <cberry@cinenet.net>
   37    56.2 ( 31.7/ 24.2/ 13.8)  Bart Lateur <bart.lateur@skynet.be>
   29    58.9 ( 21.8/ 34.9/ 18.4)  nobull@mail.com
   22    47.6 ( 21.5/ 22.7/ 21.8)  abigail@foad.org
   20    27.4 ( 17.1/ 10.3/  2.3)  AvA <a.v.a@home.nl>
   18    35.1 ( 14.6/ 20.4/ 12.8)  Eric Bohlman <ebohlman@omsdev.com>
   18    38.2 ( 16.4/ 19.5/  8.5)  Joe Schaefer <joe+usenet@sunstarsys.com>

These posters accounted for 28.1% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

 154.6 ( 55.7/ 98.4/ 74.8)     61  "Godzilla!" <godzilla@stomp.stomp.tokyo>
 106.4 ( 55.1/ 44.4/ 26.5)     49  tadmc@augustmail.com
  85.3 ( 35.4/ 49.8/ 20.2)     47  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
  58.9 ( 21.8/ 34.9/ 18.4)     29  nobull@mail.com
  56.2 ( 31.7/ 24.2/ 13.8)     37  Bart Lateur <bart.lateur@skynet.be>
  54.1 ( 21.7/ 27.1/ 17.0)     37  Craig Berry <cberry@cinenet.net>
  47.6 ( 21.5/ 22.7/ 21.8)     22  abigail@foad.org
  45.6 ( 10.5/ 32.7/ 19.6)     17  Chris Stith <mischief@velma.motion.net>
  38.2 ( 16.4/ 19.5/  8.5)     18  Joe Schaefer <joe+usenet@sunstarsys.com>
  36.9 ( 14.6/ 22.3/ 11.3)     13  myluck42@yahoo.com

These posters accounted for 30.1% of the total volume.

Top 10 Posters by OCR (minimum of five posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.996  (  6.7 /  6.8)      9  Rafael Garcia-Suarez <rgarciasuarez@free.fr>
0.988  (  7.5 /  7.6)      6  "Scott R. Godin" <webmaster@webdragon.unmunge.net>
0.957  ( 21.8 / 22.7)     22  abigail@foad.org
0.936  (  2.3 /  2.4)      5  jtjohnston <jtjohnston@courrier.usherb.ca>
0.930  (  2.2 /  2.4)      6  "Matt L." <mlaw@talk21.comNOSPAM>
0.906  ( 22.7 / 25.0)      5  James freeman <jfreeman@tassie.net.au>
0.825  (  9.4 / 11.5)      9  Eric <nospam@xx.com>
0.760  ( 74.8 / 98.4)     61  "Godzilla!" <godzilla@stomp.stomp.tokyo>
0.739  (  5.8 /  7.9)      6  dave@mo-seph.com
0.722  ( 10.4 / 14.4)     15  "Alan J. Flavell" <flavell@mail.cern.ch>

Bottom 10 Posters by OCR (minimum of five posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.422  (  3.8 /  8.9)      6  Dave VP <me@my_no_spam.org>
0.417  (  2.0 /  4.7)      5  "John W. Krahn" <krahnj@acm.org>
0.415  (  4.6 / 11.2)     13  Uri Guttman <uri@sysarch.com>
0.406  ( 20.2 / 49.8)     47  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
0.381  (  3.3 /  8.6)     16  bernard.el-hagin@lido-tech.net
0.379  (  1.8 /  4.6)      5  "Andre Probst" <ap@andre-probst.de>
0.369  (  1.0 /  2.8)      7  John Joseph Trammell <trammell@bayazid.hypersloth.invalid>
0.223  (  2.3 / 10.3)     20  AvA <a.v.a@home.nl>
0.185  (  1.3 /  6.9)      9  "carlos" <carlos@plant.student.utwente.nl>
0.136  (  1.2 /  8.9)      6  John Martin Ping <webmaster@domainenterprises.com>

63 posters (19%) had at least five posts.

Top 10 Threads by Number of Posts
=================================

Posts  Subject
-----  -------

   77  Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
   28  An Example Of A Polite FAQ
   22  Measuring the time
   20  regExp question
   19  What is wrong with my Regular Expression?
   19  garbage collection in perl
   17  Can anyone help me please?
   16  Searching for Postal Code
   16  Stubborn regex won't work
   16  Taint

These threads accounted for 20.8% of all articles.

Top 10 Threads by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Subject
--------------------------  -----  -------

 169.9 ( 75.2/ 89.6/ 49.6)     77  Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
  82.3 ( 23.8/ 57.6/ 37.8)     28  An Example Of A Polite FAQ
  43.3 ( 12.7/ 29.5/ 16.3)     13  Cabal Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
  39.4 (  5.6/ 33.8/ 25.6)      8  Bits and bytes
  38.5 ( 18.5/ 18.4/ 11.3)     19  What is wrong with my Regular Expression?
  38.3 ( 17.8/ 19.0/ 11.8)     22  Measuring the time
  36.6 (  7.5/ 28.3/ 13.4)      9  Hash: keys to variable names, or variable names to keys?
  33.6 ( 17.2/ 14.9/  8.0)     20  regExp question
  32.5 ( 14.4/ 17.2/  9.7)     17  Can anyone help me please?
  31.1 ( 11.5/ 19.2/ 14.1)     16  Match Parsing Glitch

These threads accounted for 24.0% of the total volume.

Top 10 Threads by OCR (minimum of five posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Subject
-----  --------------  -----  -------

0.886  (  4.6/   5.2)      5  aol proxy
0.835  (  9.6/  11.5)      9  Transliteration Creates A \r Character Accidently??
0.827  (  2.4/   2.8)      6  page transition when submitting form
0.827  ( 10.2/  12.4)      6  Benefits of "strict" and "-w"?
0.808  (  1.6/   2.0)      5  Diary
0.806  (  5.0/   6.2)      5  oh c'mon please, one of you perl/unix gurus!!!
0.805  (  5.2/   6.5)      6  perl book
0.799  (  4.7/   5.9)      6  Hyphenated File Names
0.792  (  3.7/   4.7)      5  Stumped on $?, duplicate output
0.787  (  6.2/   7.9)      6  HTTP Response suppression

Bottom 10 Threads by OCR (minimum of five posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Subject
-----  --------------  -----  -------

0.457  (  2.5 /  5.4)      8  I only want 2 digts behind the dot of a currency value
0.449  (  2.6 /  5.7)     11  i want to tokenize a string
0.417  (  2.4 /  5.8)      5  if ($x in @a) equivalent in perl?
0.406  (  2.6 /  6.3)      7  regexp: delete everything between <?  ... ?>
0.406  (  1.6 /  4.0)      5  Perl Modules
0.400  (  1.8 /  4.6)      7  xtropia - Web_store
0.399  (  0.8 /  2.0)      5  Addition
0.367  (  1.2 /  3.3)      8  find.pl private to Perl?
0.319  (  2.0 /  6.4)      9  assigning a subroutine to a variable
0.274  (  1.3 /  4.6)      5  non repeating random numbers

84 threads (32%) had at least five posts.

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      24  comp.lang.perl.modules
      11  alt.perl
      10  comp.lang.perl
       6  comp.lang.perl.moderated
       3  comp.lang.functional
       3  comp.lang.scheme
       3  comp.lang.smalltalk
       3  comp.lang.lisp
       3  comp.lang.ada
       3  misc.education

Top 10 Crossposters
===================

Articles  Address
--------  -------

      14  "Biep @ http://www.biep.org/" <reply-via@my-web-site.com>
       6  "illya" <illya@rosen-bote.de>
       5  Ron Reidy <rereidy@indra.com>
       5  "Alan J. Flavell" <flavell@mail.cern.ch>
       4  Andrew Clover <andrew@white.oaktree.co.uk>
       4  Wojciech Domalewski <Wojciech.Domalewski@pnti.waw.pl>
       3  "flash" <bop@mypad.com>
       3  AvA <a.v.a@home.nl>
       3  "Lance Duncan" <duncanl@bisnet.net>
       2  "RGS" <ronald_starling@intuit.com>


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

Date: 21 May 2001 08:10:14 -0700
From: w_keeling@yahoo.com (Will)
Subject: Storing a filehandle in an object
Message-Id: <cd46a84c.0105210710.38ff8914@posting.google.com>

Does anybody know if it is possible to open a filehandle in an
object's contructor and then store that filehandle as part of the
object for use later by methods of that object?

I am aware of the module IO::File which could potentially do this job
but I specifically require the use of the format() function which can
only take a handle as it's argument and not another expression.

Thanks,

Will


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

Date: Mon, 21 May 2001 10:53:20 -0500
From: Reuben Logsdon <rlogsdon@eris.io.com>
Subject: Re: Storing a filehandle in an object
Message-Id: <Pine.LNX.4.21.0105211051260.19280-100000@eris.io.com>


you can use this code in your new() function:

my $handle = *FOO;
$self->{'p_handle'} = \$handle;

then whenever you need to reference this filehandle, use:

my $p_handle = $self->{'p_handle'};
then
open($$p_handle, "fjdsaj") || ...
$_ = readline($$p_handle);
etc.



On 21 May 2001, Will wrote:

> Does anybody know if it is possible to open a filehandle in an
> object's contructor and then store that filehandle as part of the
> object for use later by methods of that object?
> 
> I am aware of the module IO::File which could potentially do this job
> but I specifically require the use of the format() function which can
> only take a handle as it's argument and not another expression.
> 
> Thanks,
> 
> Will
> 

-- 
Regards,
Reuben Logsdon

http://www.io.com/~rlogsdon/




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

Date: 21 May 2001 18:13:41 +0100
From: nobull@mail.com
Subject: Re: Storing a filehandle in an object
Message-Id: <u9y9rqaam2.fsf@wcl-l.bham.ac.uk>

Reuben Logsdon <rlogsdon@eris.io.com> writes untrimmed-jeopary style
which is a big clue he's talking rubbish:

[jeopardectomy ]
> On 21 May 2001, Will wrote:
> 
> > Does anybody know if it is possible to open a filehandle in an
> > object's contructor and then store that filehandle as part of the
> > object for use later by methods of that object?
> > 
> > I am aware of the module IO::File which could potentially do this job
> > but I specifically require the use of the format() function which can
> > only take a handle as it's argument and not another expression.

> you can use this code in your new() function:
> 
> my $handle = *FOO;
> $self->{'p_handle'} = \$handle;

Bad.  This makes $handle into a fake GLOB and fake GLOBs are a pain in
the proverbials.

The above is better written as:

$self->{'p_handle'} = \*FOO;

This is still bad because all instances of the object are sharing one
file handle.

The OP says he's aware of IO::File and IO::File is indeed the correct
solution here.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 21 May 2001 18:20:46 +0100
From: nobull@mail.com
Subject: Re: Storing a filehandle in an object
Message-Id: <u9vgmuaaa9.fsf@wcl-l.bham.ac.uk>

w_keeling@yahoo.com (Will) writes:

> Does anybody know if it is possible to open a filehandle in an
> object's contructor and then store that filehandle as part of the
> object for use later by methods of that object?

Yes.

> I am aware of the module IO::File which could potentially do this job

IO::File is the correct solution.

> but I specifically require the use of the format() function which can
> only take a handle as it's argument and not another expression.

The thing that comes after the word format is a format name not a file
handle.

By default named filehandles[1] get associates with the format of the
same name.  You can use the format_name() method to associate a
format with a file handle that was retuned from IO::File->new.

[1] Yes, I know that even filehandles returned from IO::File->new()
have names really, but this is an implementational artifact,
conceptually they are anonymous.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 21 May 2001 15:26:23 +0200
From: "Rene Scheibe" <Rene.Scheibe@gmx.net>
Subject: Re: time of a file
Message-Id: <9eb4vr$21ogh$1@ID-65612.news.dfncis.de>

What if I need just some of this stats?
Do I really have to declare all of them or
how do I do when I let's say just need $atime?




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

Date: Mon, 21 May 2001 13:34:30 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: time of a file
Message-Id: <Xns90A861D63ADC9echangnetstormnet@207.106.93.86>

"Rene Scheibe" <Rene.Scheibe@gmx.net> wrote in <9eb4vr$21ogh$1@ID-
65612.news.dfncis.de>:

> What if I need just some of this stats?
> Do I really have to declare all of them or
> how do I do when I let's say just need $atime?
> 

See "perldoc -f -X" for information about the 27 file test operators, 
including

   -M  Age of file in days when script started.
   -A  Same for access time.

-- 
EBC


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

Date: 21 May 2001 09:10:06 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: time of a file
Message-Id: <871ypirdxd.fsf@limey.hpcc.uh.edu>

>> On Mon, 21 May 2001 15:26:23 +0200,
>> "Rene Scheibe" <Rene.Scheibe@gmx.net> said:

> What if I need just some of this stats?  Do I really
> have to declare all of them or how do I do when I let's
> say just need $atime?

(Please include *some* context from the article to which
you are responding to indicate what you are replying to)

You can encapsulate stat's behaviour with the File::stat
module.

    perldoc File::stat

e.g. from the SYNOPSIS

    use File::stat;
    $st = stat($file) or die "No $file: $!";
    if ( ($st->mode & 0111) && $st->nlink > 1) ) {
        print "$file is executable with lotsa links\n";
    }

hth
t
-- 
Just reach into these holes.  I use a carrot.


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

Date: Mon, 21 May 2001 10:46:26 -0500
From: Reuben Logsdon <rlogsdon@eris.io.com>
Subject: Re: time of a file
Message-Id: <Pine.LNX.4.21.0105211045450.19280-100000@eris.io.com>


use:

my $last_access_t = (stat($file))[8];

On Mon, 21 May 2001, Rene Scheibe wrote:

> What if I need just some of this stats?
> Do I really have to declare all of them or
> how do I do when I let's say just need $atime?
> 
> 
> 

-- 
Regards,
Reuben Logsdon

http://www.io.com/~rlogsdon/




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

Date: 21 May 2001 14:05:25 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: unlinking files under -T
Message-Id: <9eb7b5$1ok$0@216.155.32.44>

using the following code snippet 

# During-Usage Cleanup of old user-created files, but save our samples.
opendir(DIR, $output_path) or die "Cannot Open Output Dir $output_path 
-- $!";
my @oldfiles = readdir(DIR);
closedir(DIR) or die "closing read on $output_path directory failed: $!";

foreach my $oldfile (@oldfiles) 
{
    #preserve samples, index, and stylesheet
    next if $oldfile =~ /^index/;
    next if $oldfile =~ /^dm-sample/;
    next if $oldfile =~ /css$/;

    # now get the time differential between now and file's last 
    # modification date. non-preserved files older than 24 hours
    # get cleaned up.

    if ( ( time - (stat("$output_path$oldfile"))[9] ) >= 86400)
    { 
        # diagnostics
        #print  my $date = 
        #   localtime((stat("$output_path$oldfile"))[9]), 
        #   " = $output_path$oldfile\n";
        unlink "$output_path$oldfile"; #older than 24 hours
    }
}

I get an "Insecure dependency" warning about the unlink. Now, none of 
this information is user-generated, so I don't quite understand why I 
get a warning of this nature unless it's because ANY unlink operation is 
considered unsecure (which seems to be the case, from my perusal of 
perlsec.pod).

Since these files are created by the program (run as a CGI form), they 
will need to be periodically cleaned up to prevent using up the user's 
disk quota. How can I go about doing such a thing under -T, if this is 
at all possible?

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: Mon, 21 May 2001 15:04:21 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: unlinking files under -T
Message-Id: <3b092e74.54b$334@news.op.net>

In article <9eb7b5$1ok$0@216.155.32.44>,
Scott R. Godin <webmaster@webdragon.unmunge.net> wrote:
>I get an "Insecure dependency" warning about the unlink. Now, none of 
>this information is user-generated, so I don't quite understand why I 
>get a warning of this nature 

Data in a directory might very well have been user-generatred---the
user could come along and create a bunch of files with maliciously
constructed names that cause the program to do unexpected.  

Now, perhaps that is impossible in this particular case, but there is
now way for Perl to know that unless you tell it.

The general rule is that *all* data from outside your program is
considered untrustworthy.

>unless it's because ANY unlink operation is considered unsecure
>(which seems to be the case, from my perusal of perlsec.pod).

There are two concepts here:

1. unlink() is considered 'unsafe'
2. data read from directories is considered untrustworthy

You get the 'Insecure Dependency' failure when you perform an unsafe
operation with untrustworthy data.  Both conditions need to be
satisfied.    An unsafe operation with trustworthy data will not
trigger the error; nor will  a safe operation with untrustworthy data.

>How can I go about doing such a thing under -T, if this is 
>at all possible?

Your perusal of 'perlsec.pod' seems to have been rather perfunctory.

Since you turned on -T as a security feature, why is it that you are
resisting learning exactly what the security is for?  If you don't
want to understand the security, why not make your problems go away by
removing -T?

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 21 May 2001 16:28:57 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Why can't I localize a lexical variable?
Message-Id: <dnbO6.59090$V5.11120150@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <5djdgt8jdtmlgbrtb8in3k31vhirdgf3ae@4ax.com>,
	Bart Lateur <bart.lateur@skynet.be> writes:
> Clinton A. Pierce wrote:
>>Because it hurts my head.    Example:
>>Yuck.  This is why I always code:
> ...
>>To avoid this nonsense.
> 
> BS. That is precisely the *purpose* of being able to do that.

Oh agreed:  it's useful.  But if I'm going through all of the trouble to
declare strict and use lexicals then I'm going to make my scope painfully
obvious and straightforward.  It's simply a matter of style.  I'd rather
use:

	{
		my $foo;
		sub always_called_from_bar {
			print $foo;
		}
		sub bar {
			($foo)=@_;
			always_called_from_bar();
		}
	}

When this might be more appropriate:

	sub always_called_from_bar {
		print $foo;
	}
	sub bar {
		local ($foo)=@_;
		always_called_from_bar();
	}

Just because one is more obvious to me than the other.

-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org         Perl Developer's Dictionary -- May 2001
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: 21 May 2001 18:02:13 +0100
From: nobull@mail.com
Subject: Re: Why can't I localize a lexical variable?
Message-Id: <u94ruebppm.fsf@wcl-l.bham.ac.uk>

clintp@geeksalad.org (Clinton A. Pierce) writes:

> Oh agreed:  it's useful.  But if I'm going through all of the trouble to
> declare strict and use lexicals then I'm going to make my scope painfully
> obvious and straightforward.  It's simply a matter of style.  I'd rather
> use:
> 
> 	{
> 		my $foo;
> 		sub always_called_from_bar {
> 			print $foo;
> 		}
> 		sub bar {
> 			($foo)=@_;
> 			always_called_from_bar();
> 		}
> 	}

This is all well and good unless bar() should to be re-entrant.

For an example of where the inability to local()ise lexicals has
caused real trouble take a look at File::Find.  Find::Find used to
use local() then some well-meaning person changed all the package
variables to lexical and then to get rid of the errors simply removed
all the local()s without thinking why they were needed.  This, of
course, broke many scripts.  I've worked-round this bug in my scripts
AFAIK File::Find has not been fixed yet.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 21 May 2001 10:47:41 -0400
From: Henry Hartley <hartleh1@westat.com>
Subject: Re: xtropia - Web_store
Message-Id: <3B092A8D.9FF979ED@westat.com>

Banshee Smith wrote:
> 
> Hi,
> I was wondering if anyone was still using this Web_store from Selena
> Sol (www.extropia.com)?
> I am trying to make HTML templates for the pages and am just a little
> perplexed as to where to put the code. (And yes i am new to perl). As
> it will have to be hosted on an ISP web server I am quite limited to
> the languages I can use. (Perl and cgi are ok)
> Does anybody who reads this know of a current alternative for
> web_store?

Look into Interchange at <http://developer.akopia.com/>.

-- 
Henry Hartley


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.

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 V10 Issue 950
**************************************


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