[13056] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 466 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 11 17:07:20 1999

Date: Wed, 11 Aug 1999 14:05:12 -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           Wed, 11 Aug 1999     Volume: 9 Number: 466

Today's topics:
    Re: About qq() and need help <cassell@mail.cor.epa.gov>
        Another quick question...Arrays...testing against (BXTC)
    Re: array and file processing <cassell@mail.cor.epa.gov>
    Re: Comma seperated numbers (brian d foy)
        Dereferencing anon hash <jogoodma@lanl.gov>
        Design by Contract Seminar Series <training@eiffel.com>
    Re: File locking ? <jerrad@networkengines.com>
    Re: Getting perl to accept a flat table file <cassell@mail.cor.epa.gov>
        How to delete an element from an array (Dico Reyers)
    Re: How to delete an element from an array <tchrist@mox.perl.com>
    Re: How to delete an element from an array <sariq@texas.net>
    Re: How to share constants across modules? <david@coppit.org>
        HTTP & sockets on win32 <jerrad@networkengines.com>
    Re: I guess this is a Misc question: Cgi-bin (J. Moreno)
    Re: I guess this is a Misc question: Cgi-bin (J. Moreno)
        lock_nb <flexit@flexit.eurobell.co.uk>
    Re: Looking for Reviews - Perl <cassell@mail.cor.epa.gov>
    Re: Mini-objects (Sean McAfee)
    Re: Nicer Way (J. Moreno)
        Perl Novice needs advice <w.mak@cwcom.net>
    Re: Perl Novice needs advice <jerrad@networkengines.com>
    Re: Perl Question - NOT ! <phony@nospam.com>
    Re: pricing a perl job (J. Moreno)
    Re: printf problem - Left-Justifying Floats <cassell@mail.cor.epa.gov>
    Re: printf problem - Left-Justifying Floats <sariq@texas.net>
    Re: Problem reading forms with perl genelong@my-deja.com
        Problem using last with a label support@gethits.com
    Re: Re(2): NO-ONE USES PERLQT !!!!!!!!!!!!!!!!!!!!!???? (Tad McClellan)
    Re: reference to object method (Greg Bacon)
    Re: Run a script from a web browser and put it in the b <cassell@mail.cor.epa.gov>
        Sesssion ID <flexit@flexit.eurobell.co.uk>
        working with imagery <tom.kralidis@ccrs.nrcanDOTgc.ca>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Wed, 11 Aug 1999 13:25:57 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: About qq() and need help
Message-Id: <37B1DC55.D711490D@mail.cor.epa.gov>

Guideline Chan wrote:
> 
> $alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
>             'abcdefghijklmnopqrstuvwxyz'.
>             '0123456789+/';
> $_="vq7O";
> eval qq{ tr!$basealphabet!\0-\77!; };
> 
> What's the meaning of the fifth line??? Is it equivalent to
> tr/$basealphabet/\0-\77/; ?? if not, what does it equivalent to???

