[16377] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3789 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 24 18:15:38 2000

Date: Mon, 24 Jul 2000 15:15:25 -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: <964476925-v9-i3789@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 24 Jul 2000     Volume: 9 Number: 3789

Today's topics:
        sort with use strict <noemail@noemail.com>
    Re: sort with use strict <uri@sysarch.com>
    Re: sort with use strict (Tad McClellan)
        String Interpolation of Typeglobs <rawizza@ll.mit.edu>
    Re: String Interpolation of Typeglobs <aqumsieh@hyperchip.com>
        StudlyCaps (was: HELP: longSyntax ok, but: rHsh->{myKey <iltzu@sci.invalid>
    Re: Threading and ActiveState Perl 616 on Win32 <dan@tuatha.sidhe.org>
        user entered IP or Domain ? <coy@coystoys.com>
        Why use anonymous? ()
    Re: Why use anonymous? (Mads Orbesen Troest)
    Re: Why use anonymous? <jbc@west.net>
    Re: Why use anonymous? (Mads Orbesen Troest)
    Re: Why won't  "use strict;"  work?(Gozilla) (BUCK NAKED1)
    Re: Why won't  "use strict;"  work?(Gozilla) <godzilla@stomp.stomp.tokyo>
    Re: Why won't  "use strict;"  work? (BUCK NAKED1)
    Re: Why won't  "use strict;"  work? (Tad McClellan)
    Re: Why won't  "use strict;"  work? (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 24 Jul 2000 16:48:55 -0400
From: Young <noemail@noemail.com>
Subject: sort with use strict
Message-Id: <397CABB7.4FACCF94@noemail.com>

Hi,

How come I don't need to declare $a and $b with the following line, when
I use strict? How come I get an error if I do declare those variables?

@rows = sort { ($a->[0] cmp $b->[0]) || ($a->[1] <=> $b->[1]) ||
($a->[2] <=> $b->[2])} @rows;

It sorts properly.

I've seen in a book that I'm supposed to use $::a->[0], etc., except the
example was with associative arrays. I tried using $::a->[0], etc. in
one attempt, and sorting did not occur at all. In some shorter code, I
tried the same thing, and it did sort anyway. I'm confused! Can anyone
explain?

Thanks a lot!



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

Date: Mon, 24 Jul 2000 21:02:18 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: sort with use strict
Message-Id: <x7d7k39r8m.fsf@home.sysarch.com>

>>>>> "Y" == Young  <noemail@noemail.com> writes:

  Y> How come I don't need to declare $a and $b with the following line, when
  Y> I use strict? How come I get an error if I do declare those variables?

$a and $b are allowed to be used without declarations even under use
strict. thisis just because of the way they are used in sort. 

  Y> I've seen in a book that I'm supposed to use $::a->[0], etc., except the
  Y> example was with associative arrays. I tried using $::a->[0], etc. in
  Y> one attempt, and sorting did not occur at all. In some shorter code, I
  Y> tried the same thing, and it did sort anyway. I'm confused! Can anyone
  Y> explain?

$a is always in package main (or :: by itself) so using $::a is no
different but may fix a case where you did declare a private version of
$a with my.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
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


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

Date: Mon, 24 Jul 2000 16:26:23 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: sort with use strict
Message-Id: <slrn8np9jf.9lh.tadmc@magna.metronet.com>

On Mon, 24 Jul 2000 16:48:55 -0400, Young <noemail@noemail.com> wrote:

>How come I don't need to declare $a and $b with the following line, when
>I use strict? 


Because they get a special exception from strictures.

It is ugly, but necesary to get reasonable sorting speed.


>How come I get an error if I do declare those variables?


I dunno. It depends on _where_ you declare them, and you 
have not shown the declaration you tried, nor its context.



>@rows = sort { ($a->[0] cmp $b->[0]) || ($a->[1] <=> $b->[1]) ||
>($a->[2] <=> $b->[2])} @rows;


So @rows is a LoL then?


>It sorts properly.


Then it must be a LoL.


>I've seen in a book that I'm supposed to use $::a->[0], etc., except the
>example was with associative arrays. 


First, be very suspicious of any book that calls them "associative arrays".

They have been called "hashes" for 5 years now.

Is your book 5 years old?

Second, there are no hashes involved with that code snippet!

Hashes use {curly braces}, and there aren't any of those there...



Do not declare $a and $b and it should be fine.


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


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

Date: Mon, 24 Jul 2000 14:19:53 -0400
From: Mark Rawizza <rawizza@ll.mit.edu>
Subject: String Interpolation of Typeglobs
Message-Id: <397C88C8.62C4E773@ll.mit.edu>

I was trying examples from "Advanced Perl Programming" (p. 42) and found
what seems to be a bug with interpolating typeglobs in a string.

1:  @spud = ("idaho", "russet");
2:  *potato = *spud;
3:  print "@potato\n";

This will return the following:

==> In string, @potato now must be written as \@potato at try.pl line 3,
near "@potato"
==> Execution of try.pl aborted due to compilation errors.

Is this a bug?  I ran this on an SGI IRIX 6.5 and under LINUX and got
the same result.  I was running perl version 5.005_03 on both machines.
Of course, => print "@spud\n"; <=  prints out what you would expect.

Mark Rawizza
rawizza@LL.mit.edu




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

Date: Mon, 24 Jul 2000 18:57:18 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: String Interpolation of Typeglobs
Message-Id: <7awvibgxv3.fsf@merlin.hyperchip.com>


Mark Rawizza <rawizza@ll.mit.edu> writes:

> I was trying examples from "Advanced Perl Programming" (p. 42) and found
> what seems to be a bug with interpolating typeglobs in a string.
> 
> 1:  @spud = ("idaho", "russet");
> 2:  *potato = *spud;
> 3:  print "@potato\n";
> 
> This will return the following:
> 
> ==> In string, @potato now must be written as \@potato at try.pl line 3,
> near "@potato"
> ==> Execution of try.pl aborted due to compilation errors.
> 
> Is this a bug?  I ran this on an SGI IRIX 6.5 and under LINUX and got
> the same result.  I was running perl version 5.005_03 on both machines.
> Of course, => print "@spud\n"; <=  prints out what you would expect.

Looks like a bug to me.
The following works as expected:

	@spud = ("idaho", "russet");
	*potato = *spud;
	print for @potato;
	__END__
	idaho
	russet

--Ala


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

Date: 24 Jul 2000 19:58:29 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: StudlyCaps (was: HELP: longSyntax ok, but: rHsh->{myKey} UNDEFINED??)
Message-Id: <964468082.22537@itz.pp.sci.fi>

In article <8li2os$hmo$2@slb1.atl.mindspring.net>, David Combs wrote:
>I do not understand this perl-people's "religious" commandment
>that "thou shall not mix cases in variable or sub names --
>      you shall instead use underlines".
>
>My reasons:
>
>. I like long names that fully describe what the variable is --
>   even VERY long names (30 chars and more).

Well, that is like saying: "I like swimming in freezing cold water."

There's absolutely nothing wrong with that, of course, if you really
do like it - thousands if not millions of Finns would agree with you.

You are, however, expected to stop before complaining of the cold.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Mon, 24 Jul 2000 18:42:38 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Threading and ActiveState Perl 616 on Win32
Message-Id: <y60f5.4648$f_5.22943@news1.rdc1.ct.home.com>

steve <SCook@pobox.com> wrote:
> Hi,

> I am trying to get the code from the Perl threading tutorial to run under
> win32 with active perl.  No matter what I do it will not work.  The
> thread.pm module has been included with active perl but it appears to be
> broken.  Yet reading their release notes it indicates that fork and
> threading now are supported on all platforms.  Is this wrong?? or is there
> some magic that will get active perl on win32 to thread?

Perl needs to be built with special flags set to enable the sort of
threading that the Thread module provides. Perl, as shipped by
ActiveState, doesn't have them set. It's also incompatible with the sort
of threading used to provide the fork emulation on windows.

					Dan


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

Date: Mon, 24 Jul 2000 21:05:26 GMT
From: "Coy" <coy@coystoys.com>
Subject: user entered IP or Domain ?
Message-Id: <qc2f5.9211$Mt.102121@nnrp1.ptd.net>

I'm looking for a simple way to tell if the user entered
an IP address, or a domain name.

example:
    ./program.pl 192.168.123.1
    or
    ./program.pl some.host.domain.com
    or
    ./program.pl host.domain.com

the host will not always have reverse dns,
so I can't check with inet_ntoa();

Is there an easy way of doing this ?
( i have a feeling that im looking right over the solution on this one :c/ )

- Coy




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

Date: 24 Jul 2000 17:51:50 GMT
From: awilcox@contract.East.Sun.COM ()
Subject: Why use anonymous?
Message-Id: <8lhvnm$l54$1@eastnews1.east.sun.com>


Hi all,
  I have been doing Perl for a long time (since ~1995) and
in that time, I have never found a need to use anonymous 
hashes/subroutines (were they even available in Perl 4?).
I had a job interview some time ago where a smarmy little
know-it-all, who's been Perl-ing for all of 6 months, quizzed
me on my Perl abilities.  He tried to stump me with regexes, 
but I had just finished a project where I had done a lot of
them, so no dice there :-)  So then, he dragged out these anonymous
hashes and such, which, to my knowledge, I have never needed or 
used, and thus said "Huh?".

He couldn't give me an answer as to why one would use these, so
I thought I'd pose the question to the Perl populace in general, since
this has been bugging me ever since (I decided not to work there, 
since the creep that interviewed me was as bad as his boss, who asked
me some funky puzzle thing about 5 pirates fighting over their
gold -- weird)  So, to recap, why would you use an anonymous hash or
subroutine, as opposed to their named counterparts?


Anita


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

Date: Mon, 24 Jul 2000 20:21:12 GMT
From: mads@troest.NEVERMORE.dk (Mads Orbesen Troest)
Subject: Re: Why use anonymous?
Message-Id: <k6fk2tedC4v7-pn2-x2MROdHTed2y@mads.lokal.net>

On Mon, 24 Jul 2000 17:51:50, awilcox@contract.East.Sun.COM () wrote:

> So, to recap, why would you use an anonymous hash or
> subroutine, as opposed to their named counterparts?

I use them quite often! 

Consider complex constructs like this:

 MySub( [ 'a', 'b', 'c' ], [ '1', '2', '3' ], { method=3D>'seek', 
range=3D>100 }, 'MyString' );

sub MySub()
{
 my( $pFirstArray, $pSecondArray, $pFirstHash, $Stringy ) =3D @_;
}

They are particularly, as implied by the above, used for creating 
complex structures; arrays of arrays of hashes, etc.

      ... /\/\\ads Orbesen Troest <mads@troest.NEVERMORE.dk>

(Please remove NEVERMORE from address when replying via email...)


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

Date: Mon, 24 Jul 2000 13:27:07 -0700
From: John Callender <jbc@west.net>
Subject: Re: Why use anonymous?
Message-Id: <397CA69B.A9495E2D@west.net>

awilcox@contract.East.Sun.COM wrote:
> 
> So, to recap, why would you use an anonymous hash or
> subroutine, as opposed to their named counterparts?

To build multilevel data structures? Anonymous hashes, at least,
tend to show up there a lot.

John


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

Date: Mon, 24 Jul 2000 20:29:06 GMT
From: mads@troest.NEVERMORE.dk (Mads Orbesen Troest)
Subject: Re: Why use anonymous?
Message-Id: <k6fk2tedC4v7-pn2-sR6d9Io4cy5x@mads.lokal.net>

On Mon, 24 Jul 2000 20:21:12, mads@troest.NEVERMORE.dk (Mads Orbesen 
Troest) wrote:

> They are particularly, as implied by the above, used for creating 
> complex structures; arrays of arrays of hashes, etc.

Forgot to give an example of that:

my $pSneakyArray =3D [ [ {first=3D>'hash'}, {second=3D>'hash'} ], 
[{third=3D>'hash'}, {fourth=3D>'hash'}] ];

This creates a reference to an array containing (references to) two 
arrays, each of which is containing two (references to) hashes.

      ... /\/\\ads Orbesen Troest <mads@troest.NEVERMORE.dk>

(Please remove NEVERMORE from address when replying via email...)


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

Date: Mon, 24 Jul 2000 12:54:01 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Why won't  "use strict;"  work?(Gozilla)
Message-Id: <18294-397C82B9-37@storefull-248.iap.bryant.webtv.net>

I am not jesting. If you want something, roll up your sleeves, get to
work and earn what you want. If you expect Life to be served on a Silver
Platter, go out and get a life. It doesn't work this way Buster. 
Unless you are mentally disabled, you have the same capacity to research
as any average person. I know this from direct experience teaching both
physically handicapped and mentally handicapped children over my many
years as a teacher. A physical disability doesn't wash with me when it
comes to intelligence. 
If you have researched Fcntl appropriately, you would not be here asking
this question. Disabled or not, you are mucking around in mule manure;
being deceitful. 
Godzilla!

I do not wish to start a flame war with you, but you are wrong in all of
your assumptions, including my disability, which I wish I had not
mentioned now. I have never been lazy in my life. If you don't want to
answer the question, then don't, but please don't throw out sarcastic
false accusations that do nothing to help.   Regards, Dennis



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

Date: Mon, 24 Jul 2000 11:31:08 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Why won't  "use strict;"  work?(Gozilla)
Message-Id: <397C8B6C.FDE262F7@stomp.stomp.tokyo>

BUCK NAKED1 wrote:

> I do not wish to start a flame war with you, 

(snipped)

Then why have you attempted to start a flame war?

If you are looking for a cat fight, you are
certainly a mule barking up the wrong tree.
I am not interested.

Meow....

Godzilla!

-- 
@© = (a .. z); @® = qw (7 15 4 26 9 12 12 1 18 15 3 11 19);
srand(time() ^ ($$ + ($$ << 15))); 
sub G { rand(1000) < 500 ? "\u$1" : "\l$1" ; }
foreach $¿ (@®) { $¢ = $©[$¿-1]; $¢ =~  s/([a-z])/G($1)/gie;
if ($¢ =~ /($©[0])/i) { $¢ = "$¢ "; } print $¢; }
print "!"; exit;


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

Date: Mon, 24 Jul 2000 13:46:47 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Why won't  "use strict;"  work?
Message-Id: <23637-397C8F17-49@storefull-242.iap.bryant.webtv.net>

>The proper sequence is: 
>>Open a file for read/write. 
>>Lock the file. 
>>Read the content. 
>>Seek to beginning. 
>>Write new content. 
>>Truncate file. 
>>Close file (which releases the lock). >>Abigail 

Thanks Abigail,
I thought I should use strict because someone here recommended it. I
looked at many explanations about it, and still didn't understand
though. I don't understand your explanations about use strict either, so
maybe I'll just take it out... unless you could explain a little simpler
maybe, so that I can understand it?

Perhaps the above ordering of things will help. As you seemed to have
guessed, my biggest problem is with I/O order.  So, this is what I'm
guessing...

1. Opening the file for read/write would be done like:
open (COUNT, "visits.dat") or die "Cannot open COUNT: $!";
I don't think I need to use sysopen because the file will already be
open and permissions set.

2. Locking the file would be:
flock(COUNT, $LOCK_EX) if I use Fcntl or  flock(COUNT, 2) without Fcntl.

Maybe, I need to take out Fcntl and just use the magic numbers so the
code would be more compatible with other systems?
BTW... many examples I saw had the file opened, flocked, closed, opened
for writing, then flocked again, then unlocked and closed. That really
confused me. It looks like we only need to use flock 2 once in the file,
and no flock 8, since close automatically unlocks it?

3. Read the content would be:
$cnt = <COUNT> reads it into a scalar... or do I need to read it into an
array such as @cnt?  (use my or local... are either or those necessary?
I couldn't understand when to use them either)

4. Seek to beginning would be done as: seek(COUNT, 0, 0) or die "Cannot
REWIND visits.dat: $!";  I had this in, but thought it wasn't necessary
or thought you had to use sysopen in order to use it... so I took it
out.

5. Write new content would be done as:
print COUNT $cnt   (not going to use die here, because I'm not worried
about running out of space, as someone here pointed out... see I have
been trying to digest everything the best I can.)
 
6. Truncate the file would be done as:
truncate(COUNT, 0) or die "blah blah: $!"; I also had this, but took it
out because I thought it was only needed with sysopen. 

7. Close the file would be done as:
Close COUNT   finally, an easy one.

And just where in all of that do I put chomp $cnt? And where do I put
$cnt++
to increment the count?

This whole thing is very confusing to me. Obviously I'm a beginner, but
I have tried diligently to do the needed research. I have spent over two
weeks now trying to figure this out, and probably well over 200 hours
looking and studying numerous perl faqs and examples, believe it or not. 

Maybe I'm just not very smart, but I did not find any perl faq or
examples that explained things well or thoroughly in my honest opinion,
and I used 12 different search engines. I doubt if there is a perl site
on the net that I haven't been to. I still don't know when it's best to
use flock, fnctl, or ioctl. Oh well.

One good thing, I think I've learned alot from all of the time I've
spent researching this... or maybe not?... seems like I'm getting more
confused.

I will study your suggestions, and try to post what I hope to be the
final coding for your critique.

Sincerely,
Dennis



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

Date: Mon, 24 Jul 2000 16:14:24 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Why won't  "use strict;"  work?
Message-Id: <slrn8np8t0.9jb.tadmc@magna.metronet.com>

On Mon, 24 Jul 2000 13:46:47 -0500 (CDT), BUCK NAKED1 <dennis100@webtv.net> wrote:


>I thought I should use strict because someone here recommended it. 


You think correctly.

You (and everybody else) should always use strict on *all*
perl programs.

It will most certainly save you from long and frustrating
troubleshooting sessions.



>I
>looked at many explanations about it, and still didn't understand
>though. I don't understand your explanations about use strict either, so
>maybe I'll just take it out... unless you could explain a little simpler
>maybe, so that I can understand it?


With "use strict", you must always declare your variables
before you use them.

The best kind of variables are lexical variables. You declare
them with the my() function. You should always prefer this
type of variable over the other type (dynamic variables).

The other kind of variables are dynamic variables, often
associated with the local() function.

But under use strict, you do not use the local() function.

You either:

   1) use our() instead (if you have perl 5.6)

   2) "use vars"   to see how to use this, type:    perldoc vars 

   3) use fully qualified variable names, e.g.   $main::myvar, or
      $SomePackage::myvar instead of just $myvar


