[13363] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 773 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 13 00:07:35 1999

Date: Sun, 12 Sep 1999 21:05:09 -0700 (PDT)
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, 12 Sep 1999     Volume: 9 Number: 773

Today's topics:
        about dbmopen() <nononno@ms6.hinet.net>
    Re: baffle about flock() please help! (Martien Verbruggen)
    Re: bin2hex and back again (Chris Nandor)
    Re: division by zero <agray@infoscience.otago.ac.nz>
        How to make clean the text with screen control characte <tom89y@hanmail.net>
    Re: Idea for extracting name from city? (Eric Bohlman)
    Re: my and hashes; Bug of PERL? <cublai@earthlink.net>
        Need date/time validation on user input. <ricky_c_matlak@mail.northgrum.com>
    Re: Operating system problems? (elephant)
    Re: Perl - not Purify clean <mpersico@erols.com>
    Re: Perl's underlying implementation of Arrays - Low Pr <mpersico@erols.com>
    Re: Project: perl to ksh for sync logins <ultrak@my-deja.com>
        running Perl files on Apache 1.3 running under Windows  <barm@aarmstrong.fsbusiness.co.uk>
    Re: running Perl files on Apache 1.3 running under Wind <collin.starkweather@colorado.edu>
        Searching by date problem. <adtec@vic.bigpond.net.au>
    Re: Templates (Eric Bohlman)
    Re: UNCRAP project proposal (Chris Nandor)
        UseNet <flanker@sonnet.ru>
    Re: Where can I find a free website hosting supportting <me@toao.net>
        WHILE(1) {} <flanker@sonnet.ru>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 12 Sep 1999 19:01:01 GMT
From: "Handsome" <nononno@ms6.hinet.net>
Subject: about dbmopen()
Message-Id: <7rgt9d$rls$1@news.seed.net.tw>

Hi, anyone know,
If I use dnmopen(), I will get list.dbm.db file,
What's software  I can read list.dbm.db file ?

TKS...





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

Date: Mon, 13 Sep 1999 03:11:20 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: baffle about flock() please help!
Message-Id: <sXZC3.105$Nk1.8552@nsw.nnrp.telstra.net>

In article <_qMC3.8$I96.886@vic.nntp.telstra.net>,
	"Wyzelli" <wyzelli@yahoo.com> writes:
>> > sleep(3600);
>> > flock(FILE,LOCK_UN);
>> > close(FILE);
>>
>> And of course that's a waste of at least one line of code. There's very
>> little reason to ever explicitly unlock a file from Perl.
> 
> That's interesting and something I never caught from the docs... is it
> because the lock is released when the file is closed anyway?

Yes.

And, in fact, explicitly breaking the lock before closing (or at least
flushing) the file can be harmful. At least on some platforms.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.       | enough features yet.
NSW, Australia                      | 


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

Date: Mon, 13 Sep 1999 01:39:27 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: bin2hex and back again
Message-Id: <pudge-1209992139340001@192.168.0.77>

In article <s2BB3.127940$5r2.190165@tor-nn1.netcom.ca>, "Kevin Howe"
<khowe@performance-net.com> wrote:

# I would like to be able to store binary files such as .gif files in my
# databases.  I read that this could be done by converting the binary file to
# hexidecimal to store it in the database, and then converting it back
# (hexidecimal to binary) when the item is to be used.
# 
# I have found several scripts which convert from binary to hexidecimal
# (binhex.pl, Data::HexDump) but these do not to the conversion back to
# binary. On the perl site under http://www.perl.com/CPAN/scripts/index.html
# there are 2 scripts bin2hex and hex2bin which appear to solve the problem,
# but are meant to be used as command-line programs, and could not easily be
# hacked into something useful. I'd like to make a module which would make
# this simple, as follows:
# 
# $Convert = new BinHexConvert;
# $Convert->bin2hex(@lines);
# $Convert->hex2bin(@lines);
# 
# What exactly do you need to do to convert between the two?
# 
# Much thanks.

Just a wild suggestion, but the Convert::BinHex module might do what you
are looking for.  :)

    http://search.cpan.org/search?module=Convert::BinHex