When you go back and re-read the manpages [it is under "Regexp
Quote-Like Operators" in the perlop section] you'll see that
tr/// can take other brackets besides '/'.  So the author was
changing the bouning brackets to avoid the '/' buried in the
variable.  The eval() is because tr/// doesn't accept variables
like s/// does.  That is covered in the same section.

But the whole snippet you quoted is unnecessary, since tr///
accepts ranges.  You would be better off writing that 
monstrosity as:

$_='vq70';   #single quotes!
tr[A-Za-z0-9+/][\000-\077];

or, if the string was already in a variable $string1:

$string1 =~ tr[A-Za-z0-9+/][\000-\077];

What was the author trying to do?
And are you sure this is a piece of code from which you 
want to learn Perl?

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 11 Aug 1999 20:36:39 GMT
From: "(BXTC)" <bxtc@forfree.at>
Subject: Another quick question...Arrays...testing against
Message-Id: <r9ls3.98$1B5.7574@monger.newsread.com>

Hi, I am sorry for bothering you all again, but you were so helpful before.
I
since have bought the Camel book, and have been reading it and learning a
lot.  I think I am going to really learn it, even just for myself not as
much as for my work.  But I've run into another problem which hopefully is
easy, as I think many people would have to do this.....

I have an array "@numbers" with values as follows (although the $#numbers
will vary)

@numbers[0]  =  5
@numbers[1]  =  9
@numbers[2]  =  19
@numbers[3]  =  12
@numbers[4]  =  6

And I also have a string $target whose value is....(this also will vary)

$target  =  9 (and it is actually the number of elements in another
array....$#target)

Now I need to search each value of @numbers to see if ANY of them equals
$target.  I have been reading the book all about arrays, and I have learned
that I can't test it as @numbers because that would test the WHOLE array,
and using slices isn't any better.  I tried doing something like this

my $x = $#numbers - 1;
while ($x >= 0){
     if ($#target = $numbers[$x]) {
          DO_MY_FUNCT();
     } else {
          $x - 1;
     }
}

but it didn't work, as it didn't like my syntax and it was saying something
about a useless subtraction, on one of the lines that only had "}" on
it...so that confused me.

I hope it wouldn't be too much of a pain for you to help me.  There is no
rush on this at all, as I have met my bosses time limit(thanks totally to
you all), and am now improving the script for my own experience/knowledge.

And just so you don't think I am just getting you to do my work for me
(although the code I've shown you is probably proof enough as it is wrong
and inefficiant) I have been reading a lot in the perldoc(which is hard to
understand sometimes) and the Camel book(pretty good, but leaves some
questions unanswered), and looking at other people code from web sites.
Thanks for the time you have already spent, and for any more you might
spare.

Bryce Tate
Team Unicorn, Inc.
www.teamunicorn.com




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

Date: Wed, 11 Aug 1999 13:43:14 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: array and file processing
Message-Id: <37B1E062.295AD9A8@mail.cor.epa.gov>

Hector Gonzalez wrote:
> 
> Hi,
> 
> I am very sorry. We will work on fixing the formatting.
> 
> Uri Guttman wrote:
> 
> > hey, questionexchange,
> >
> > any chance you could use a proper newsreader and not mangle the quoted
> > text? it is impossible to read the code when you wrap it to hell. so
> > stop hiding behind your website and just read and post here directly.

Thank you for being polite about this.  Many people who answer
for the first time in this newsgroup do not take criticism
[either constructive or destructive] well.  And this group
is fairly firm about adhering to group standards.

BTW, your post earlier in this thread referred to:

@sortedscore = sort{ $a->{score} <=> $b->{score} } @topscore;

as the Schwartzian Transform.  It is not.  This is simply
a sort with an explicit sort routine.  The dreaded [:-]
Schwartzian Transform [or the 'Black Transform' as TomC
once suggested] looks like this:

# code snitched right out of perlfunc
@new = map { $_->[0] }   
       sort { $b->[1] <=> $a->[1]
                       ||      
              $a->[2] cmp $b->[2]
       } map { [$_, /=(\d+)/, uc($_)] } @old;

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 11 Aug 1999 16:44:00 -0400
From: brian@pm.org (brian d foy)
Subject: Re: Comma seperated numbers
Message-Id: <brian-ya02408000R1108991644000001@news.panix.com>

In article <7osjve$nr4$1@nnrp1.deja.com>, Stone Cold <paulm@dirigo.com> posted:


> script. Here is the subroutine...think it will work?
> 
> sub commify {
>         my $text = reverse $_[0];
>         $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
>         return scalar reverse $text;
> }

what happened when you tired it?

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: Wed, 11 Aug 1999 14:36:38 -0600
From: Josh Goodman <jogoodma@lanl.gov>
Subject: Dereferencing anon hash
Message-Id: <37B1DED6.8017EB7F@lanl.gov>

I am having some problems dereferencing an anonymous hash that I am
using.  If I take the code that sets up the anon hash outside of the
foreach loops I have no problems.  But when it is setup as shown below
I get an unitiliazed variable error at line 69 which is the final print
statement.  I have been working with this code for 2 days now and I am
sure I am missing something quite simple.  Can anyone help out with
this?

    The program is supposed to read everyline in two files and then
store the information from one column on every line.  The database
information is stored based on the file name used and then the line
number.

Thanks in advance,
Josh

#!/usr/local/bin/perl -w

use strict;

########################
#                                            #
#Initializing Variables         #
#                                            #
########################

my $root_dir  = "/home/mutant2/jogoodma/PDB/";
my @files      = ("crd.9.m0","crd.19.m0");
my $file_tail = ".rsa";
my $temp;
my $count     = 0;
my $avg_sasa  = 55;
my $abs_digits;
my %database;
my $i;
my $result;

########################
#                                            #
#Main Program                    #
#                                            #
########################

foreach $_ (@files) {
  $i = 0;
  my $file = $root_dir . $_ . $file_tail;
  open (FILE,$file);
  my @input = <FILE>;
  chop(@input);
  close(FILE);

  foreach $temp (@input) {
    if ($temp =~ /RES/ && $temp !~ /REM/) {
      my ($label,$aa,$res,$abs,$rel,$remainder) = split(' ',$temp,6);
      if ($abs < $avg_sasa) {
         $abs_digits = 0;
      }
      elsif ($abs >= $avg_sasa) {
         $abs_digits = 1;
      }
      #Creating anon hash
      $database{$_} = {
                 $i => $abs_digits
                  };

      $i++;
    }
  }
}

my $test;
#Derefencing one specific database entry by hand for testing purposes.
$test = %{$database{"crd.9.m0"}} ->{"1"};
print "$test\n";




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

Date: Wed, 11 Aug 1999 13:32:05 -0700
From: "Interactive Software Engineering, Inc." <training@eiffel.com>
Subject: Design by Contract Seminar Series
Message-Id: <7osmiu$b3k$1@news.rain.org>

ISE's EXCLUSIVE SEMINARS ON DESIGN BY CONTRACT AND THE COMPONENT REVOLUTION.
A ONE-DAY COURSE BY BERTRAND MEYER.

If you are involved in software development, either as a manager or as a
developer, you know how crucial it is to improve software quality and
productivity. In spite of the major advances of recent years, especially
Object Technology, it is still much too hard to produce correct, reliable
systems at a reasonable cost.

This state of the art seminar is a unique opportunity to hear about the
approach that is revolutionizing the software industry - not from an outside
observer, but from one of the key originators of the discipline, Dr.
Bertrand Meyer, one of a handful of object- oriented movers and shakers
whose work made modern object-oriented technology possible.

"Design by Contract" is the major technological breaktrough in software
engineering in the past 15 years. This course introduces Design by Contract
and shows why it can, like no other technique since the invention of classes
and objects, dramatically affect the way we develop software, and why it is
a required condition for achieving the promise of the Component Revolution.

For more information about the seminar, as well as locations, please visit
our Web site at http://www.designbycontract.com. You can also contact us by
email: training@eiffel.com.

Interactive Software Engineering, Inc
ISE Building
270 Storke Road, 2nd Floor
Goleta, CA 93117, USA
t. 805 685-1006
f. 805 685-6869







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

Date: Wed, 11 Aug 1999 16:58:28 -0400
From: jerrad pierce <jerrad@networkengines.com>
Subject: Re: File locking ?
Message-Id: <37B1E3F4.6AAAD36B@networkengines.com>

I'm pretty sure that when they say networking environment they mean NFS
etc. A notortious byatch for synchonization

Ian Coetzee wrote:
> 
> Hi
> I have a big problem I am trying to figure out how to use flock() , the
> information I got tells me that flock() might not work on a networking
> environment , so what is the use then ? Does anybody know how to implement
> file locking on a "flat file" which is to be used on the internet (as in a
> classified adds program). Can any body please help me ,
> 
> As I am new to Perl (but a seasoned Delphi and pascal developer) i would
> like any answers to be as descriptive as possable.
> 
> Thx's
>   Ian Coetzee
> seccoza@mweb.co.za


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

Date: Wed, 11 Aug 1999 13:14:03 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Getting perl to accept a flat table file
Message-Id: <37B1D98B.6016CBEB@mail.cor.epa.gov>

craig_davids@my-deja.com wrote:
> 
> In article <37B13280.B43298B7@analog.com>,
>   Paul Foran <Paul.Foran@analog.com> wrote:
> > Hi all,
> >
> > Can somebody tell me how to get perl to accept a comma delimited txt
> > file and parse it contents.

Craig, thank you for being so considerate as to provide an
answer here.  But you should think about the following
problems:

<pedant>

> Open the file into the file handle (STUFF, in this case) and parse the
> file using a split command.
> ie:
> open(STUFF, "dir/filename");

Always check the return of your open() .  And you don't
need to put double quotes around character strings which do not
need variable interpolation.

open STUFF, 'dir/filename' or die "Can't open for read: $!";

If Paul is planning on using this in a CGI script, he
would of course want a better approach than the standard 
die() .

> while(<STUFF>)

Good call.  No point in wasting memory by slurping in the 
whole file at once.

> {
> ($var1, $var2, $var3) = split (/,/);

Hmmmm.  Here's my real concern.  What happens when the CSV
file has a line like:

1234,"apples, bananas, and kumquats",14.52,"commas, commas, everywhere but not a
stop to think,"

and you split() on /,/ ?

This is in the FAQ, by the way.  Try this:

perldoc -q delimited

or 

perldoc perltoc

to track it down in perlfaq4.  The FAQ has a Jeffrey-Friedl
solution which handles the above problem, as well as a mention
of Text::ParseWords and Text::CSV modules.  It overlooks
the DBD::CSV solution which may be more of what the poster
really wants, since he is using this file as a database.

> # do something with variables
> }
> close(STUFF)

And it doesn't hurt to check the return on your close()
either.  Defensive programming is an aspect of hubris - in
the Larry Wall sense of the word - so it is A Good Thing(tm)
in a Perl programmer.  I wish I had more of it.  :-)

> good luck!
> 
> Craig

And I hope you don't take this [supposedly] constructive
criticism the wrong way.  I want you to stick around, and
to continue to answer questions.. and also to give 
really good answers.  Hey, I'm no Tom Christiansen when
it comes to Perl wisdom, but I *do* try.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 11 Aug 1999 20:03:24 GMT
From: dico@internetworks.ca (Dico Reyers)
Subject: How to delete an element from an array
Message-Id: <37b1d968.8951042@news.attcanada.net>

Hello there,

Could someone please let me know if it is possible to delete an
element from an array in perl?

@array = ("one","two and three",4,"five");

how do I delete '4' and be left with...

@array = ("one","two and three","five");

Thanks in advance,

Dico


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

Date: 11 Aug 1999 14:33:04 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to delete an element from an array
Message-Id: <37b1de00@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, dico@internetworks.ca (Dico Reyers) writes:
:Hello there,
:
:Could someone please let me know if it is possible to delete an
:element from an array in perl?
:
:@array = ("one","two and three",4,"five");
:
:how do I delete '4' and be left with...
:
:@array = ("one","two and three","five");

How did manage to miss the part of the perlfunc manpage right at the
time where it reads:

       Functions for real @ARRAYs
	   [deleted]

       Functions for list data
	   [deleted]

--tom
-- 
"Unix was never designed to keep people from doing stupid things, because
 that policy would also keep them from doing clever things."  (Doug Gwyn)
     
VMS is a text-only adventure game. If you win you can use Unix.


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

Date: Wed, 11 Aug 1999 15:30:45 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: How to delete an element from an array
Message-Id: <37B1DD75.5088D511@texas.net>

Dico Reyers wrote:
> 
> Hello there,

Howdy!

> Could someone please let me know if it is possible to delete an
> element from an array in perl?

splice

- Tom


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

Date: Wed, 11 Aug 1999 16:18:11 -0400
From: David Coppit <david@coppit.org>
To: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: How to share constants across modules?
Message-Id: <Pine.GSO.4.05.9908111604010.21255-100000@mamba.cs.Virginia.EDU>

On Wed, 11 Aug 1999, Tom Phoenix wrote:

> > Unfortunately, some people on different computers/versions are saying that
> > their version of perl is translating "main::DEBUG" into "&main::-1".
> 
> What error message are they getting? Can they make a small example program
> which demonstrates this behavior? Ten lines or so should suffice. Thanks!

Okay, I did some research and found the following news posts:

http://www.deja.com/=dnt_mn/getdoc.xp?AN=431075526&fmt=text
http://www.deja.com/=dnt_mn/getdoc.xp?AN=415562952&fmt=text

They say that the Perl distributed with RedHat 5.2 was not an official
release, and had several problems. I have some corroboration of this, because
I found RedHat 5.2 users needed to install a newer version of the IO module to
fix another problem. Is there a more official statement about problems with
this version of Perl?

Upon further inspection, it looks like a problem with the aliasing of the
"dprint" function. Below is a short script that exhibits the problem.

----snip----------
use constant DEBUG => 1;

sub dprint
{
  return unless DEBUG;
  print join '',@_;
  return 1;
}

dprint "Called dprint in main\n";

# ------------------------------------------------------------------------------

package Test;

use constant DEBUG => main::DEBUG;

sub dprint;
*dprint = \&main::dprint;

main::dprint "Called main::dprint from Test\n";
dprint "Called dprint from Test\n";
----snip----------

The output on RedHat 5.2 is:
Called dprint in main
Called main::dprint from Test
Undefined subroutine &main::-1 called at aaa.pl line 22.

I'm guessing that the only answer is to have RedHat 5.2 folks downgrade to Perl
5.004, which came with RedHat 5.1, or upgrade to Perl 5.00503, which came with
RedHat 6.0. However, I'd rather be able to tell people to just install a newer
module. Any advice?

Thanks!
David

_________________________________________________________________________
David Coppit - Graduate Student        david@coppit.org      
The University of Virginia             http://coppit.org/
    "Yes," said Piglet, "Rabbit has Brain." There was a long silence.
"I suppose," said Pooh, "that that's why he never understands anything."



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

Date: Wed, 11 Aug 1999 16:55:05 -0400
From: jerrad pierce <jerrad@networkengines.com>
Subject: HTTP & sockets on win32
Message-Id: <37B1E329.F3D9B6C3@networkengines.com>

Okay, so I'm using the code below (essentially ripped straight from O'reilly) to get a doc. It flies on UN*X boxes. But on win32 it crawls.
It takes about a minute for the document to come through when hitting against an apache server, and several minutes when hitting against IIS.
Any ideas what's up? How to speed it up?