>This whole thing is very confusing to me. Obviously I'm a beginner, but
>I have tried diligently to do the needed research. I have spent over two
>weeks now trying to figure this out, and probably well over 200 hours
>looking and studying numerous perl faqs and examples, believe it or not. 


That is all that is expected before posting, so keep on posting
until you understand how to make each and every Perl program
that you write work under "use strict".

Without "use strict", you are writing dirty hacks.

With "use strict", you might be writing something worthy of
being called a "program".

In projects that I control, you get fired if you do not "use strict"...



>Maybe I'm just not very smart, but I did not find any perl faq or
>examples that explained things well or thoroughly in my honest opinion,
>and I used 12 different search engines. I doubt if there is a perl site
>on the net that I haven't been to. I still don't know when it's best to
>use flock, fnctl, or ioctl. Oh well.


Because file locking is intimately connected to the underlying
Operating System.

Perl does its best to insulate you from such things, but sometimes
you cannot ignore them. You might try searching around for how
to "lock files on whatever OS you are using", rather than how to
do "locking with Perl".



>I will study your suggestions, and try to post what I hope to be the
>final coding 


Please do, but be aware that you are probably being unrealistically
optimistic about the "finalness" of what you post. 

Someone is sure to find some (perceived or real) flaw to
comment on  :-)


