[15979] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3391 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 16 14:05:52 2000

Date: Fri, 16 Jun 2000 11:05: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: <961178727-v9-i3391@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 16 Jun 2000     Volume: 9 Number: 3391

Today's topics:
    Re: [REGEXP] Matching list of comma-separated ID's (Abigail)
    Re: [REGEXP] Matching list of comma-separated ID's <bochmann-usenet0600@gmx.net>
    Re: A Computer Programmers Profile (David H. Adler)
    Re: A Computer Programmers Profile <cmcurtin@interhack.net>
    Re: A Computer Programmers Profile <lr@hpl.hp.com>
    Re: A Computer Programmers Profile <care227@attglobal.net>
    Re: A question from Dynamic Whistler <dparrott@ford.com>
        Activeperl 5.6 wrong ascii in Windows98 michaeljgardner@my-deja.com
    Re: Activeperl 5.6 wrong ascii in Windows98 <rootbeer@redcat.com>
    Re: Activeperl 5.6 wrong ascii in Windows98 <blah@nospam.com>
    Re: Activeperl 5.6 wrong ascii in Windows98 (Michel Dalle)
        Archives of c.l.p.m posts [was: "Fuzzy" matching] <iltzu@sci.invalid>
    Re: binding a string variable to call a stored proc ? newsposter@cthulhu.demon.nl
    Re: Bot for this group to auto-answer queries? <jbroz@transarc.com>
    Re: Bot for this group to auto-answer queries? (Abigail)
    Re: Bot for this group to auto-answer queries? (David H. Adler)
    Re: Bot for this group to auto-answer queries? (John Stanley)
    Re: Bot for this group to auto-answer queries? (John Stanley)
    Re: bug with arrays? (Joe Petolino)
    Re: concerned about flock() <lr@hpl.hp.com>
    Re: Crazy enough that it might just work... (John Stanley)
        creating and opening a file <twood@csd.uwm.edu>
    Re: creating and opening a file <W.Hielscher@mssys.com>
    Re: creating and opening a file <abe@ztreet.demon.nl>
    Re: creating and opening a file (Abigail)
    Re: creating and opening a file <billy@arnis-bsl.com>
    Re: creating and opening a file <tina@streetmail.com>
    Re: creating and opening a file (Jerome O'Neil)
        dbm's and associative arrays (Robin Senior)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 16 Jun 2000 11:58:05 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: [REGEXP] Matching list of comma-separated ID's
Message-Id: <slrn8kkkml.kp1.abigail@alexandra.delanet.com>

Henryk Bochmann (bochmann-usenet0600@gmx.net) wrote on MMCDLXXXI
September MCMXCIII in <URL:news:8idd2g$4ie05$1@fu-berlin.de>:
?? Rafael Garcia-Suarez <garcia_suarez@hotmail.com> wrote:
?? >>I need users to input a string which will consist of one or more part
?? >>ID's with two decimal digits (eg. 1.03 or 2.01 or 12.03). The first
?? >>number stands for the type of the part, the two latter digits for its
?? >>version. Users are supposed to separate the numbers by comma+space. The
?? >>final string should look like '1.03' or '2.01, 12.02, 3.03, 8.04',
?? >>depending on the number of parts required and should not contain a
?? >>final comma, but may contain a final space.
?? >>
?? >>Can anybody help me with a regex that would test for the correct input?
?? 
?? > This regexp will verify that $string matches your specification:
?? >   $string =~ /\d+\.\d\d(, \d+\.\d\d)* ?/
?? > but it won't extract any useful information from it.
?? > Look also at the split function to extract the fields from your
?? > input string.
?? 
?? Rafael,
?? 
?? I tried the following:
?? 
?? #! /usr/bin/perl
?? 
?? @tests = ('1.03', 
??           '1.03, 2.04', 
??           '2.03 3.04',
??           '3.03  3.04',
??           '3.03,3.04',
??           '3.03, 3.04, 4.04 ',
??           '3.03 3.04 4.04');
?? 
?? foreach $field (@tests) {
?? 	if ($field =~ /\d+\.\d\d(, \d+\.\d\d)* ?/) {
??         	print "-$field- is OK.\n";
??     	} else {
??         	print "-$field- is FALSE.\n";
?? 	}
?? }
?? 
?? It seems to come out OK for all tests, while it should only allow
?? '1.03, 2.04' and '3.03, 3.04, 4.04 '.

No, it doesn't. Look at the regex, all it needs to match is \d+\.\d\d. The
",  \d+\.\d\d" can match 0 times, and so can the space at the end. And
since each test contains a substring of a digit followed by a period
and two digits, you get OK all the time.

First thing you have to do is to anchor the regex, so it will match the
end and beginning of the string:

    /^\d+\.\d\d(, \d+\.\d\d)* ?$/

(use \z instead of $ if a trailing new line is not ok).

You also might have to chance the * into a +, but I cannot figure out what
you want. In your original message, you want to allow "1.03", but in 
your latter post, you say it shouldn't. Use * if "1.03" is ok, and + if
it isn't.



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: 16 Jun 2000 17:11:19 GMT
From: Henryk Bochmann <bochmann-usenet0600@gmx.net>
Subject: Re: [REGEXP] Matching list of comma-separated ID's
Message-Id: <8idn3n$4j4ub$1@fu-berlin.de>

Abigail <abigail@delanet.com> wrote:
>     /^\d+\.\d\d(, \d+\.\d\d)* ?$/

> (use \z instead of $ if a trailing new line is not ok).

> You also might have to chance the * into a +, but I cannot figure out what
> you want. In your original message, you want to allow "1.03", but in 
> your latter post, you say it shouldn't. Use * if "1.03" is ok, and + if
> it isn't.


Abigail,

thanks, this one works :) And, yes, I meant it to catch '1.03', too. My
mistake.