PS> Please (b) cc me with any replies as well. My ISP doesn't keep articles for very long

    my $hostname = "127.0.0.1";
    my $port     = 80;
    my $file     = "/";
    ($sockaddr,$there,$response,$tries) = ("Snc4x8");
    $there = pack($sockaddr,2,$port, &getaddress($hostname));
    ($a, $b, $c, $d) = unpack('C4', $hostaddr);
    
    $proto = (getprotobyname ('tcp'))[2];
    
    if (!socket(S,AF_INET,SOCK_STREAM,$proto)) { die "$0:  Fatal Error.  $!\n"; }
    if (!connect(S,$there)) { die "$0:  Fatal Error.  $!\n"; }
    select(S);$|=1;
    select(STDOUT);
    print S "GET $file HTTP/1.1\n";
    print S "Host: $hostname\n\n";
    $header=0;
    while(<S>) {
	chomp $line;
	s%\r%%;
	if( s%^$%%  ){ $header=1; next; }
	if( $header ){ $OUT[$i++] = $_; }
    }
    close(S);
    return @OUT;


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

Date: Wed, 11 Aug 1999 16:38:22 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: I guess this is a Misc question: Cgi-bin
Message-Id: <1dwdoue.12dabb2lpfuchN@roxboro0-0014.dyn.interpath.net>

