[7539] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1166 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 13 03:37:42 1997

Date: Mon, 13 Oct 97 00:00:36 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 13 Oct 1997     Volume: 8 Number: 1166

Today's topics:
     ANNOUNCE: Bit::Vector 5.0 BETA 1 (Steffen Beyer)
     Re: Can someone look at this and tell me why it doesn't (Mike D. Kail)
     Re: Can someone look at this and tell me why it doesn't (Robert Patrick)
     Re: Can someone look at this and tell me why it doesn't (Tad McClellan)
     Re: Can someone look at this and tell me why it doesn't <jgostin@shell2.ba.best.com>
     Getting PERL for NT and installing it. <escobar@oxy.edu>
     Re: How does "die" work? <bholzman@mail.earthlink.net>
     Re: How does "die" work? (Tad McClellan)
     Re: How does "die" work? <robert.friberg@eductus-vast.com>
     Re: How to do hashes in CGI.pm - help needed please! (Robert Patrick)
     Re: howto: implement a mailing list? <mweber@atlas.de>
     Re: Need help in searching a string <bholzman@mail.earthlink.net>
     Re: Need help in searching a string <petri.backstrom@icl.fi>
     Re: Newbie question; how to redirect <petri.backstrom@icl.fi>
     Re: Perl Info! <shiloh@shell9.ba.best.com>
     Re: Perl Info! <jgostin@shell2.ba.best.com>
     Re: Problems with flock <petri.backstrom@icl.fi>
     Re: the oddest syntax error <bholzman@mail.earthlink.net>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 13 Oct 1997 06:04:12 GMT
From: sb@sdm.de (Steffen Beyer)
Subject: ANNOUNCE: Bit::Vector 5.0 BETA 1
Message-Id: <61sdks$e3a@sunti1.sdm.de>

Dear Perl users,

I am glad to be able to announce the first BETA release of version 5.0
of my "Bit::Vector" module:

                    =====================================
                      Package "Bit::Vector" Version 5.0
                    =====================================
                      for Perl version 5.000 and higher

It is available from http://www.engelschall.com/u/sb/download/ or from
any CPAN ftp server (look for "Bit-Vector-5.0b1.tar.gz").

The coding of the new methods (see below for a list) is now complete;
the module passes all regression tests, but more test scripts and a
more complete documentation are still lacking.


What does it do:
----------------

This module is useful for a large range of different tasks:

  -  For example for implementing sets and performing set operations
     (like union, difference, intersection, complement, check for subset
     relationship etc.),

  -  as a basis for many efficient algorithms (the complexities of the
     methods in this module are usually either O(1) or O(n/b), where
     "b" is the number of bits in a machine word on your system),
     like the "Sieve of Erathostenes" (for calculating prime numbers),

  -  for using shift registers (for instance for cyclic redundancy
     checksums) of arbitrary length,

  -  to calculate "look-ahead", "first" and "follow" character sets
     for parsers and compiler-compilers,

  -  for graph algorithms,

  -  for efficient storage and retrieval of status information,

  -  for performing text generation depending on logical expressions,

  -  for big integer arithmetic,

  -  for manipulations of chunks of bits of arbitrary size,

and more.

A large number of import/export methods allow you to access individual
bits, contiguous ranges of bits, machine words, arbitrary chunks of
bits, lists (arrays) of chunks of bits or machine words and a whole
bit vector at once (for instance for blockread/-write to and from
a file).

You can also import and export the contents of a bit vector in binary,
hexadecimal and decimal representation as well as "newsrc" style
enumerations.

Note that this module is especially designed for efficiency, which is
also the reason why its methods are implemented in C.