In the future, you can just use http://search.cpan.org/ ... if you had
typed "binhex" in the main text box on the main page and hit return, you
would have found it.

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


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

Date: 13 Sep 1999 14:38:51 +1200
From: Andrew Gray <agray@infoscience.otago.ac.nz>
Subject: Re: division by zero
Message-Id: <ur9k3sfgk.fsf@infoscience.otago.ac.nz>

RAGGMOPP <raggmopp@ix.netcom.com> writes:
<SNIP>
> I have looked in the camel book, the Que book, and a SAMS 21 day book. I
> cannot find
> a procedure for avoiding or creating a statement to the zero division
> issue.
<SNIP>
>    $tot = $veg + $fruit;
>    $perveg = ($veg  /  $tot) * 100;
>    $perfru = ($fruit / $tot) * 100;

You have two main options as I see it.  Either use the eval statement
to provide some form of exception handling (see "perlfdoc -f eval" for
details), or you can check that $tot is not zero before calculating
the percentages and use an if/else block to handle the problem.  If
you think that you may be doing this a lot you can create a subroutine
to wrap the exception handling.

#!/usr/bin/perl -w
use strict;

my $veg=0;
my $fruit=0;

my $perveg;
my $perfru;

my $tot = $veg + $fruit;

# these will return an error and stop the program
# $perveg = ($veg  /  $tot) * 100;
# $perfru = ($fruit / $tot) * 100;

# this is clumsy, but works
if ($tot!=0) {
    $perveg = ($veg  /  $tot) * 100;
    $perfru = ($fruit / $tot) * 100;
}
else {
    print "Total is zero!  Cannot calculate percentages.\n";
}

# catch exceptions
eval {$perveg = ($veg  /  $tot) * 100;};
warn $@ if $@;

eval {$perveg = ($fruit  /  $tot) * 100;};
warn $@ if $@;

print "still alive...\n";

will produce

Total is zero!  Cannot calculate percentages.
Illegal division by zero at test.pl line 22.
Illegal division by zero at test.pl line 25.
still alive...

Cheers,
Andrew






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

Date: Mon, 13 Sep 1999 09:41:02 +0900
From: Yoon <tom89y@hanmail.net>
Subject: How to make clean the text with screen control characters.
Message-Id: <37DC481E.DC9C05C4@hanmail.net>

What is the best way of cleaning the messy text with screen control
characters ? I suppose the screen control characters are curses based.

Thanks in advance.







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

Date: 13 Sep 1999 03:32:18 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Idea for extracting name from city?
Message-Id: <7rhr82$49r@dfw-ixnews12.ix.netcom.com>

Kevin Reed (kevin@zippy.tnet.com) wrote:
: Below are some sample records to show the problem that I am having:
: 
: Mrs. Joyce Aab Pittsford, NY
: Mrs. Melissa Aab Pittsford, NY
: Mr. Elmer Aamodt Grand Prairie, TX

There's no algorithmic way of separating the name and city in this 
example.  There are some heuristics, but they require information outside 
of the records themselves.  If you know that there's a city called Grand 
Prairie, TX, but *not* one called Prairie, TX, or vice versa, you can 
disambiguate it.  But if you have no information about Texas cities, or 
if there's *both* a Grand Prairie and a Prairie, then this one is 
impossible to disambiguate.


: Mr. C. Chester Abell Columbus, OH
: Mr. Charles Abercrombe Amarillo, TX
: Mr. Denis Abercrombie The Woodlands, TX

A reasonably safe heuristic is that words like 'the' don't occur in 
people's names but do occur in place names.

: Dr. Gary Abercrombie Plainview, TX
: LTC Ralph Aguirre Glendale, AZ
: Mr. Vikoslav Aguirre Greenwood Village, CO
: Mr. C. Willis Adams III Indianapolis, IN

It's also reasonably safe to assume that Roman numeral are far more 
likely to occur in people's names than in place names.

: COL Samuel Adams Jr. Alexandria, VA
: Mr. Frederick Addison III Dallas, TX

: The real data has every record in alphabetical order by last name.
: So the following record would always have a last name that is
: equal in value or greater.

This can form part of your heuristic; if a word in your current record is 
lexically less than the validated last name from your previous record, it 
can't represent the first word of the current record's last name.  
Unfortunately the converse isn't true.

