Plz help - Perl Q 
Author Message
 Plz help - Perl Q

Hi folks,
    I have a Perl question & have read many many FAQs, books, web sites (TY
Godzilla), newsgroups, etc. I have almost got it, but am missing the last
piece.
    My question is: If I have to lock more than 1 file in a script, should I
undefine $OFH after each use? Or maybe use a different scalar designator for
the flush each use? Or do I need to only flush once per script?
    Below is the code I am using.
        Thanks a million!!!
            Michael

Fcntl qw(:DEFAULT :flock);
open (MEMBERS, "db/members") or die("Unable to open db/members: $!");
$OFH=select(MEMBERS); $| = 1; select($OFH);
flock(MEMBERS, LOCK_EX) or die "can't write-lock db/members: $!";
while ($line=<MEMBERS>)
{
  chomp $line;

  $userexists=$line[0];
  if ( ($userexists) eq ($regdata{"Pool Number"}) )
  {
    $rawinfo=$exists;
  }

Quote:
}

close (MEMBERS);

--
== CigarPool ==
http://www.*-*-*.com/

== CigarPool ==
http://www.*-*-*.com/

--
== CigarPool ==
http://www.*-*-*.com/



Wed, 18 Jun 1902 08:00:00 GMT  
 Plz help - Perl Q

Quote:


> > I have a Perl question & have read many many FAQs, books, web
> > sites (TY Godzilla), newsgroups, etc. I have almost got it, but am
> you have a major mistake listed there. you accepted help from
> moronzilla. you have to be decontaminated before any regulars can help
> you. any help you got from her is wrong and useless.

Your claiming Perl Online Documentation to be
wrong and useless does help to explain why you
know so little about Perl and Perl Programming.

Godzilla!



Wed, 18 Jun 1902 08:00:00 GMT  
 Plz help - Perl Q

  MC>     I have a Perl question & have read many many FAQs, books, web
  MC> sites (TY Godzilla), newsgroups, etc. I have almost got it, but am

you have a major mistake listed there. you accepted help from
moronzilla. you have to be decontaminated before any regulars can help
you. any help you got from her is wrong and useless.

uri

--

SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com



Tue, 01 Apr 2003 13:13:05 GMT  
 Plz help - Perl Q

Quote:

>    My question is: If I have to lock more than 1 file in a script, should I
>undefine $OFH after each use? Or maybe use a different scalar designator for
>the flush each use? Or do I need to only flush once per script?
>$OFH=select(MEMBERS); $| = 1; select($OFH);

$OFH is only used to temporarily store the current handle. There's no
reason not to reuse this variable for other purposes. Well, personally,
I would make it a localized variable:

        {
            my $ofh = select MEMBERS;
            $| = 1;
            select $ofh;
        }

But, coming back to this:

Quote:
>If I have to lock more than 1 file in a script

At the same time? Be careful for avoiding deadlock. If program A grabs X
and then Y, and program B grabs Y and then X, well, if this happens
simulataniously, and A has X and B has Y, they'll wait for each other
forever. That is called "deadlock". But actually, that's not a Perl
specific problem.

--
        Bart.



Wed, 18 Jun 1902 08:00:00 GMT  
 Plz help - Perl Q



  >> > I have a Perl question & have read many many FAQs, books, web
  >> > sites (TY Godzilla), newsgroups, etc. I have almost got it, but am

  >> you have a major mistake listed there. you accepted help from
  >> moronzilla. you have to be decontaminated before any regulars can help
  >> you. any help you got from her is wrong and useless.

  G> Your claiming Perl Online Documentation to be
  G> wrong and useless does help to explain why you
  G> know so little about Perl and Perl Programming.

no, i am claiming and proclaiming with complete acclaim from this group
that anything you say is tainted by your delusional psychosis. even if
you happen to point someone to a correct source for an answer doesn't
mean anything since a stopped clock is right twice a day. you could be
shooting darts at perldoc and sometime hit the target. that doesn't mean
you know anything.

as for my perl skills, your statement doesn't seem to carry any weight
here (other than your nutty baggage). i leave it to the group to decide
if my posts are worthy to read. other than you, i don't seem to get many
negative flames about them. hmmm, could it be that i have bribed
everyone here? or could it be that you are a frigging idjit?