To further increase execution speed, the module doesn't use bytes as its
basic storage unit, but rather uses machine words, assuming that a machine
word is the most efficiently handled size of all scalar types on all
machines (that's what the ANSI C standard proposes and assumes anyway).

In order to achieve this, it automatically determines the number of bits
in a machine word on your system and then adjusts its internal configuration
constants accordingly.

The greater the size of this basic storage unit, the better the complexity
(= execution speed) of the methods in this module (but also the greater the
average waste of unused bits in the last word).


Important note:
---------------

Note that the C library at the core of this module ("BitVector.c") can
also be used stand-alone (i.e., without Perl).

To do so, link the output file "BitVector.o" (which is produced when you
build this module or when you just compile "BitVector.c") with your
application.

Note however that this C library does not perform any bounds checking;
this is your application's duty.

See the file "Vector.xs" in this distribution for an example of how
this can be done.


Example applications:
---------------------

See the module "Set::IntegerRange" for an easy-to-use module for sets
of integers.

See the module "Math::MatrixBool" for an implementation of boolean
matrices.

(Both modules are available from "http://www.engelschall.com/u/sb/download/"
or from any CPAN ftp server.)

A tool relying crucially on this "Bit::Vector" module is "Slice" (see
also "http://www.engelschall.com/sw/slice/"), a tool for generating
varying document versions out of a single master file. (This tool was
written by Ralf S. Engelschall).

This tool is itself part of another tool (by the same author), "WML"
(= "Website Meta Language"), which allows you to generate and maintain
large web sites (see also "http://www.engelschall.com/sw/wml/"). Among
many other features, it allows you to define your own HTML tags which
will be expanded either at generation or at run time, depending on your
choice.


New features in version 5.0:
----------------------------

In version 5.0, the following new methods have been added:

  -  Word_Bits()
  -  Long_Bits()
  -  Primes()
  -  Interval_Copy()
  -  Interval_Substitute()
  -  to_Bin()
  -  from_bin()
  -  to_Dec()
  -  from_dec()
  -  Insert()
  -  Delete()
  -  add()
  -  subtract()
  -  Negate()
  -  Absolute()
  -  Sign()
  -  Multiply()
  -  Divide()
  -  GCD()
  -  Block_Store()
  -  Block_Read()
  -  Word_Size()
  -  Word_Store()
  -  Word_Read()
  -  Word_List_Store()
  -  Word_List_Read()
  -  Word_Insert()
  -  Word_Delete()
  -  Chunk_Store()
  -  Chunk_Read()
  -  Chunk_List_Store()
  -  Chunk_List_Read()
  -  Transpose()

The following methods have been re-implemented in C (instead of Perl):

  -  Version()
  -  Shadow()
  -  Clone()
  -  to_Enum()       (previously named "to_ASCII")
  -  from_enum()     (previously named "from_ASCII")

The following methods have been renamed:

  -  to_String()      -->    to_Hex()
  -  from_string()    -->    from_hex()
  -  to_ASCII()       -->    to_Enum()
  -  from_ASCII()     -->    from_enum()

(Aliases for the old names are still available but deprecated!)

And finally, the following methods are gone:

  -  lexorder()
  -  new_from_String()

A patch utility is available in the module's distribution to upgrade your
existing applications and to provide substitutes for the two methods that
are gone.


Legal issues:
-------------

This module and its distribution with all its parts is

Copyright (c) 1995, 1996, 1997 by Steffen Beyer. All rights reserved.

Please read the file "LICENSE" in the module's distribution for details
about the exact terms under which this package may be used and distributed.


Prerequisites:
--------------

Perl version 5.000 or higher, a C compiler capable of the ANSI C standard (!)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


Author's note:
--------------

If you have any questions, suggestions or need any assistance, please
let me know!

Also, if there is anything you would like to do with this module which
the module doesn't provide yet, please let me know! If it fits the module's
overall concept, I'll implement it as soon as possible. Frequently this is
only a matter of a few days.

I hope you will find this module beneficial!

Yours,
--
    Steffen Beyer <sb@sdm.de> http://www.engelschall.com/u/sb/
     "There is enough for the need of everyone in this world,
      but not for the greed of everyone." - Mahatma Gandhi


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

Date: 13 Oct 1997 04:11:40 GMT
From: mdkail@fv.com (Mike D. Kail)
Subject: Re: Can someone look at this and tell me why it doesn't work!!
Message-Id: <slrn643825.q4r.mdkail@dime.fv.com>

On Sun, 12 Oct 97 20:45:31 -0400, franklin@nospamingideas4you.com
<franklin@nospamingideas4you.com> wrote:
[...]
>               if ($PassFile==$PassValue) {
>                    $Logged=1;
>                    $BaseDir = $UserMaxLowDir;
[...]
>The two if statements don't work.  it just passes through them like it's
>not like thier not even there. -- 

that's because your 'if' statments are incorrect.  since you are comparing
2 strings you need to use the 'eq' keyword, not '=='

e.g.

	if ($PassFile -eq $PassValue) {
	...


-- 
/*-------------------------------------------------------------*/
/*  Mike D. Kail                    |  voice:  (619) 350-3524  */
/*  Unix System Architect           |  fax:    (619) 793-2950  */
/*  FIRST VIRTUAL Holdings Inc.     |  e-mail: mdkail@fv.com   */
/*-------------------------------------------------------------*/



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

Date: Mon, 13 Oct 1997 04:33:36 GMT
From: rpatrick@ix.netcom.com (Robert Patrick)
Subject: Re: Can someone look at this and tell me why it doesn't work!!
Message-Id: <3444a3fc.3029707@nntp.ix.netcom.com>

On Sun, 12 Oct 97 20:45:31 -0400, franklin@nospamingideas4you.com
wrote:

>     foreach $CheckLog (@CheckLog) {
>          ($PassFileName, $PassFile, $UserMaxLowDir) =
>split(/:/,$CheckLog);
>          if ($PassFileName == $LogValue) {
>               if ($PassFile==$PassValue) {
>                    $Logged=1;
>                    $BaseDir = $UserMaxLowDir;
>                    }
>               }
>          }
>
>The two if statements don't work.  it just passes through them like it's
>not like thier not even there. -- 

The comparison operator for strings is "eq", not "==".  Could this be
your problem?

Cheers,
Robert



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

Date: Sun, 12 Oct 1997 22:02:37 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Can someone look at this and tell me why it doesn't work!!
Message-Id: <d03s16.in3.ln@localhost>

franklin@nospamingideas4you.com wrote:
:      foreach $CheckLog (@CheckLog) {
:           ($PassFileName, $PassFile, $UserMaxLowDir) =
: split(/:/,$CheckLog);
:           if ($PassFileName == $LogValue) {
:                if ($PassFile==$PassValue) {
:                     $Logged=1;
:                     $BaseDir = $UserMaxLowDir;
:                     }
:                }
:           }

: The two if statements don't work.  it just passes through them like it's
: not like thier not even there. -- 


That should work fine if $PassFileName, $LogValue, $PassFile, and
$PassValue are all numbers instead of strings.

So, I expect they are strings, since you here you are 
posting yet again...

Strings are compared with the eq operator, not with the == operator.

It says so right in the man pages that come with perl.

One of the headings in the perlop man page is "Equality Operators".

There it says:

"Binary "==" returns true if the left argument is numerically equal to
the right argument.

 ...

Binary "eq" returns true if the left argument is stringwise equal to
the right argument."



[ snip that damn eighteen line sig again

  Sheesh. Sheesh. Sheesh. Sheesh.

  Stop the madness!
]


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 13 Oct 1997 06:04:27 GMT
From: Jeff Gostin <jgostin@shell2.ba.best.com>
Subject: Re: Can someone look at this and tell me why it doesn't work!!
Message-Id: <61sdlb$11t$2@nntp1.ba.best.com>

Tad McClellan <tadmc@flash.net> wrote:
: That should work fine if $PassFileName, $LogValue, $PassFile, and
: $PassValue are all numbers instead of strings.

If this is an RTFM, point me at the FM, and I'll happily read away. I don't
suspect it is, and I suspect that the answer is 'no' because of PERL's lack
of specific data types, but here's the question:

Is there a way to determine if a scalar (or an array element, or whatever)
contains a numeric sequence or an alphanumeric sequence?

				--Jeff


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

Date: Sun, 12 Oct 1997 21:33:48 -0700
From: Julio Rafael Escobar <escobar@oxy.edu>
Subject: Getting PERL for NT and installing it.
Message-Id: <3441A4AB.24CB@oxy.edu>

Hi everyone,

I am very interested in learning PERL.  I have written some batch files,
but I find that they are limited in power.  Can someone tell me how I
can get PERL for NT 4.0 and install it.  I may have it in the NT
Resource Kit already, but I don't know how to get it started:  This
means installing it and getting into a code window where I can start
writing code.

Also, are there any good how-to books out there that you can recommend? 
I would like to start with the ABC's of PERL.  Please let me know by
replying to the address below.  I would really appreciate your help.

-- 
Best regards,

Julio R. Escobar
email: mailto:escobar@oxy.edu


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

Date: Sun, 12 Oct 1997 21:06:04 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Yingxue Li <yingxue@ee.tamu.edu>
Subject: Re: How does "die" work?
Message-Id: <344173FC.FF30C6FC@mail.earthlink.net>

[posted & mailed]

Yingxue Li wrote:
> 
> Hi, all:
> 
> In one of my cgi program, I used code like:
> 
>   die "Content_type:text/html\n\n Please input data in every field"
>      unless($statement);
> 
> I expected it would export the message to browser when statement was not
> true, but it didn't. Instead, it exported a server error message to
> browser. When I checked  the error_log of server, the message
> (text/html\n\n,...) was there, following by "script headers premature".
> 
> I know there are some other ways to solve the problem, but, can "die" do
> it?
> Another stupid question, huh?
> 
> Li

If you look up die() in perlfunc, you'll see that die prints its error
message to STDERR, not STDOUT.  If you want die()s error messages to
show up on the browser, redirect STDERR to STDOUT.  You might also be
interested in the CGI::Carp module.


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

Date: Sun, 12 Oct 1997 20:29:55 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How does "die" work?
Message-Id: <jitr16.3d3.ln@localhost>

Yingxue Li (yingxue@ee.tamu.edu) wrote:

:   die "Content_type:text/html\n\n Please input data in every field"
:      unless($statement);

: I expected it would export the message to browser when statement was not
: true, but it didn't. Instead, it exported a server error message to
: browser. When I checked  the error_log of server, the message
: (text/html\n\n,...) was there, following by "script headers premature".

: I know there are some other ways to solve the problem, but, can "die" do
: it? 
: Another stupid question, huh?


I would have to say Yes. 

Considering the very first line in the description
for die() in the perlfunc man page says:

   "Outside of an eval(), prints the value of LIST to C<STDERR>"

most servers are set up to put STDERR to the error logs, and STDOUT
to the browser.


So the machines are doing exactly what you told them to do.

Try telling them to do something else  (write to STDOUT ;-)


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 13 Oct 1997 05:56:31 GMT
From: "Robert Friberg" <robert.friberg@eductus-vast.com>
Subject: Re: How does "die" work?
Message-Id: <01bcd79c$f47660c0$c82da8c0@akilles.ittek.org>

> In one of my cgi program, I used code like:
> 
>   die "Content_type:text/html\n\n Please input data in every field"
>      unless($statement);
> 

die prints on STDERR 

try this instead:

$msg = "Content_type:text/html\n\n Please input data in every field";
print $msg && die unless ($statement);

-- 
#######################################
#
#   Robert Friberg	
#   robert.friberg@eductus-vast.com
#
#######################################




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

Date: Mon, 13 Oct 1997 04:29:34 GMT
From: rpatrick@ix.netcom.com (Robert Patrick)
Subject: Re: How to do hashes in CGI.pm - help needed please!
Message-Id: <3443a1a0.2426026@nntp.ix.netcom.com>

I think you have the answer below.

On Sun, 12 Oct 1997 22:20:37 +0100, Rosemary I H Powell
<Rosie@dozyrosy.demon.co.uk> wrote:

>I feel very stupid asking this question because I'm sure that I am
>missing something simple:
>
>I have just started using CGI.pm instead of cgi-lib.pl and am having
>difficulty working out how to get a list of all the parameters as
>key/value pairs.
>
>With cgi-lib.pl I can do something like:
>    foreach $input (values (%form_data) ) {
>       $form_data{$key} = $value;
>    }
>
>CGI.pm documentation gives examples of how to get the names of all the
>parameters:
>    @names = $query->param
>
>or how to get the value(s) of a SINGLE named parameter:
>    @values = $query->param('foo')
>    $value  = $query->param('foo')
>
>But how do I get names and values into a hash where both are unknown
>quantities??? I just can't see/understand how to do this and I'm getting
>my knickers in a right old twist...If someone could show me the code to
>match my cgi-lib example I would be truly grateful.

How about something like this:

foreach $key ($query->param) {
   $form_data{$key} = $query->param($key);
}

Robert


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

Date: Mon, 13 Oct 1997 08:20:13 +0200
From: "Mathias-H. Weber" <mweber@atlas.de>
Subject: Re: howto: implement a mailing list?
Message-Id: <3441BD9D.C22BE958@atlas.de>

There is a very useful little perl script "guestbook+" written by Mark
Peskin:

http://friga.mer.utexas.edu/mark/perl/

Maybe you should have a look at it. Of course it does not explain any
questions related to mailing lists in principle. Furthermore using this
script requires "perl" to be installed on your site. 

It seems to me that you are rather at the beginning of thinking about
mailing lists. Another hint would be to have a look at the "majordomo"
programm (also written in perl). Below I have copied one paragraph out
of the FAQs for you:

# You can get an HTML version of this FAQ on the World Wide Web at
#   http://www.cis.ohio-state.edu/~barr/majordomo-faq.html. You can
#   request a copy by email by sending a message to
#   mail-server@rtfm.mit.edu, with the following text in the body:
   
#send
usenet/comp.mail.list-admin.software/Majordomo_Frequently_Asked_Questions

Hope this gives you enough stuff to start reading, thinking, working..
Mathias
-- 
__________________________________________________________________
| Dr. Mathias-H. Weber          ---     mailto:mweber@atlas.de   |
| STN ATLAS ELEKTRONIK GmbH   {~@_@~}                            |
| Brueggeweg 54 / Dept ETS21  _( Y )_   Phone:  +49 421 457 4401 |
| 28305 BREMEN               (:_~*~_:)  Fax  :  +49 421 457 3177 |
| Germany                     (_)-(_)   Telex:  2 457 460        |
___________________________SIGSIG: Signature too long (core dumped)


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

Date: Sun, 12 Oct 1997 21:35:47 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: fain@actcom.co.il
Subject: Re: Need help in searching a string
Message-Id: <34417AF3.9F375080@mail.earthlink.net>

[posted & mailed]

|| Fains || wrote:
> 
> OK, I know I didn't start the questions but after reading your message I now have
> one (it could be because I am coming in late). I understood everything up to this
> line of code:
> 
> push @foods, $1;
> 
> What does "push" do?
> what do we expect to find in @Foods?
> last but not least - what does the $1 do?
> 

> > #1.  get a line from the file
> > while( $line = <FILE> )
> >    {
> >    #2. is this the right line?
> >    next unless $line =~ m/service:: catering/;
> >
> >    #2 YES: so get the next line:
> >    $next_line = <FILE>;
> >
> >    #3. was it the right line?
> >    next unless $next_line =~ m/food type: (.*)/;
> >
> >    #3 YES:  do your thing
> >    push @foods, $1;
> >    }
> >

As documented in perlfunc, PUSH ARRAY, LIST pushes the values of LIST
onto the end of ARRAY.  Now, the $1 is set in the previous line, in the
pattern match.  If you consult perlre, you'll see that if you enclose
pieces of patterns inside ()s, the portion of the string which matches
those pieces of the pattern get stored in special variables $1, $2,
etc., respectively.  So the '(.*)' from the pattern match, which will
match everything after 'food type: ' on the lines which have that, goes
into $1.  This is being pushed onto the end of @foods; we expect @foods
to contain every food type.

HTH,
Benjamin Holzman


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

Date: Sun, 12 Oct 1997 10:41:04 +0200
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Need help in searching a string
Message-Id: <34408D20.794B@icl.fi>

|| Fains || wrote:
> 
> OK, I know I didn't start the questions but after reading your message I now have
> one (it could be because I am coming in late). I understood everything up to this
> line of code:
> 
> push @foods, $1;
> 
> What does "push" do?
> what do we expect to find in @Foods?
> last but not least - what does the $1 do?

Pushes/appends a new element to a list (see the perlfunc manual 
page for details; part of the free online documentation that 
comes with every proper Perl distribution kit).

$1 is the result of a match preceding it (i.e., what you've
found).

In essence, it means that all the things you found have been
appended to a list/array @foods.

Now, what's in @Foods we don't know, but it is probably
different from what's in @foods ;-)

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: Sun, 12 Oct 1997 10:35:26 +0200
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Newbie question; how to redirect
Message-Id: <34408BCE.50@icl.fi>

Johann Ehm wrote:
> 
> Hi, I have an old URL and I wan4t to redirect all accesses to my new URL
> automatic so that the visitor won4t have to click a new URL-link.
> I4m not at all familiar in how scripts work so I need in deepth help.
> Thanxs in advance.
> Johann Ehm, Sweden

You don't need a Perl script for that. All you need 
to do is to replace the original page with one that
redirects the user to the new location:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
    <html>
    <head>
        <meta http-equiv="REFRESH" 
              content="2; url=http://newhost.com/newpage.html"> 
    </head>
    <body>
        <p>
        <a href="http://newhost.com/newpage.com">New location</a>
        (In case the automagic redirection isn't working.)
        </p>
    </body>
    </html>

And even you did this in a CGI script, the general 
mechanics for it you should try to find out from books, 
online docs, frequently asked questions lists (FAQs), 
searches through services such as http://www.dejanews.com 
or http://altavista.digital.com and if those don't help,
then by asking in the newsgroup comp.infosystems.www.authoring.cgi
if you determine it is a CGI script that you want to use
to accomplish your goal, and if not - as you can see above -
you would've searched comp.infosystems.www.authoring.html
instead.

Save this group for when you have actual Perl questions
(that online docs, FAQs or dejanews searches cannot answer
for you ;-)

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: 13 Oct 1997 05:50:25 GMT
From: <shiloh@shell9.ba.best.com>
Subject: Re: Perl Info!
Message-Id: <61scr1$134$1@nntp1.ba.best.com>

Tammy Lowney <tlowney@gonzaga.edu> wrote:
: I am new to the perl language and would like some information sources on
: where to get started (books, websites...).  Any suggestions would be
: appreciated.  Thanks!!                       

I recommend "Learning Perl" by Schwartz.  It's a very structured approach
for the beginner.  Good book.

--Joe McCaughan | He who heeds the word wisely will find good,
shiloh@best.com | And whoever trusts in the Lord, happy is he. Proverbs 16:20


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

Date: 13 Oct 1997 06:07:58 GMT
From: Jeff Gostin <jgostin@shell2.ba.best.com>
Subject: Re: Perl Info!
Message-Id: <61sdru$11t$3@nntp1.ba.best.com>

shiloh@shell9.ba.best.com wrote:
: I recommend "Learning Perl" by Schwartz.  It's a very structured approach
: for the beginner.  Good book.

Seconded! "Learning Perl" is a good book for "this is how Perl expects you
to tell it things, and this is what you can expect back from it". The
"sequel" is "Programming Perl", by Wall, Schwartz, and Christianson. It
expands nicely on "What you can actually tell Perl to do, and how to do it
to make Neat Thingies!". :)

				--Jeff



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

Date: Sun, 12 Oct 1997 10:18:37 +0200
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Problems with flock
Message-Id: <344087DD.AF1@icl.fi>

Xavier Tarafa Mercader wrote:

[snip]
 
> The value I get when locking the file (flock(TABLE,$LOCK_EX) is $valor=1
> 
> and when i'm unlocking $valor=0. I've assumed   1 = succes
> 0=error.
> Why I get an error unlocking the file when I flock succesfully
> (assuming success returns 1)?

Maybe because you close the file (which flushes any and all
buffered data, releases the lock and closes the file) before 
you try to unlock.

Just remove the unlocking code and leave the close. In no
circumstances should you unlock before you close, because
that opens up a window where some other process could get
write access and write to the file before you get to the
closing (and thus flushing any buffered data) - the result
being corrupt data.

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: Sun, 12 Oct 1997 21:24:35 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Kenneth Taborek <oberon@nospam.erols.com>
Subject: Re: the oddest syntax error
Message-Id: <34417853.F6FFF12E@mail.earthlink.net>

[posted & mailed]

Kenneth Taborek wrote:
> 
> I have encountered an error which I cannot come to terms with.  The
> program below has been stripped of all extraneous lines.  But, prior to
> paring it down, I had a small loop which printed the key-element pairs
> of %rot13, and it worked fine.  Then I noticed that @temp2 should fall
> in range (a..m) instead of (a..n).  When I made this change, I got the
> following syntax error.
> 
> syntax error at ./thingy.pl line 12, near "if"
> Execution of ./thingy.pl aborted due to compilation errors.
> 
> Here is my script:
> 
> #! /usr/bin/perl
> 
> $i = 0;
> %rot13 = {};

This should read: %rot13 = ();

> 
> @alpha = (a..z);
> @temp1 = (n..z);
> @temp2 = (a..n);
> 
> for ($i = 0; $i < 26; $i++)  {
> 
>     if ($i < 13)  {
> 
>         $rot13{$alpha[$i]} = $alpha[($i + 13)];
>     }
>     else  {
>         $rot13{@alpha[$i]} = $alpha[($i - 13)];
>     }
> }
> 
> Now, I am a complete beginner to perl, and may have made some basic
> error, but I do not see how changing the range of elements in an array
> could make the difference between working and breaking.
> 
> --oberon@erols.com

When you say:
@temp2 = (a..m);

The parser interprets the 'm)' as the beginning of a matching operation,
using ')' as the pattern delimiter.  By the parser's logic, the pattern
ends at '$i++)' which is followed by '} if', thus the syntax error.  If
instead you say:
@temp2 = ('a'..'m');
you won't have a problem.  Don't worry about having missed this; it took
me a while to figure it out, and I've been programming in perl for over
2 years...

Benjamin Holzman


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 1166
**************************************

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