I'd approach the problem using state-machine techniques, but working 
*backwards* from the end of the strings.  But once again, the most you 
can come up with are heuristics.



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

Date: Sun, 12 Sep 1999 17:44:19 -0600
From: "Zach Thompson" <cublai@earthlink.net>
Subject: Re: my and hashes; Bug of PERL?
Message-Id: <7rhdtp$h73$1@birch.prod.itd.earthlink.net>

I believe this is happening because you are using a symbolic reference with
%{$hash_name} which needs to access the symbol table.  Lexical variables are
not stored in the symbol table.


Bernd Kronmueller <Bernd.Kronmueller@eedn.ericsson.se> wrote in message
news:37D7AC6A.1E13EAAA@eedn.ericsson.se...
> Hello,
>
> we encountered here a problem and we can't explain what is going on.
>
> #! /usr/loacal/bin/perl -w
>
> my $name = "hash";
> my $hash_name = "$name\_1";
>
> my %hash_1 = ('asd', 1 , 'erg', 2);
>
> print "\tdirect:\n";
> foreach $key (keys %hash_1)
> {
>   print "key: $key value: ", $hash_1{$key}, "\n";
> }
>
> print "\n\thash name put together: \n";
> foreach $key (keys %{$hash_name})
> {
>   print "key: $key value: ", ${$hash_name}{$key}, "\n";
> }
>
> The problem is, that in the case where the name is put together it won't
> find the hash.
> Simply removing the my from the hash declaration solves the problem.
>
> Who can explain this to me or is it a bug of perl???
>
> Thanks, Bernd
>





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

Date: Mon, 13 Sep 1999 03:39:35 GMT
From: "Ricky C. Matlak" <ricky_c_matlak@mail.northgrum.com>
Subject: Need date/time validation on user input.
Message-Id: <37DC71F7.4BAD3E01@mail.northgrum.com>

I have a user entering dates and times, and I must worry about bogus
entries (i.e. Feb 30th, or say month 99/01/1999), and could use
something to validate the entries.  Need to account for leap years,
etc...

I realize I could use regular expressions, but am not well versed, and
thought maybe something could handle this already.

I tried using Time::Local timelocal routine, which gives me epoch
seconds.  Seems fine, but it will take bad dates (i.e. 02/45/1999) and
returns a number without an error.

Help,
Any suggestions?


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

Date: Mon, 13 Sep 1999 10:38:44 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Operating system problems?
Message-Id: <MPG.1246d68012f5d993989cc1@news-server>

Peter Wilford writes ..
>My question is, is it because I am using Win'98 that I get a load
>module failurein the NetResource module?  The error seems to be
>indicating a problem with the 'Hardware Access Layer' (HAL) on the Win
>NT platform...  Could this be true?  Has anyone else had the same
>problem?  Any help would be appreciated...

I can't say what's happening here because I don't know that module .. 
but I can confirm that I get the same error when trying to use 
Win32::NetResource on Win98 .. and I get no such error when using it on 
WinNT

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sun, 12 Sep 1999 23:02:07 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Perl - not Purify clean
Message-Id: <37DC692F.9992358B@erols.com>

Nathan Torkington wrote:
> 
> Frazer Worley <fworley@dal.asp.ti.com> writes:
> > Perl is in a pretty sorry state of affairs if it contains these
> > type of errors - and in large quantities. And - note I only called
> > perl_parse with NULL arguments .... heaven knows how much junk I'd
> > be exposed to if I called the function with real arguments.
> 
> As was pointed out to this idiot on the perl5-porters mailing list, he
> didn't read *all* the perlembed documentation, where it talks about
> how to build Perl with Purify support.
> 
> He doesn't know whereof he speaks.  Ignore him.
> 
> Nat

From this, can we assume that:

1) His errors were because he didn't RTFM on building Perl and Purify.
2) If you RTFM and do it right, Perl is bascially clean?

Just curious.
-- 
Matthew O. Persico
    
You'll have to pry my Emacs from my cold dead oversized
   control-pressing left pinky finger. -- Randal L. Schwartz


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