uri

--

SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com



Wed, 18 Jun 1902 08:00:00 GMT  
 Plz help - Perl Q
Uri Guttman scribbled with a Crayola crayon:

Quote:
> Godzilla! intelligently articulated:
> > Uri Guttman suffered verbal diarrhea:

> > > > I have a Perl question & have read many many FAQs, books, web
> > > > sites (TY Godzilla), newsgroups, etc. I have almost got it, but am
> > > you have a major mistake listed there. you accepted help from
> > > moronzilla. you have to be decontaminated before any regulars can help
> > > you. any help you got from her is wrong and useless.
> > Your claiming Perl Online Documentation to be
> > wrong and useless does help to explain why you
> > know so little about Perl and Perl Programming.
> no, i am claiming and proclaiming with complete acclaim from this group
> that anything you say is tainted by your delusional psychosis. even if
> you happen to point someone to a correct source for an answer doesn't
> mean anything since a stopped clock is right twice a day. you could be
> shooting darts at perldoc and sometime hit the target. that doesn't mean
> you know anything.
> as for my perl skills, your statement doesn't seem to carry any weight
> here (other than your nutty baggage). i leave it to the group to decide
> if my posts are worthy to read. other than you, i don't seem to get many
> negative flames about them. hmmm, could it be that i have bribed
> everyone here? or could it be that you are a frigging idjit?

There is no doubt all readers of this newsgroup view
you as an appointed and anointed Godsend savior of
all Techno-Geeksters.

Godzilla!
--
Dr. Kiralynne Schilitubi | Cooling Fan Specialist
UofD: University of Duh! | ENIAC Hard Wiring Pro
BumScrew, South of Egypt | HTML Programming Class



Wed, 18 Jun 1902 08:00:00 GMT  
 Plz help - Perl Q

  G> There is no doubt all readers of this newsgroup view
  G> you as an appointed and anointed Godsend savior of
  G> all Techno-Geeksters.

that is the first honest and truthful statement you have ever made
here. congratulations! now that you have done that, you can leave this
group in peace. go learn python. they have no modules so you can live in
their little world. they will love you. or even better, learn C# and
plague redmond. that'll teach them a lesson!

uri

--

SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com



Wed, 18 Jun 1902 08:00:00 GMT  
 Plz help - Perl Q
Thanks for the tips Bart!!!
I don't have 2 open at the same time. I open one, read some stuff, then
close it, then open another & write to it based on the info from the first.
Should I redefine $OFH between these, use another variable, or do I only
need to flush it once for the whole script?
    Thanks!
        Michael
--
== CigarPool ==
http://www.cigarpool.com


Quote:

> >    My question is: If I have to lock more than 1 file in a script,
should I
> >undefine $OFH after each use? Or maybe use a different scalar designator
for
> >the flush each use? Or do I need to only flush once per script?

> >$OFH=select(MEMBERS); $| = 1; select($OFH);

> $OFH is only used to temporarily store the current handle. There's no
> reason not to reuse this variable for other purposes. Well, personally,
> I would make it a localized variable:

> {
>     my $ofh = select MEMBERS;
>     $| = 1;
>     select $ofh;
> }

> But, coming back to this:

> >If I have to lock more than 1 file in a script

> At the same time? Be careful for avoiding deadlock. If program A grabs X
> and then Y, and program B grabs Y and then X, well, if this happens
> simulataniously, and A has X and B has Y, they'll wait for each other
> forever. That is called "deadlock". But actually, that's not a Perl
> specific problem.

> --
> Bart.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. perl questions-urgent plz help

2. plz help about using DLL w/ perl

3. Perl for Windows - Plz somebody help...

4. plz help me on perl-tk

5. DBM question plz help

6. Plz help: Modifying server-side text files

7. Problems with pattern matching plz help.

8. Newbie matching problem- plz help

9. NET::POP3 Help plz

10. Urgent Help Req. Plz

11. Plz help a newbie add up elements of an array

12. PLZ HELP

 

 
Powered by phpBB® Forum Software