Ben Quick <newsgroup@bigwig.net> wrote:

> I R A Darth Aggie wrote in message ...
>
> >Why should any given person on this group be expected to know the answer
> >to a unix file permissions question?
> 
> Because any scripts would have to be given permissioons, to be fair

I run most of my scripts under MacOS 8.6.  For some reason I don't
*have* to give them unix file permissions, and am rather weak on unix
file permissions in general.

I wonder why this might be....

-- 
John Moreno


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

Date: Wed, 11 Aug 1999 16:38:26 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: I guess this is a Misc question: Cgi-bin
Message-Id: <1dwdp0s.171lqvkbu1k7jN@roxboro0-0014.dyn.interpath.net>

Ben Quick <newsgroup@bigwig.net> wrote:

> David H. Adler wrote in message ...
-snip-
> >And, had you actually asked a question that was appropriate for this
> >forum (and indicated that you had tried to find the answer yourself),
> >you probably would have gotten an answer easily.
> >
> >If you wind up going to one of the cgi groups with this question, I
> >suggest you read their faqs first...
> 
> Fair points, but wouldn't it have been easier if I was given polite
> responses like
> "I'm sorry, I don't know the answer. But ou're in the wrong group really,
> try asking in...."
> or
> "The answer is.... but really this is the wrong group. In future for this
> type of question try asking in...."