Date: Sun, 12 Sep 1999 23:33:09 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Perl's underlying implementation of Arrays - Low Priority
Message-Id: <37DC7075.6A5A3043@erols.com>

Nick Read wrote:
> 
> > I haven't personally used linked lists in 'C' since my first programming
> > job.
> 
> Ah, but are you sure you haven't used them without noticing!!!  For example,
> Trees
> 
I'm sure. Most of my experience is for financial institutions crunching
rows of RDBMS data - no links required. Just grab a bunch of contiguous
bits, set 'em, slice 'em, dice 'em and drop 'em into the great big
bit-bucket in the sky.

-- 
Matthew O. Persico


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

Date: Mon, 13 Sep 1999 03:27:15 GMT
From: Kermit Lowry, III <ultrak@my-deja.com>
Subject: Re: Project: perl to ksh for sync logins
Message-Id: <7rhqu9$rcf$1@nnrp1.deja.com>

I have received so much crap from my posts on the shell and
database.sybase forums that I wanted to save those here the trouble.
This is just a need I have that I thought someone else, who couldn't
run perl on their Unix system because of business considerations beyond
their control, might want to help with.
If you think this is a stupid idea, please don't respond.
If someone out there wants to give me a ray of hope in humanity, please
contact me.


Kermit Lowry, III
klowry@DELETEfhlbatl.com


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


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

Date: Mon, 13 Sep 1999 02:32:40 +0100
From: "Andrew Armstrong" <barm@aarmstrong.fsbusiness.co.uk>
Subject: running Perl files on Apache 1.3 running under Windows 95 ?
Message-Id: <7rhk9f$6u1$1@news8.svr.pol.co.uk>

Does anyone know why Ikeep getting a Forbidden message when trying to run my
Perl programs ? I am running Apache 1.3 under windows 95 and have Perl 5.005
installed. I think it may be to do with the httpd.conf file but cannot find
anything in there that sets restrictions on certain files.

Any clues

Thanks




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

Date: Sun, 12 Sep 1999 21:47:43 -0600
From: Collin Starkweather <collin.starkweather@colorado.edu>
To: Andrew Armstrong <barm@aarmstrong.fsbusiness.co.uk>
Subject: Re: running Perl files on Apache 1.3 running under Windows 95 ?
Message-Id: <37DC73DF.BF6881C2@colorado.edu>

I seem to recall that even on Windows machines, Apache looks for the
shebang.

So make sure you have something like

#!C:\Perl\bin\perl.exe

at the top of your script.

Hope this helps!

-Collin

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Collin Starkweather                                 (303) 492-4784
University of Colorado            collin.starkweather@colorado.edu
Department of Economics          http://ucsu.colorado.edu/~olsonco
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Andrew Armstrong wrote:
> 
> Does anyone know why Ikeep getting a Forbidden message when trying to run my
> Perl programs ? I am running Apache 1.3 under windows 95 and have Perl 5.005
> installed. I think it may be to do with the httpd.conf file but cannot find
> anything in there that sets restrictions on certain files.
> 
> Any clues
> 
> Thanks


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

Date: Mon, 13 Sep 1999 12:49:16 +1000
From: "Adtec" <adtec@vic.bigpond.net.au>
Subject: Searching by date problem.
Message-Id: <7rhpa7$ipm$1@m2.c2.telstra-mm.net.au>

newbie here.

I'm asking the user to enter a date at the prompt, (dd/mm/yy)
Search a text file for the respective date.
And print each line beyond that date (until eof)  to a new file.

I'm finding it difficult to print beyond a certain date when the actual date
to search for
may not exist within the source file. ie; a search date could point to a
Sunday for example, and no work was
conducted on a Sunday.

I'm thinking of splitting up the date entered, into three seperated strings
(day, month and year) and search each string individually using a
comparitive if statement. ie IF day < day, IF month < month etc..

surely there must be a library or command(s) of some sort that can do this
for me......?




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

Date: 13 Sep 1999 03:19:13 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Templates
Message-Id: <7rhqfh$49r@dfw-ixnews12.ix.netcom.com>