Regards,
Henryk

-- 
Henryk Bochmann, M.D. | bochmann@rcs.urz.tu-dresden.de
                      | University Clinic @ Technical University Dresden
Tel: +49 351 458-4813 | Institute of Clin.Chemistry & Laboratory Medicine
Fax: +49 351 458-4332 | 01307 Dresden, Fetscherstr. 74, Germany


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

Date: 16 Jun 2000 15:40:43 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: A Computer Programmers Profile
Message-Id: <slrn8kkijr.s5k.dha@panix6.panix.com>

On Wed, 14 Jun 2000 15:13:55 -0700, Employer
<jenniferbNOjeSPAM@oreilly.com.invalid> wrote:

>I am looking for this information in the interest to be able to find
>computer programmers for employment when I need them. They have been
>hard to find (the good ones anyway), and I am trying to find them!!

*sigh* If the organizational affiliation indicated by your email
address is indeed correct, one would have hoped you'd know better than
this...  Oh well, here we go:

You have posted a job posting or a resume in a technical group.

Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.

Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :)

Please do not explain your posting by saying "but I saw other job
postings here".  Just because one person jumps off a bridge, doesn't
mean everyone does.  Those postings are also in error, and I've
probably already notified them as well.

If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.

There is a Perl Jobs Announce list that may be more helpful to you.  See
<http://www.pm.org/mailing_lists.shtml> for details.

Yours for a better usenet,

dha


-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"i don't play lead.  it interferes with my drinking." - Malcolm Young


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

Date: 16 Jun 2000 12:10:37 -0400
From: Matt Curtin <cmcurtin@interhack.net>
Subject: Re: A Computer Programmers Profile
Message-Id: <xlxitv9ip36.fsf@gold.cis.ohio-state.edu>

>>>>> "Abigail" == Abigail  <abigail@delanet.com> writes:

  Abigail> Usenet, MUDs, IRC.

Oh my!

-- 
Matt Curtin cmcurtin@interhack.net http://www.interhack.net/people/cmcurtin/


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

Date: Fri, 16 Jun 2000 09:48:51 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: A Computer Programmers Profile
Message-Id: <MPG.13b3fa4a43a22d8e98ab8b@nntp.hpl.hp.com>