>for your critique.


Good luck!



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


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

Date: 24 Jul 2000 17:31:26 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Why won't  "use strict;"  work?
Message-Id: <slrn8npdd5.vcg.abigail@alexandra.foad.org>

BUCK NAKED1 (dennis100@webtv.net) wrote on MMDXIX September MCMXCIII in
<URL:news:23637-397C8F17-49@storefull-242.iap.bryant.webtv.net>:
`' >The proper sequence is: 
`' >>Open a file for read/write. 
`' >>Lock the file. 
`' >>Read the content. 
`' >>Seek to beginning. 
`' >>Write new content. 
`' >>Truncate file. 
`' >>Close file (which releases the lock). >>Abigail 
`' 
`' Thanks Abigail,
`' I thought I should use strict because someone here recommended it. I
`' looked at many explanations about it, and still didn't understand
`' though. I don't understand your explanations about use strict either, so
`' maybe I'll just take it out... unless you could explain a little simpler
`' maybe, so that I can understand it?
`' 
`' Perhaps the above ordering of things will help. As you seemed to have
`' guessed, my biggest problem is with I/O order.  So, this is what I'm
`' guessing...
`' 
`' 1. Opening the file for read/write would be done like:
`' open (COUNT, "visits.dat") or die "Cannot open COUNT: $!";