Marc (marc@infinityinternet.com) wrote:
: I'm having problems with my template subroutine I created. It doesn't parse
: anything.
: 
: ##########
: sub template
: {
:   my($begin_tag) = '<?';
:   my($end_tag) = '?>';

Both $begin_tag and $end_tag contain question marks, which have special 
meanings in regular expressions.  When you subsequently interpolate them 
into your regex, they're given their special meaning rather than treated 
as literals.  Therefore you have to arrange for them to be backwhacked 
when they get interpolated, which means putting a literal backslash into 
their string values:

  my ($begin_tag) = '<\\?';
  my ($end_tag) = '\\?>';

:   $fillings{var} = "test";
:   my $text = "testing\n<?if v3ar?>\n123\n<?endif?>\nreghtml";
:   $text =~ s{ $begin_tag\s*if\s*(.+)?\s*$end_tag/s*(.+)/s*
:     $begin\s*endif\s*$end }
:   {
: 
:                    exists $fillings->{$1} ?
:                      "$2" :
:                       "" ;
:                  }gsi;
:   return $text;
: }


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

Date: Mon, 13 Sep 1999 01:33:50 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: UNCRAP project proposal
Message-Id: <pudge-1209992133570001@192.168.0.77>

In article <m33dwkrqd9.fsf@biff.bitsko.slc.ut.us>, Ken MacLeod
<ken@bitsko.slc.ut.us> wrote:

# "Alan J. Flavell" <flavell@mail.cern.ch> writes:
# 
# > but still the original assertion remains
# > untouched.
# 
# My apologies, Alan.
# 
# Maybe you'd like to take a crack at explaining why requiring closing
# tags in a version of HTML suddenly makes that version no longer HTML
# when the HTML specifications and existing parsers both allow them and
# assume that they are there if they are missing?

If this "version" of HTML were codified and approved by W3C, then it would
be HTML.  If it isn't, then ... it isn't HTML.  Only HTML is HTML.  If
something requires or allows something that HTML does not, then it is not
HTML.  This isn't hard.  :)

No one said adding the closing tag makes it not HTML.  Requiring it makes
it not HTML (for now, anyway).

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


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

Date: Mon, 13 Sep 1999 02:44:23 +0400
From: "Michael Yevdokimov" <flanker@sonnet.ru>
Subject: UseNet
Message-Id: <7rhaj0$19m$1@ghost.rosmail.com>

How to read UseNet on the Web? Does anyone knows the url from where I could
download a Perl script for this subject?

--
Best wishes,


Michael Yevdokimov

Email: flanker@sonnet.ru
ICQ: 40272699
-----------------------------------------------
Aerospace Center Ltd.
Krasnoarmeiskaya Str.,4
Moscow, 125167
RUSSIA

Tel.: +7 095 212 0278
Fax: +7 095 212 7301

Web: http://www.polygon.org.ru
E-mail: info@polygon.org.ru





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

Date: Mon, 13 Sep 1999 01:12:23 GMT
From: Graham W. Boyes <me@toao.net>
Subject: Re: Where can I find a free website hosting supportting perl?
Message-Id: <7rhj1f$m32$1@nnrp1.deja.com>

Could just go to Yahoo and search for "free website cgi" or something...

Or Hypermart is the best that I've found.  Very quick.
http://www.hypermart.net

-Graham W. Boyes

--
"The One and Only"
me AT toao DOT net ~ http://www.toao.net


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


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

Date: Mon, 13 Sep 1999 02:40:53 +0400
From: "Michael Yevdokimov" <flanker@sonnet.ru>
Subject: WHILE(1) {}
Message-Id: <7rhace$13f$1@ghost.rosmail.com>

Hey

How to run a Perl script from a Web browser so it will be working
independently from me? I have a script which can do a work of a "spy" for
the files in directory.. Well, I ran it from a Web browser. But when I
closed it, the script also finished it work. So, how to run it so it will be
working indefinitely?

--
Best wishes,


Michael Yevdokimov

Email: flanker@sonnet.ru
ICQ: 40272699
-----------------------------------------------
Aerospace Center Ltd.
Krasnoarmeiskaya Str.,4
Moscow, 125167
RUSSIA

Tel.: +7 095 212 0278
Fax: +7 095 212 7301

Web: http://www.polygon.org.ru
E-mail: info@polygon.org.ru





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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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 V9 Issue 773
*************************************


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