In article <394A3157.E1E55B9B@attglobal.net> on Fri, 16 Jun 2000 
09:53:27 -0400, Drew Simonis <care227@attglobal.net> says...
> Ferk Da Jerk wrote:
> > 
> > I'd like to see you try to kill the children.  It seems these days the
> > children are out numbering the adults, the killers are the children, and the
> > children are more stronger than the adults.
>                ^^^^^^^^^^^^^ 
> 
> And oh the grammer!

Is that Kelsey Grammer or English grammar?

Sorry about a spell flame, but you chose to flame about Da Jerk's 
grammer^H^Har.  :-)

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


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

Date: Fri, 16 Jun 2000 13:08:37 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: A Computer Programmers Profile
Message-Id: <394A5F15.B6C02413@attglobal.net>

Larry Rosler wrote:
> 
> > And oh the grammer!
> 
> Is that Kelsey Grammer or English grammar?
> 
> Sorry about a spell flame, but you chose to flame about Da Jerk's
> grammer^H^Har.  :-)
> 

I guess the old addage is still true...  every good grammar flame 
deserves a spelling flame...  *shrug*, I've always been a bad speller.


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

Date: Fri, 16 Jun 2000 11:25:11 -0400
From: "Dennis M. Parrott" <dparrott@ford.com>
Subject: Re: A question from Dynamic Whistler
Message-Id: <394A46D7.F7E9C0B5@ford.com>

Maybe you should apologize for publicizing a site that causes your 
web browser to have conniption fits and page fault!

Don't surf this site with NS Communicator 4 -- it causes you to
Blow Up Real Good (tm) and it will take your newsreader with it
when it goes...

Man, I HATE sites that do stuff like this!!  ARRGHGGH!!!!^4

bzooty@my-deja.com wrote:
> 
> Couldn't find the section of the FAQ that tells how to humbly apologize
> for ignorant mistakes. Sincerely sorry for the eye strain. Cheers.
> 
> Jerry Stogsdill
> Dynamic Whistler
> http://whistler.bccmedia.com
> 
> In article <8fhrr0$be4$1@orpheus.gellyfish.com>,
>   Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> > On Fri, 12 May 2000 01:18:13 GMT bzooty@my-deja.com wrote:
> > > Hey. Dynamic Whistler is an information site about DHTML. We're a
> month
> > > old and are starting to really get focused on content. We're
> thinking
> > > about including PERL resources as well. Our question is:
> > >
> > > What would be the most important resource that an PERL developer
> would
> > > hope to find on our site?
> > >
> >
> > Probably a pointer to the Perl FAQ wherein it is described how to
> spell
> > the name of the language for starters.
> >
> > /J\
> > --
> > I'm a white male, age 18 to 49. Everyone listens to me, no matter how
> > dumb my suggestions are.
> > --
> > fortune oscar homer
> >
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.


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

Date: Fri, 16 Jun 2000 15:08:27 GMT
From: michaeljgardner@my-deja.com
Subject: Activeperl 5.6 wrong ascii in Windows98
Message-Id: <8idfsr$psg$1@nnrp1.deja.com>

Using the chr() function with a value of 10 returns a carriage return
character instead of the proper ascii character.  Any ideas on how to
get windows, or Perl, to return the proper value.

Thanks,
Michael


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 16 Jun 2000 08:26:09 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Activeperl 5.6 wrong ascii in Windows98
Message-Id: <Pine.GSO.4.10.10006160824570.21108-100000@user2.teleport.com>

On Fri, 16 Jun 2000 michaeljgardner@my-deja.com wrote:

> Using the chr() function with a value of 10 returns a carriage return
> character instead of the proper ascii character.  Any ideas on how to
> get windows, or Perl, to return the proper value.

File a bug report via perlbug, then use the next version when it's fixed.

If you can compile from the source, there may be another option, of
course. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 16 Jun 2000 17:34:48 +0200
From: Marco Natoni <blah@nospam.com>
Subject: Re: Activeperl 5.6 wrong ascii in Windows98
Message-Id: <394A4918.2399501B@nospam.com>

Michael,