No, that opens it only for reading. Please consult the manual to see how
you open it for read/write.

`' I don't think I need to use sysopen because the file will already be
`' open and permissions set.

Huh? If the file is already opened, you don't need open() either.

`' 2. Locking the file would be:
`' flock(COUNT, $LOCK_EX) if I use Fcntl or  flock(COUNT, 2) without Fcntl.
`' 
`' Maybe, I need to take out Fcntl and just use the magic numbers so the
`' code would be more compatible with other systems?

No. If you want to make your code compatible with other systems you
*WILL* use Fcntl and use symbolic constants.

`' BTW... many examples I saw had the file opened, flocked, closed, opened
`' for writing, then flocked again, then unlocked and closed. That really
`' confused me. It looks like we only need to use flock 2 once in the file,
`' and no flock 8, since close automatically unlocks it?

Don't draw conclusions from bad examples. Read the manual instead.

`' 3. Read the content would be:
`' $cnt = <COUNT> reads it into a scalar... or do I need to read it into an
`' array such as @cnt?  (use my or local... are either or those necessary?
`' I couldn't understand when to use them either)

If you only have one thing, you use a scalar. If you have many things, you
use an array. As for my or local, don't use local unless you can't use my.
For details on scoping, see the perlsub man page.

`' 4. Seek to beginning would be done as: seek(COUNT, 0, 0) or die "Cannot
`' REWIND visits.dat: $!";  I had this in, but thought it wasn't necessary
`' or thought you had to use sysopen in order to use it... so I took it
`' out.

If you read something, the filepointer is no longer at the beginning.
If you don't seek, the next write will be *after* the first line.

`' 5. Write new content would be done as:
`' print COUNT $cnt   (not going to use die here, because I'm not worried
`' about running out of space, as someone here pointed out... see I have
`' been trying to digest everything the best I can.)

You probably want to write a newline as well.

`' 6. Truncate the file would be done as:
`' truncate(COUNT, 0) or die "blah blah: $!"; I also had this, but took it
`' out because I thought it was only needed with sysopen. 