Several reasons listed in no particular order.

Asking off topic questions in the first place is frequently considered
rude -- the faqs and other documents are quite clear on what is
appropriate.

This and other off topic questions have been asked before and people are
tired of dealing with them and so are easily annoyed (which goes back to
the first reason because asking the question in the first place is
considered rude).

Lots of people feel that such answers encourage people to post off topic
questions here "well, I got an answer last time", "Joe User got a good
answer about the best place to buy sports equipment, someone told him
where he could get soccer balls for 80% off, and Joe said he bought 5, I
think I'll ask about how to rebuild my carburetor".

Here's a general usenet hint -- when you say something in any new (to
you) newsgroup and have one or more people point out that your post is
off topic or otherwise inappropriate the CORRECT response is to
apologize -- you may if you wish ask for direction to a more appropriate
group, but you don't argue about it.

If someone says you should have included a joke, then fine you should
have included a joke, quoting at the bottom instead of at the top (or
even vice versa), including or not including a Cc -- it doesn't matter,
when a regular tells you that the convention is to do X, then you do X
or go elsewhere.  You don't say that Y is better or that everyone should
know the answer and it wouldn't hurt them to help you  -- you say
"sorry" and then try to get along.

(This is one of the things that puzzle me about this phenomena in
general and not just Ben's response in particular -- is the world filled
with people that can't admit they were wrong and then get on with life?
I don't know how many times I've seen someone point out that the quoting
was backassword or the message was off topic and the person respond with
the quip "Are you the moderator?  If not then buzz off and mind your own
business" [a recent variation was "Do you own the NG??"]).

-- 
John Moreno


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

Date: Wed, 11 Aug 1999 21:30:23 +0100
From: "Troy Knight" <flexit@flexit.eurobell.co.uk>
Subject: lock_nb
Message-Id: <7osmcj$12fh$1@slrn.eurobell.net>

I have read the faq's and docs but still don't exactly understand lock_nb.
What does it do?, What is the syntax for it? and Do you use after or before
flocking with lock_sh/lock_ex or with?

Troy




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

Date: Wed, 11 Aug 1999 13:45:35 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Jody Fedor <JFedor@datacom-css.com>
Subject: Re: Looking for Reviews - Perl
Message-Id: <37B1E0EF.A6AA5DB1@mail.cor.epa.gov>

Jody Fedor wrote:
> 
> Attn: Perl Hackers.....
> 
> I'm looking for book reviews on all O'Reilly books.  Author Comments are
> invited too!
> 
> Author Comments to:  authors@datacom-css.com
> Reviewers to: review@datacom-css.com

Have you contacted Tom Christiansen for permission to point
at his reviews of O'Reilly books?  How about Jon Orwant for
permission on the reviews which have appeared in TPJ?

> Our Everything Perl Section is up (sans shopping cart at this time) at:
> 
> http://www.datacom-css.com/books/perl.htm

I hope it's not *everything* Perl.  I wouldn't want to find
"Perl for Dummies" there.  :-)

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 11 Aug 1999 20:21:13 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Mini-objects
Message-Id: <ZWks3.1300$J72.203502@news.itd.umich.edu>

In article <37B15544.1CD4663E@Mark.Com>, Mark  <Mark@Mark.Com> wrote:
>Sean McAfee wrote:
>> my $sth = prepare $dbh "select ... from ...";
>> execute $sth;
>> while ($row = fetch $sth) { ... }

>> ...not too bad, really, but I thought it would be better to factor out the
>> common "prepare $dbh" and "execute" code and simply pass a SQL query to a
>> function which would return a cursor-like object.

>The problem with packaging DBI methods is error checking. This is made more
>difficult by putting the prepare/execute/fetch in a single function. In many
>cases, you want to do specific things on failures of prepare or execute.

Yes, my approach isn't suitable for all cases, but for my current application
I depend on setting $dbh->{RaiseError} to make errors fatal.  There's one
place in my code where I do a

    local @$dbh{'PrintError', 'RaiseError'} = (0, 0);

 ...but this is in a routine that only inserts new rows, and doesn't do any