michaeljgardner@my-deja.com wrote:
> Using the chr() function with a value of 10 returns a carriage 
> return character instead of the proper ascii character.  Any ideas 
> on how to get windows, or Perl, to return the proper value.

  Ehm... and what should be the proper ASCII character with code 10?


	Best regards,
		Marco


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

Date: Fri, 16 Jun 2000 16:13:55 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Activeperl 5.6 wrong ascii in Windows98
Message-Id: <8idjse$nlu$2@news.mch.sbs.de>

In article <394A4918.2399501B@nospam.com>, mnatoni@rumbanet.it wrote:
>Michael,
>
>michaeljgardner@my-deja.com wrote:
>> Using the chr() function with a value of 10 returns a carriage 
>> return character instead of the proper ascii character.  Any ideas 
>> on how to get windows, or Perl, to return the proper value.
>
>  Ehm... and what should be the proper ASCII character with code 10?

linefeed :)

Michel.


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

Date: 16 Jun 2000 15:36:24 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Archives of c.l.p.m posts [was: "Fuzzy" matching]
Message-Id: <961168567.28914@itz.pp.sci.fi>

In article <8ida2b$ldh$1@plutonium.compulink.co.uk>, Guy Fraser wrote:
>Is this group archived anywhere as I don't have your earlier posts in my
>message base :o(

Normally I use http://www.deja.com/ with Jeremy Nixon's alternative
search interface http://www.exit109.com/~jeremy/news/deja.html .

However, Deja appears to be still having database problems, causing
many messages not to be found.  The only other site I know of that
offers a similar facility is http://www.remarq.com/ .  I don't like
their user interface very much, but until Deja gets its act together
I'd recommend using Remarq instead.


Regarding the original topic, entering "algorithm +diff +perl" into
the search form there, and selecting "Search for Messages" from the
drop-down menu, produced a rather through list, including all the
messages I had been referring to as well as this important one:

  http://www.remarq.com/read/perlmodu/q_PFvsr2b63cAAAAA

Quoted below is the relevant section of said post by Ned Konz:

: I've uploaded a completely re-written version (1.06) to CPAN, where it
: resides under the authors/id/N/NE/NEDKONZ/ directory (along with
: my Archive::Zip module). So, for instance, you can get it from the
: http://www.cpan.org/modules/by-authors/id/N/NE/NEDKONZ/ directory.
: The new version runs much faster and with much less memory consumption
: when comparing large arrays/files. 
:
: The module index on CPAN has not yet been changed to reflect my
: ownership of the module, so use the above link. 

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: 16 Jun 2000 17:00:51 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: binding a string variable to call a stored proc ?
Message-Id: <8idmg3$jo5$1@internal-news.uu.net>

Andy <andywright28NOanSPAM@hotmail.com.invalid> wrote:

> I'm trying to call a stored procedure and pass it a string
> variable (with spaces) :

> ---SNIP---
> my $my_str_val = "val_a or val_b";
> $sth = $dbh->prepare(q{
>   BEGIN OPEN :cursor FOR
>     SELECT * from tbl_my_table where first_val = :str_first_val;
>   END;
> });
> $sth->bind_param(":str_first_val", $my_string_val, {ora_type =>
> ORA_VARCHAR2});

> ---SNIP---

> The problem seems to be the binding of the string
> $my_string_val. If its set to "val_a" it returns ok, but when
> there seems to be spaces in the string, it returns nothing. What
> am I doing wrong ?!?!??!

  I don't see you calling a stored procedure. You're trying to open
a cursor, but I might be nitpicking too much, or even be wrong.

  You can't use placeholders to build SQL statements dynamically.
You can do something like:

   'SELECT * FROM table WHERE column1 = :val'

This can be compiled and have a value be added in later, but

   'SELECT * FROM table WHERE column1 = :val'

and then modifying the statement by adding an 'or' is not possible.

  You might want to look into using an actual stored procedure and
have the procedure build your SQL statement dynamically and open
and return a cursor.

Erik



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

Date: Fri, 16 Jun 2000 16:22:17 +0100
From: "Joe_Broz@transarc.com" <jbroz@transarc.com>
Subject: Re: Bot for this group to auto-answer queries?
Message-Id: <394A4629.5FF584EC@transarc.com>

John Stanley wrote:
> 
> In article <961044460.18283@itz.pp.sci.fi>,
> Ilmari Karonen  <usenet11123@itz.pp.sci.fi> wrote:
> >Specifically, it should store a list of every e-mail address it has
> >ever replied to, and only reply to those that are new to it.  There
> >should also be a header ("X-No-Autoreply"?) which could be included in
> >a post to prevent the bot from replying to it.  Both of these features
> 
> No. Getting crap from a robot must be opt-in, not opt-out.

Or just kill all posts from it. Should be relatively easy with a good
newsreader.


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

Date: 16 Jun 2000 11:45:31 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Bot for this group to auto-answer queries?
Message-Id: <slrn8kkjv3.kp1.abigail@alexandra.delanet.com>

Joe_Broz@transarc.com (jbroz@transarc.com) wrote on MMCDLXXXI September
MCMXCIII in <URL:news:394A4629.5FF584EC@transarc.com>:
,, John Stanley wrote:
,, > 
,, > In article <961044460.18283@itz.pp.sci.fi>,
,, > Ilmari Karonen  <usenet11123@itz.pp.sci.fi> wrote:
,, > >Specifically, it should store a list of every e-mail address it has
,, > >ever replied to, and only reply to those that are new to it.  There
,, > >should also be a header ("X-No-Autoreply"?) which could be included in
,, > >a post to prevent the bot from replying to it.  Both of these features
,, > 
,, > No. Getting crap from a robot must be opt-in, not opt-out.
,, 
,, Or just kill all posts from it. Should be relatively easy with a good
,, newsreader.


That's still opt-out.


Abigail
-- 
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
          for (s;s;s;s;s;s;s;s;s;s;s;s)
              {s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'


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

Date: 16 Jun 2000 17:46:02 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Bot for this group to auto-answer queries?
Message-Id: <slrn8kkpuq.s5k.dha@panix6.panix.com>

On Fri, 16 Jun 2000 09:33:05 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:

>My confidence in Tom Phoenix' judgement on poor subject lines in far
>higher than in the judgement of a bot. Say that the bot complains
>wrongly about a poor subject line, twice a week. Wouldn't it soon become
>a source of anger? "That dumb bot..."?

 ...which would then become a common subject line, causing the bot to
fire off more corrections....  :-)

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
The Teletubbies are coming to America.
They must be stopped!


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

Date: 16 Jun 2000 17:54:19 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Bot for this group to auto-answer queries?
Message-Id: <8idpkb$eq$1@news.NERO.NET>

In article <394A4629.5FF584EC@transarc.com>,
Joe_Broz@transarc.com <jbroz@transarc.com> wrote:
>> No. Getting crap from a robot must be opt-in, not opt-out.
>
>Or just kill all posts from it. Should be relatively easy with a good
>newsreader.

It should not be necessary to run a mail filter to keep from getting
harrasing email in response to news postings. The bot should not be
sending it in the first place. 



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

Date: 16 Jun 2000 18:01:00 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Bot for this group to auto-answer queries?
Message-Id: <8idq0s$kc$1@news.NERO.NET>

In article <394983AB.92AF1145@jpl.nasa.gov>,
Jon Ericson  <Jonathan.L.Ericson@jpl.nasa.gov> wrote:
>Ugh!  (But if the error message was sent to the right place and worded
>correctly, the world would be a better place, right?)

The poster is not the right place. 

>> not a good idea. Automated email in response to postings in a discussion
>> group are not a good idea.
>
>My thought was that all reponses would be posts in c.l.p.m, not email,

Which is even worse. Bots posting in response to articles they see
posted is recipe for disaster. ARMM, anyone?

>but re-reading what I said, I see how I was mis-interpreted.  Except for
>the word harass, I don't know why you think it's a bad idea, however. 

Except for the sky being blue, I like the color of the sky. Is "harass"
not sufficient reason for it to be a bad idea?

>What difference does it make if it's Tom Phoenix or a perl program that
>responds to poor subject lines with a standard message?  

It doesn't make any difference. Both are wrong. If you don't like the
subject, don't read the article. That's what the subject is for, to help
you make that determination. The fact that nobody can convince Tom
Phoenix to stop doing it doesn't make it right, or a good use of
resources.

Unless you grant me the right to start a bot to complain about what I
want to complain about automatically, don't start talking about how you
want to start one to complain about your pet peeves.



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

Date: 16 Jun 2000 17:14:28 GMT
From: petolino@Eng.Sun.COM (Joe Petolino)
Subject: Re: bug with arrays?
Message-Id: <8idn9k$38n$1@engnews3.Eng.Sun.COM>

petolino@Eng.Sun.COM (Joe Petolino) said:
>> I second Lauren's suggestion to use qw, but I'd keep the
>> original feature of padding with a null first element to
>> make the indexes work out nicer.  Maybe something like
>> this:
>>
>>    my @month = qw(jan feb mar apr may jun jul aug sep oct nov dec);
>>    unshift @month, '';       # So that $month[1] == 'jan', etc.

Tony Curtis  <tony_curtis32@yahoo.com> wrote:
>Fiddling about with data structures and adding meaningless
>fields isn't, IMHO, a good idea.  Data which represent a
>real-world "thing" should echo the real-world exactly if
>at all possible.  It's up to the code to make the
>translation.  I find this to be an especially valuable
>tack to take when the real-world data come from something
>not under your control, e.g. down a pipe or from a config
>file.  I'd possibly make an exception for severe
>space-time tradeoffs but I don't have any experience of
>such a tradeoff being necessary.

You have a point, but IMHO a weak one in this case.  The array is being
used as a translation table from numerical month specifiers to month
names.  In this application, making the array index different from the
corresponding month number has a lot more potential for confusion than
having 13 elements in the array.  I say this from the perspective of a
hardware designer who has had to deal with brain-damaged CAD systems which
require you to number the bits of every bus starting with zero, even when
they're just copies of higher-order bits of some other bus.

Luckily in Perl TMTOWTDI, and the most natural way to do name translations
is with a hash.  Here's a solution that should make us all happy:

    @month_name{1..12} = qw(jan feb mar apr may jun jul aug sep oct nov dec);

>You can tell perl to use 1 as the base array index
>(perldoc perlvar)   .  .  .

The perldoc entry for $[ says "Its use is discouraged."  And for good
reason, since it's a global mode setting which affects *every* array in
your program, not just @month.  It also affects index() and substr().

-Joe

-- 
Joe Petolino                                 petolino@eng.sun.com


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

Date: Fri, 16 Jun 2000 10:03:12 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: concerned about flock()
Message-Id: <MPG.13b3fdaf72de4beb98ab8c@nntp.hpl.hp.com>

In article <3949ABD1.3423@modulus.com.au> on Fri, 16 Jun 2000 14:23:45 
+1000, Peter Hill <phill@modulus.com.au> says...
> Clinton A. Pierce wrote:

 ...

> > I've used flock() on a variety of Unix and Windows systems.  Where
> > it works (Unix with local filesystems, NT with local filesystems) it
> > works OK.  Where it's not supported (Win9x) it's not needed.  Where it
> 
> Win9x is a single-user multi-tasking OS - the lack of flock on Win9x is
> unfortunate, as it is needed where multiple tasks might conflict.

But on Win9x one task cannot open a file that is already opened by 
another task, so there can be no conflict, so no need for file locking.  
In essence, the operating system imposes mandatory locking.

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


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

Date: 16 Jun 2000 17:52:53 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Crazy enough that it might just work...
Message-Id: <8idphl$e9$1@news.NERO.NET>

In article <henry-8269F0.09564916062000@news.metropolis.net.au>,
Henry  <henry@penninkilampi.net> wrote:
>In article <8ibp7k$dgt$1@news.NERO.NET>, stanley@skyking.OCE.ORST.EDU 
>(John Stanley) wrote:
>
>>> We could, for example, reject the first post attempt _outright_
>> 
>> Who is the "we" who is rejecting this post? 
>
>Execution via script.  Parameters determined by group consensus.

I'm sorry, I meant for you to think about what you were saying before
whipping off another silly answer.

Where is this "script", and who runs it? How do we make sure that all
articles posted go to that script and not to the group like they
normally do? Who mandates that they cannot be posted? Who prohibits
other people from running a bot with a different set of rules? 

>i.e. "we".

"We" are not running any script. "We" will never run a script. 

>> There is another word you should be aware of w.r.t. USENET. "Troll".
>
>Please killfile me.  We'll both feel better.

Please stop posting nonsense. You are wasting resources around the world
even if everyone killfiles you. But since you asked me to, I am now
going to killfile you in the digest, like you asked.



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

Date: Fri, 16 Jun 2000 10:53:30 -0500
From: Tyler Robert Wood <twood@csd.uwm.edu>
Subject: creating and opening a file
Message-Id: <Pine.OSF.3.96.1000616104953.17273A-100000@alpha2.csd.uwm.edu>


Hello,

For some reason, I'm having trouble creating and opening a file.
The code looks like this:


        $filename = $highest.".txt";
        open (FILE, $filename) || print "Can't open the file";
        print FILE $message;
        close (FILE);

The file is never created or opened.
I bet it's something simple I'm missing,
any ideas?

Thanks in advance,

Tyler Wood
twood@uwm.edu



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

Date: Fri, 16 Jun 2000 18:01:42 +0200
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: creating and opening a file
Message-Id: <394A4F66.48DA9157@mssys.com>

Tyler Robert Wood wrote:
> For some reason, I'm having trouble creating and opening a file.
> The code looks like this:
> 
>         $filename = $highest.".txt";
>         open (FILE, $filename) || print "Can't open the file";
>         print FILE $message;
>         close (FILE);
> 
> The file is never created or opened.
> I bet it's something simple I'm missing,
> any ideas?

You should try
   open (FILE, ">$filename") || print "Can't open the file";
to open the file for writing.
So your bet was right.

Cheers
	Wolfgang


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

Date: Fri, 16 Jun 2000 18:36:24 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: creating and opening a file
Message-Id: <rblkksccd9p6ebotu52qgorl2i2mn17pi0@4ax.com>

On Fri, 16 Jun 2000 18:01:42 +0200, Wolfgang Hielscher
<W.Hielscher@mssys.com> wrote:

> Tyler Robert Wood wrote:
> > For some reason, I'm having trouble creating and opening a file.
> > The code looks like this:
> > 
> >         $filename = $highest.".txt";
> >         open (FILE, $filename) || print "Can't open the file";
> >         print FILE $message;
> >         close (FILE);
> > 
> > The file is never created or opened.
> > I bet it's something simple I'm missing,
> > any ideas?
> 
> You should try
>    open (FILE, ">$filename") || print "Can't open the file";
> to open the file for writing.

Whilst that sorts out one thing there are two other issues at hand here:

First is to always include '$!' in the diagnostic, so that you know
_what_ went wrong.

Second is that just print()ing the diagnostic isn't enough in case of an
error. Since there is no use for the program (as shown) if the open
failed, better to let it die() immediately:

	open FILE, "> $filename" or die "Can't open '$filename': $!";

-- 
Good luck,
Abe


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

Date: 16 Jun 2000 12:38:27 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: creating and opening a file
Message-Id: <slrn8kkn2b.me0.abigail@alexandra.delanet.com>

Tyler Robert Wood (twood@csd.uwm.edu) wrote on MMCDLXXXI September
MCMXCIII in <URL:news:Pine.OSF.3.96.1000616104953.17273A-100000@alpha2.csd.uwm.edu>:
&& 
&& Hello,
&& 
&& For some reason, I'm having trouble creating and opening a file.
&& The code looks like this:
&& 
&& 
&&         $filename = $highest.".txt";
&&         open (FILE, $filename) || print "Can't open the file";
&&         print FILE $message;
&&         close (FILE);
&& 
&& The file is never created or opened.
&& I bet it's something simple I'm missing,

Yes. It's called "-w". Run the program with warnings enabled, and
Perl will tell you what's wrong.



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: Fri, 16 Jun 2000 16:34:37 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: creating and opening a file
Message-Id: <8idkur$u6h$1@nnrp1.deja.com>

In article
<Pine.OSF.3.96.1000616104953.17273A-100000@alpha2.csd.uwm.edu>,
  Tyler Robert Wood <twood@csd.uwm.edu> wrote:
>
> Hello,
>
> For some reason, I'm having trouble creating and opening a file.
> The code looks like this:
>
>         $filename = $highest.".txt";
>         open (FILE, $filename) || print "Can't open the file";

You are trying to open file for reading only.
Also why not to use a more descriptive error message ?

open FILE, "> $filename"  or die "cannot open $filename: $!\n";

For more details abot different file open modes
see your local 'perldoc -f open'.
(or http://www.cpan.org/doc/manual/html/pod/perlfunc/open.html)

>         print FILE $message;
>         close (FILE);
>
> The file is never created or opened.
> I bet it's something simple I'm missing,
> any ideas?
>

Hope this helps.
Ilja.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Jun 2000 17:48:05 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: creating and opening a file
Message-Id: <8idp8l$4mb4u$1@fu-berlin.de>

hi,

Ilja Tabachnik <billy@arnis-bsl.com> wrote:
> In article
> <Pine.OSF.3.96.1000616104953.17273A-100000@alpha2.csd.uwm.edu>,
>   Tyler Robert Wood <twood@csd.uwm.edu> wrote:
>>
>>         $filename = $highest.".txt";
>>         open (FILE, $filename) || print "Can't open the file";

> Also why not to use a more descriptive error message ?

> open FILE, "> $filename"  or die "cannot open $filename: $!\n";

open FILE, "> $filename"  or die "cannot open $filename: $!";

better to leave that newline out:
perldoc -f die

tina


-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \ _,_\ __/\ __/_| /__/ perception


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

Date: Fri, 16 Jun 2000 17:59:40 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: creating and opening a file
Message-Id: <gWt25.410$uE5.4688@news.uswest.net>

Tina Mueller <tina@streetmail.com> elucidates:

>> open FILE, "> $filename"  or die "cannot open $filename: $!\n";
> 
> open FILE, "> $filename"  or die "cannot open $filename: $!";
> 
> better to leave that newline out:

Better for who? If I'm managing my error messages, even unto death, 
perhaps I don't want a line number.

Line numbers encourage operators to open files and 'fix' things.


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

Date: Fri, 16 Jun 2000 15:26:08 GMT
From: rsenior@NOSPAMFORMEhotmail.com (Robin Senior)
Subject: dbm's and associative arrays
Message-Id: <394a46e4.27352741@harnews0>

Hi all,
When using a dbm, is it possible to use two-dimensional associative
arrays?

If I do this:

#!/usr/bin/perl

%aa1 = (
	key1 => element1,
	key2 => element2
);

dbmopen(%ALLRECORDS, 'MYDBM', 0777);

$ALLRECORDS{allkey1} = {%aa1};

print "%aa content is: $aa1{key1}\n";
print "ALLRECORDS content:$ALLRECORDS{allkey1}\n";
print "allkey1 content:$ALLRECORDS{allkey1}{key1}\n";

dbmclose(%ALLRECORDS);

The output is:

%aa content is: element1
ALLRECORDS content:HASH(0x8762208)
allkey1 content:

I thought I read that dbm's could only store scalars in their
associative arrays, but when I do this:

print "ALLRECORDS content:$ALLRECORDS{allkey1}\n";

It prints:
ALLRECORDS content:HASH(0x8762208)

So it seems to be storing the associative array, but it won't let me
access the information inside it.

Can this be done, or have I made a syntax error? I've checked perldoc,
the camel book, and on the web...

Thanks,
Robin


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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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