That would truncate the file to 0 length. Not a smart idea. Consult the
man page. You have some pretty weird ideas about sysopen.

`' 7. Close the file would be done as:
`' Close COUNT   finally, an easy one.

Well, close doesn't have a capital letter, and it would be better to
check its return value.

`' And just where in all of that do I put chomp $cnt? And where do I put
`' $cnt++
`' to increment the count?

Well, there are three points where you can increment the count. Before you
read the old value. Between reading the old value and writing the new
value. And after writing the new value.

If you can't figure out when to increment the count, write three programs
each doing it at different times. Run a few tests and see which program has
the proper behaviour.

`' This whole thing is very confusing to me. Obviously I'm a beginner, but
`' I have tried diligently to do the needed research. I have spent over two
`' weeks now trying to figure this out, and probably well over 200 hours
`' looking and studying numerous perl faqs and examples, believe it or not. 

Still, you seem not to have consulted the manual.

`' Maybe I'm just not very smart, but I did not find any perl faq or
`' examples that explained things well or thoroughly in my honest opinion,
`' and I used 12 different search engines. I doubt if there is a perl site
`' on the net that I haven't been to. I still don't know when it's best to
`' use flock, fnctl, or ioctl. Oh well.

Have you actually read the 12,000 pages of documentation that comes
with Perl? Have you for instance read "perlopentut"? What is it that
makes people think documentation about Perl is hidden in dark secret
corners of the web? Has the recent explosion of fuzz-without-content
of the dot-coms brainwashed everyone?

No matter where you run it, and how you turn it, Perl is Unix is all
aspects. It follows the tradition of all tradional Unix tools, and 
comes with the documentation needed.



Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54\n" and s/<<EOT/<<EOT/ee and print;
"Just another Perl Hacker"
EOT


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

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


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