queries.

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: Wed, 11 Aug 1999 16:38:28 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: Nicer Way
Message-Id: <1dwdr2s.hb3dwlyup2ntN@roxboro0-0014.dyn.interpath.net>

Scott Beck <admin@gatewaysolutions.net> wrote:

> Mabe there is somthing wrong with the way Outlook Exp. is reading the Mime
> Type.

Yes, this is a known problem with OE (although I thought it was confined
to // being the first two characters -- my mistake), but OE isn't
misreading the file MIME type because there isn't one.

> What program are you using and where can I get a copy. I've been looking for
> somthing to replace Outlook!

Anno is mostlikely using trn, which you'd probably have trouble using.
I suggest going to <http://www.newsreaders.com/win/clients.html> and
looking around (I suggest looking at Xnews, Gravity, and Forte Agent).

-- 
John Moreno


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

Date: Wed, 11 Aug 1999 21:19:20 +0100
From: "Waiman Mak" <w.mak@cwcom.net>
Subject: Perl Novice needs advice
Message-Id: <BWks3.3341$Yu4.120917@news2-hme0.mcmail.com>

Dear all,
Is it possible to configure my own PC as a WEB server so that I can create
and test my own CGI/Perl scripts? I would like to move over to more
technical WEB development, rather than just front end WEB (graphical/static
HTML) development, but I can't do this without having a server to test
anything on.


I'm not a regular on this NG so any information would be more appreciated if
sent to my e-mail address: w.mak@cwcom.net

Thank you.

Waiman.




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

Date: Wed, 11 Aug 1999 17:02:27 -0400
From: jerrad pierce <jerrad@networkengines.com>
Subject: Re: Perl Novice needs advice
Message-Id: <37B1E4E3.A9BADD27@networkengines.com>

Geta apche from http://www.apache.org

Waiman Mak wrote:
> 
> Dear all,
> Is it possible to configure my own PC as a WEB server so that I can create
> and test my own CGI/Perl scripts? I would like to move over to more
> technical WEB development, rather than just front end WEB (graphical/static
> HTML) development, but I can't do this without having a server to test
> anything on.
> 
> I'm not a regular on this NG so any information would be more appreciated if
> sent to my e-mail address: w.mak@cwcom.net
> 
> Thank you.
> 
> Waiman.


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

Date: 11 Aug 1999 20:54:28 GMT
From: "Bart Simpson" <phony@nospam.com>
Subject: Re: Perl Question - NOT !
Message-Id: <7osnu4$ogu$0@216.39.133.25>

He wants to have the from field show a name, but no email address. Isn't
that something a spammer would want to do, so nobody could reply to the
email???

Does it sound he's making a program to spam people? It would be ironic if
your mailbox filled with spam because you helped him write the program.

Hahahaha, oops, I laughed so hard I knocked my stack of AOL disks over.


Michel Dalle <michel.dalle@usa.net> wrote in message
news:7orvna$t02$1@news.mch.sbs.de...
> In article <7oqcg1$572$1@nnrp1.deja.com>, jsmith19991@my-deja.com wrote:
> >I'm having a problem with a perl script. The problem
> >we are having is with the E-mailing of information to a
> >client. To make it simple, the scriptsends an Email to
> >someone after they enter their address (Mary Smith in
> >the following example). The script includes the following
> >lines for sending the mail:
> [ploink?]
>
> This question has already been answered elsewhere.
> You need to give a fully-qualified e-mail address to
> sendmail, like jsmith19991@my-deja.com, rather than
> just 'John'.
>
> Michel.
>
> Sent to Deja.com http://www.deja.com/
> Learn that you can't share what you don't know.




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

Date: Wed, 11 Aug 1999 16:38:30 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: pricing a perl job
Message-Id: <1dwdrsw.1kfhjsr1g9q87uN@roxboro0-0014.dyn.interpath.net>

brian d foy <brian@pm.org> wrote:

> Max Pinton <max@maxgraphic.com> posted:
> 
> > and would like to charge her fairly for the work I did.
> 
> my post was completely serious.  pricing has nothing to do with the
> Perl language.

No problem with this -- he deserved a bit of a flame.

>  it has to do with what your time is worth and how much
> the client will pay, not what you do during the time that you spend
> working on the project.  that's how it works in the real world.

This I take exception to -- there are people that are willing to do some
work on the basis of what they think is a "fair price to the customer"
regardless of the actual cost to them in time and effort.

I've done work where I'd never charge so little on an hourly basis, but
was willing to do a particular job and charge what I thought was a fair
price (i.e. what it would have cost them to have someone more
experienced at it do) simply for good relations or because I wanted to
learn how and this seemed like an equitable way of doing so; I recoup
some of my time in money, they get a product that was just as good
without having to go to the effort (and risk) of getting someone more
experienced, but less trusted, to do it.

In any case, a better formation of his question would be:

"Assuming that for *some reason you didn't want to do it yourself, what
kind of price range would you be looking for when having someone else do
it?"

*promises to the wife, oaths to the elder gods, busy dodging assassins
bullets, leaving on trip to Club Med, whatever.

-- 
John Moreno


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

Date: Wed, 11 Aug 1999 13:30:49 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: printf problem - Left-Justifying Floats
Message-Id: <37B1DD79.7D73FE87@mail.cor.epa.gov>

Tom Briles wrote:
[snip]
> acme$ perl -e 'printf "|%-10.4f|\n",0;'
> |0.0000    |
> acme$ perl -v
[snip]
> acme$

So.  I've always wondered who was responsible for all that
shoddy merchandise the coyote kept buying.  Now I know.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 11 Aug 1999 15:46:06 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: printf problem - Left-Justifying Floats
Message-Id: <37B1E10E.755E5444@texas.net>

David Cassell wrote:
> 
> Tom Briles wrote:
> [snip]
> > acme$ perl -e 'printf "|%-10.4f|\n",0;'
> > |0.0000    |
> > acme$ perl -v
> [snip]
> > acme$
> 
> So.  I've always wondered who was responsible for all that
> shoddy merchandise the coyote kept buying.  Now I know.
> 

On the contrary, our merchandise is top-notch.  It's the lusers who
screw it up.

- Tom


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

Date: Wed, 11 Aug 1999 20:41:27 GMT
From: genelong@my-deja.com
Subject: Re: Problem reading forms with perl
Message-Id: <7osn5m$pup$1@nnrp1.deja.com>

In article <slrn7qv94v.ahe.abigail@alexandra.delanet.com>,
  abigail@delanet.com wrote:
> genelong@my-deja.com (genelong@my-deja.com) wrote on MMCLXIX September
> MCMXCIII in <URL:news:7oned1$16n$1@nnrp1.deja.com>:
> -- Thanks to all for your patience with a unix-challenged windows
> -- programmer.  Some more questions:
> --
> -- I went to activestate.com, and there are a lot of things to
download.
> -- Which one(s) do I need?
>
> Last time I looked, it was explained.

Maybe it's clear to you, Abigail, but not to me.  There is a PDK, a
PerlDirect, a Perl Development Kit, a Perl Resource Kit, and other
things.  I tried PerlEx for Win32, but that turned out to be for a
server, not for a workstation.  I will try downloading other things,
but I am still shooting in the dark.
>
> -- Is the "standard distribution" basically a perl compiler?  Why
would I
> -- want to compile my perl when the server interprets the source?  Or
is
> -- it just for documentation purposes?
>
> No, and the documentation isn't their for the compilers purpose
either.
> RTFM.

Give me a break, Abigail.  I DON'T HAVE A MANUAL.  I'm trying to get
one.  I never heard of the "standard distribution" until a few days ago
on this list.

> -- There seems to be a huge communication gap between unix and windows
> -- programmers.  Where do people enter commands such as perldoc (or
> -- whatever it was) in Windows?  Windows consists of icons and
screens,
> -- not command lines.  The only way I know of entering commands is
opening
> -- a DOS window, and I would think DOS has nothing to do with perl.
>
> Well, if you think Windows consists of icons and screen, please do
tell
> me, how do you expect to use Perl? By clicking on icons?
>

I already use Perl.  I edit it with a text editor and ftp it out to my
web site in the cgi-bin directory, and it runs fine when I access my
web page.  I don't need command lines to run perl.

I don't know about your windows, but mine *does* consist of icons and
screens.  Where do you enter line commands?  In DOS?

> -- I am glad to get a hold of all these resources to enhance my
knowledge
> -- of perl, but I also feel I am buying a car when all I want to do
is go
> -- to the house next door.
>
> Noone is forcing you to use Perl. If you don't need it, don't use it.
> If you don't know whether you need it, shouldn't you feel more like
> you are buying a car when all you want to do is go to the house next
> door, but you don't know where that house is?
>
Gee, you're in a bad mood today.  Of course I need perl (the language)
or I wouldn't be here.  I'm not sure I need perl (the compiler) since I
have run fine without it up to now.

> --                          Is all this really necessary to read angle
> -- brackets from a form?
>
> What the fsck is reading angle brackets from a form?

These are angle brackets:  < >

This is a form:

<form action="http://www.domain.com/cgi-bin/edit.pl" method="POST">
<textarea name="text" rows="20" cols="72">

This is perl:

$text = $FORM{'text'};

When I enter xxx<yyy>zzz on the form, $text gets xxxzzz as its value.

Everything else works fine, I just lose the text between the angle
brackets.
>
> --                        I see forms all the time that let users
enter
> -- addresses such as "joe <joe@domain.com>".  How do those forms get
the
> -- input into some place where it can be manipulated?
>
> That's a question that has nothing to do with Perl. Unless you write
> a browser in Perl.

I don't understand your comment at all.

> --                                                     I will be glad
to
> -- learn all these things, but if someone could hand me a line of code
> -- that would do the trick, I would be greatly appreciative.  It just
> -- can't be that hard.
>
> I've a strong impression you don't know what you are talking about. Or
> perhaps you do, but then you express that real awkwardly.
>
Give me a break.  I said I'm a newbie.  I'm a windows programmer, not a
unix guru.  I think I've done damn good building a web site from
scratch when all I knew was C++ to start with.  I'm humbly asking for
help, cause it's a big world out there, and I've only started to
scratch the surface.  If you don't want to help, Abigale, just ignore
my messages.

Gene


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


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

Date: Wed, 11 Aug 1999 20:42:17 GMT
From: support@gethits.com
Subject: Problem using last with a label
Message-Id: <37B1E1B4.2C409E3E@gethits.com>

I'm trying to check a flatfile database to make sure the
same email doesnt get placed twice. If an identical email
is found, I want to exit the foreach loop for efficiency;
however, before $emailcheck can be assigned a value, last
is executed prematurely (I assume). If the last function is
removed, the value is assigned and the loop will continue 
checking records. What's going on?? Code below. Thanks.

Darryl Dyck
GetHits.com

if ($usedb eq '1') {
   ($day, $month, $year) = (localtime)[3,4,5];
   $file = $month+1 . "-$day.txt";

LINE:  open (EMAILCHECK, "dbtst/$file") || die "cant open: $!\n";
          foreach $record (<EMAILCHECK>) {
             if ($record =~ /^$email\|/) {
             $emailcheck = 1;
             last LINE;
             }
       }
  close (EMAILCHECK);

   if ($emailcheck != 1) {
     open (EMAILDB, ">>dbtst/$file") || die "cant open: $!\n";
       print EMAILDB "$email|$url|$title|";
       printf EMAILDB ("%02d-%02d-%04d", $month+1, $day, $year+1900);
       print EMAILDB "\n";
     close (EMAILDB);
   }
}


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

Date: Wed, 11 Aug 1999 11:28:18 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Re(2): NO-ONE USES PERLQT !!!!!!!!!!!!!!!!!!!!!?????????????????????????
Message-Id: <iq4so7.hgp.ln@magna.metronet.com>


[ stealth Ccs are evil! ]


Thomas M. Schmickl (schmickl@magnet.at) wrote:
: tadmc@metronet.com writes:
: >   It has nothing to do with Perl.


   That was a private email.

   I did not give you permission to post it.

   It is _very_ bad manners to post private email publically.

   Please don't do that anymore.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 11 Aug 1999 21:00:19 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: reference to object method
Message-Id: <7oso93$ni0$1@info2.uah.edu>

In article <7osjv5$n30$1@towncrier.cc.monash.edu.au>,
	damian@cs.monash.edu.au (Damian Conway) writes:

: Actually, I see the existence of &can as a good reason why symbolic
: method calls *ought* to provoke use strict's wrath. Since there's a
: safe way to convert a method name to a method reference:
: 
: 	$methodref = $obj->can($methodname);
: 	$obj->$methodref();
: 
: the "unsafe" (or perhaps "unintentional") way:
: 
: 	$obj->$methodname();
: 
: ought to be flagged.

C<use strict 'methods'> anyone?  Breakage bad, progress good.

Greg
-- 
God created man.  Sam Colt made all men equal.
    -- Jim Farmer


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

Date: Wed, 11 Aug 1999 13:29:26 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Run a script from a web browser and put it in the background
Message-Id: <37B1DD26.3F92DF14@mail.cor.epa.gov>

Guideline Chan wrote:
> 
> I want to run a script from a web browser. This script may take 5
> minutes to process such as gzip a file. So put this in the background is
> preferrable and display the result to the client after finishing.
> However the problem is that a web browser is still loading.
> 
> How can I stop the browser loading but process the progress in the
> background and put the result back to the client after finishing ???

This is really a CGI issue, and as such you'll probably have
better luck asking this in a newsgroup such as
comp.infosystems.www.authoring.cgi .

As a Perl programming problem, I would fork() off a child
process to do the long bit, closing STDOUT so it wouldn't hang
up the browser window, and continue on with the CGI script in
the parent process.  Communicating with the parent to notify
about the gzip process is an exercise left to the reader who
has first read the perlipc page in the docs.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 11 Aug 1999 21:31:59 +0100
From: "Troy Knight" <flexit@flexit.eurobell.co.uk>
Subject: Sesssion ID
Message-Id: <7osmfg$12fk$1@slrn.eurobell.net>

Okay, I want to write a login program which asks for a login name and
password and then keeps track of which user is using the script, someone
told me to use session id's. I have been looking on the net for ages but
can't find info on what session id's are and how to use them. Can anyone
help?

Troy




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

Date: Wed, 11 Aug 1999 16:05:39 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: working with imagery
Message-Id: <37B1D793.4B05105B@ccrs.nrcanDOTgc.ca>

Hi,

Does anyone have any info, links, etc. on using Perl for images
(properties, cell values, etc.)?

Thanks

 ..Tom
-- 

-----------------------------------------------------------------------------------------
Tom Kralidis                                  Geo-Spatial Technologist 
Canada Centre for Remote Sensing              Tel: (613) 947-1828
588 Booth Street , Room 241                   Fax: (613) 947-1408
Ottawa , Ontario K1A 0Y7                     http://www.ccrs.nrcan.gc.ca
-----------------------------------------------------------------------------------------


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

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


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