[15725] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3138 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 23 18:05:42 2000

Date: Tue, 23 May 2000 15:05:24 -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: <959119524-v9-i3138@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 23 May 2000     Volume: 9 Number: 3138

Today's topics:
    Re: $ENV{'REMOTE_USER'}; <dwilgaREMOVE@mtholyoke.edu>
    Re: $ENV{'REMOTE_USER'}; <ppi@searchy.net>
    Re: $ENV{'REMOTE_USER'}; <rootbeer@redcat.com>
    Re: &#037; translating ascii to unicode? <flavell@mail.cern.ch>
    Re: &#037; translating ascii to unicode? <eepeter@erols.com>
        Accounting Systems Written In Perl??? otrcomm**NO_SPAM**@wildapache.net
    Re: Accounting Systems Written In Perl??? <rootbeer@redcat.com>
    Re: activestate Perl5.6 /w win2000? <l.marechal@chello.nl>
    Re: Autoload order (WAS Re: Haiku) (Gwyn Judd)
        Basic Script needed russ@russ.net
    Re: Basic scripting question <bmb@dataserv.libs.uga.edu>
    Re: Basic scripting question <godzilla@stomp.stomp.tokyo>
    Re: Basic scripting question (Randal L. Schwartz)
    Re: Basic scripting question <chris@cjx.com>
    Re: Basic scripting question (Gwyn Judd)
    Re: Basic scripting question (Gwyn Judd)
    Re: cut off text after a <br> <lr@hpl.hp.com>
    Re: cut off text after a <br> <lr@hpl.hp.com>
    Re: cut off text after a <br> <lr@hpl.hp.com>
    Re: cut off text after a <br> <lr@hpl.hp.com>
        Difference between use and require [was Re: Modules - N <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: Difference between use and require [was Re: Modules <rootbeer@redcat.com>
    Re: file locking <dan@tuatha.sidhe.org>
    Re: file locking <dan@tuatha.sidhe.org>
    Re: file locking <dan@tuatha.sidhe.org>
    Re: HELP MEEEEEE <lr@hpl.hp.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 23 May 2000 18:28:15 GMT
From: Dan Wilga <dwilgaREMOVE@mtholyoke.edu>
Subject: Re: $ENV{'REMOTE_USER'};
Message-Id: <dwilgaREMOVE-40A72C.14281623052000@news.mtholyoke.edu>

In article <MmxW4.75$An4.50091@paloalto-snr1.gtei.net>, "John Lawson" 
<John@expresspayments.com> wrote:

> I am still having some problem.
> After i login i run a script form the cgi-bin and the $ENV{'REMOTE_USER'}
> has no value set to it. do i have to login to the cgi-bin or am i calling it
> wrong.
> Here is a complete summary. I have a htacess protected directory in the main
> directory. after they login to that directory i call a script and want to
> know who logged in. i set $user=$ENV{'REMOTE_USER'}; when i print out $user
> there is no value i am not sure if it is because i have to login to the
> cgi-bin or if i am calling the env wrong.
> also  Ilja if you reads this again where is the director
> "manuals/FAQs/newsgroups".
> thanks again

Either the entire /cgi-bin directory or the particular script itself has to be 
protected and in the same realm as the other files in order for this variable 
to be set correctly.

Dan Wilga          dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply  **


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

Date: Tue, 23 May 2000 21:10:10 +0200
From: Penpal International <ppi@searchy.net>
Subject: Re: $ENV{'REMOTE_USER'};
Message-Id: <392AD792.43328571@searchy.net>

Don't you have a error in the part to print it out? be sure it's be done
like this:

open (LOG, ">>user.log"); # DON'T forgot those two >'s
print LOG "$ENV{'REMOTE_USER'}\n";
close (LOG);

John Lawson wrote:
> 
> I am still having some problem.
> After i login i run a script form the cgi-bin and the $ENV{'REMOTE_USER'}
> has no value set to it. do i have to login to the cgi-bin or am i calling it
> wrong.
> Here is a complete summary. I have a htacess protected directory in the main
> directory. after they login to that directory i call a script and want to
> know who logged in. i set $user=$ENV{'REMOTE_USER'}; when i print out $user
> there is no value i am not sure if it is because i have to login to the
> cgi-bin or if i am calling the env wrong.
> also  Ilja if you reads this again where is the director
> "manuals/FAQs/newsgroups".
> thanks again

-- 
Penpal International
http://ppi.searchy.net/
ppi@searchy.net


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

Date: Tue, 23 May 2000 12:57:50 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: $ENV{'REMOTE_USER'};
Message-Id: <Pine.GSO.4.10.10005231257290.23375-100000@user2.teleport.com>

On Tue, 23 May 2000, Penpal International wrote:

> open (LOG, ">>user.log"); # DON'T forgot those two >'s

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

Thanks!

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



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

Date: Tue, 23 May 2000 20:16:40 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: &#037; translating ascii to unicode?
Message-Id: <Pine.GHP.4.21.0005231942080.29718-100000@hpplus01.cern.ch>

On Tue, 23 May 2000, W Kemp wrote:

> >this "translating ascii to unicode".  us-ascii is a proper subset of
> >unicode, and so is iso-8859-1, 

> Are you sure about that one (iso-8859-1)

Yes Sir, I am...

> Things go slightly wrong between hex 80 and 9F (strictly speaking
> 0080 and 009F) unicode viewing these as control characters

Indeed, but this follows on from iso-8859-* usage, which also defines
them as control characters.

> hex C0 to FF in Latin-1 is the same as unicode (well, 00C0 to 00FF).

Refer to a very boring table at 
ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-1.TXT

In case anyone's got confused by the Empire: the codes between 128 and
159 decimal (x80 to x9f) are assigned to control functions, in unicode
_and_ in the iso-8859-* codings.

These codes are used for displayable characters in _some_ non-vendor
codings, e.g koi8-r (Russian Cyrillic); but most of the codings which
put displayable characters there are vendor-defined.

The reason for the gap is historical, as so many things are: nobody
really needed all those control functions, but back when there was
still a significant amount of equipment limited to 7-bit characters,
the designers worried about the consequences of an 8-bit character
losing its top bit, being mistaken for a control function, and
wrecking the whole display.  So they reserved that area for control
functions. At least if loss of the top bit on a displayable character
could only result in another displayable character, it would only mess
up a single character position.  So it made sense, at the time.

Be that as it may:

us-ascii is a proper subset of all the iso-8859-* codings,

iso-8859-1 is a proper subset of unicode.

When I say "unicode", of course I'm referring to the integer values
assigned to unicode characters.  These are the numbers that belong in
the HTML representation &#number;  (technically these are called
"numerical character references").

Note that the numerical character references &#128; to &#159; are
_undefined_, i.e meaningless in standard HTML.  Some non-standard
software uses them on the pretext that they stand for the displayable
characters which windows-1252 assigns in this area.  However, the true
values for those characters can be discovered here:

ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT

When you actually transmit or store unicode characters, you have to
decide on a coding for tnem (utf-8, utf-7, ucs-2 or ucs-4).

I think I've probably said too much for this venue.  There's tutorial
stuff and pointers to other resources, not only on Jukka Korpela's
very detailed web pages - one place to start would be
http://www.hut.fi/u/jkorpela/chars.html

but also, in relation to WWW usage, on <owntrumpet>my own pages:

http://ppewww.ph.gla.ac.uk/~flavell/charset/
</>

cheers



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

Date: Tue, 23 May 2000 16:04:39 -0700
From: Erik Peterson <eepeter@erols.com>
Subject: Re: &#037; translating ascii to unicode?
Message-Id: <392B0E87.FB5E7D66@erols.com>

  I have some code for this at the CGI section of
http://www.chinesecomputing.com

Nadja Herkova wrote:
> 
> I'm sure it must exist in modules; parser to convert ascii characters
> into their html safe unicode (?) counterparts in the &#xxx; format  -
> I've been searching for hours but have not found any help. Is there a
> special name for the &#xxx; format that I have missed ?
> 
> thanks
> Nadja


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

Date: Tue, 23 May 2000 20:55:01 GMT
From: otrcomm**NO_SPAM**@wildapache.net
Subject: Accounting Systems Written In Perl???
Message-Id: <392aef62.2826917312@news.wildapache.net>

Hello,

Does anyone know if there are any decent accounting systems written in perl
that will run on a Linux system?

Thanks,
Murrah Boswell

******
Remove the **NO_SPAM** part of return email address if you want to reply
via email.


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

Date: Tue, 23 May 2000 14:28:54 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Accounting Systems Written In Perl???
Message-Id: <Pine.GSO.4.10.10005231427280.23375-100000@user2.teleport.com>

On Tue, 23 May 2000 otrcomm**NO_SPAM**@wildapache.net wrote:

> Does anyone know if there are any decent accounting systems written in
> perl that will run on a Linux system?

It's widely agreed that there's no accounting for Perl. :-)

Are you looking for end-user software? If you're wishing merely to _find_
(as opposed to write) programs, this newsgroup may not be the best
resource for you. There are many freeware and shareware archives which you
can find by searching Yahoo or a similar service.

> Remove the **NO_SPAM** part of return email address if you want to
> reply via email.

Remove the **NO_SPAM** part of your return email address if you want to
get replies via email.

Hope this helps!

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



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

Date: Tue, 23 May 2000 20:59:41 +0200
From: "Laurent Marechal" <l.marechal@chello.nl>
Subject: Re: activestate Perl5.6 /w win2000?
Message-Id: <8gekal$htt$1@tesla.a2000.nl>

I had installed it several time without problem or error....
Is your file correct ?
ActivePerl-5.6.0.613.msi    8369664 bytes

Laurent

"¥[µá¿ß" <kflin@csie.nctu.edu.tw> wrote in message
news:8ge1ok$l84$1@netnews2.csie.nctu.edu.tw...
> Hi all,
>
> I've just downloaded the Perl5.6 for Win32 from
> ActiveState in binary form. While installing
> in Windows 2000, I got the error for
> "Premature Ended" without any further info
> for failure reason. The ActiveState states
> that we don't need any other requirement
> to install Perl package for win2k. Also I didn't
> get any resolution in their FAQ.
> So I'd like to know if anyone got the same
> problem? Or has any resolution?
> Thanks in advance.
>
>




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

Date: Tue, 23 May 2000 21:53:24 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Autoload order (WAS Re: Haiku)
Message-Id: <slrn8iojun.9qs.tjla@thislove.dyndns.org>

I was shocked! How could Brad Baxter <bmb@dataserv.libs.uga.edu>
say such a terrible thing:
>On Tue, 23 May 2000, Gwyn Judd wrote:
>> nice poem :) thank you. So from running this in the debugger it seems
>> that functions are "autoloaded" in reverse order for some weird reason.
>> Is that correct? I confess I don't understand the autoload process.
>That's like saying "fox( brown( quick( the() ) ) );"
>Each subroutine prints its own name, beginning with "the()".
>
>Output:
>
>the quick brown fox
>
>
>Not even very imaginative, really.  :-)

d'oh :). Thanks for the explanation

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
Computers can figure out all kinds of problems, except the things in
the world that just don't add up.


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

Date: Tue, 23 May 2000 21:05:48 GMT
From: russ@russ.net
Subject: Basic Script needed
Message-Id: <8gerr1$2nr$1@nnrp1.deja.com>

I'm trying to do some simple tasks and decided to try to make my life
easier by writing a perl script.  I'm clueless about Perl so I need
some help.  It should be obvious (i hope) of what I'm trying to
accomplish.  Can anyone fix this mess?

#!/usr/bin/perl
print "What is the username of the user you would like to add? ";
chop $user;
system ("htpasswd passwd.user $user");
system ("tail -1 ~/passwd.user >> ~/public_html/_vti_pvt/service.pwd");
system ("tail -1 ~/passwd.user >> ~/public_html/fpweb-
comp/_vti_pvt/service.pwd");


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


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

Date: Tue, 23 May 2000 14:11:13 -0400
From: Brad Baxter <bmb@dataserv.libs.uga.edu>
Subject: Re: Basic scripting question
Message-Id: <Pine.GSO.4.21.0005231410440.9692-100000@dataserv.libs.uga.edu>

On Tue, 23 May 2000, Chris Allen wrote:
> I can only assume that you actually know *exactly* what
> you are doing and are posting purely to wind up the members
> of clpm. 

Ding.

-- 
Brad



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

Date: Tue, 23 May 2000 12:27:41 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Basic scripting question
Message-Id: <392ADBAD.C31E148B@stomp.stomp.tokyo>

Michel Dalle wrote:
 
> In article <392AAC2E.43535A02@stomp.stomp.tokyo>, "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:

> What O.S. are you using ?


$ perl -v

This is perl, version 5.003 with EMBED
built under solaris at Aug 15 1996 12:10:42


Godzilla!


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

Date: 23 May 2000 12:53:53 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Basic scripting question
Message-Id: <m1vh05t54e.fsf@halfdome.holdit.com>

>>>>> "Godzilla!" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:

Godzilla!> $ perl -v

Godzilla!> This is perl, version 5.003 with EMBED
Godzilla!> built under solaris at Aug 15 1996 12:10:42

Ahh... the version with known CERT-ifiable buffer overflows.
I hope you're not running this somewhere on a CGI engine.  I'm
told there are rootkits that the script kiddies can run that
will take over your website trivially.

Any version of Perl prior to 5.004 is known vulnerable.  Upgrade now!

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 23 May 2000 21:09:11 +0100
From: Chris Allen <chris@cjx.com>
Subject: Re: Basic scripting question
Message-Id: <D443C5C4CCF68D63.1F49AE40A8C5D8C4.CAC96FFD4EE1EBE6@lp.airnews.net>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:

>Do you see me twisting arms, holding a gun
>to a person's head, forcing people to post
>insulting vulgar sociopathic flame articles?

No, I don't.

I see somebody who has made me read this newsgroup with a renewed
interest over the last few months, even if it is to despair at the
solutions that you post, and to learn from the counter-examples that
are posted by the regulars. I thank you for that, whether or not you
are doing it intentionally.


* You find a scroll labelled THARR


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

Date: Tue, 23 May 2000 21:45:18 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Basic scripting question
Message-Id: <slrn8iojfi.9qs.tjla@thislove.dyndns.org>

I was shocked! How could Dave Cross <dave@dave.org.uk>
say such a terrible thing:
>On Tue, 23 May 2000 13:26:18 GMT, tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
>wrote:
>>I think the thing was to print every line but every third not the other
>>way around.
>
>My version prints lines 1, 2, 4, 5 ,7,8, etc, which is what the OP
>wanted.

oh whoops. I'll shut up now :)

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
Could taste your sweet kisses, your arms open wide
This fever for you is just burning me up inside..
		-- Roy Orbison/Cyndi Lauper, "I Drove All Night"


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

Date: Tue, 23 May 2000 22:01:10 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Basic scripting question
Message-Id: <slrn8iokd9.9qs.tjla@thislove.dyndns.org>

I was shocked! How could Godzilla! <godzilla@stomp.stomp.tokyo>
say such a terrible thing:
>Uri Guttman wrote:
>
>> it wasn't always clear to print every third
>> line or skip it. i saw both types in this thread.
>
>
>Baloney. Your ego is making a fool of you.
>
>
>You are posting code which has no input,
>no output, no file handles, nothing, and
>most importantly, no testing. Quite often
>your code is dead wrong.

let me point them out for you since your monitor resolution seems to be
set wrong:

perl -ne 'print if $. % 3' input_file > output_file
            *                 *       *       *
					 ***               ***     ***     ***
					*****             *****   *****   *****
				 *******           ******* ******* *******
				   ***               ***     ***     ***
					 ***               ***     ***     ***
				  output            input   output  output
					                  file-   redir-   file-
														handle  ection  handle

HTH

-- 
Gwyn "ascii art" Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
QOTD:
	On a scale of 1 to 10 I'd say...  oh, somewhere in there.


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

Date: Tue, 23 May 2000 13:14:55 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: cut off text after a <br>
Message-Id: <MPG.1394869ac0945e1198aabf@nntp.hpl.hp.com>

In article <2pkkis813shntf2jaghrncng91ojbvpbfv@4ax.com> on Tue, 23 May 
2000 10:46:27 +0100, Dave Cross <dave@dave.org.uk> says...

 ...

> And perhaps you should take into account the possibility that the
> string we're working on contains newline characters.
> 
> $newstext =~ s/<br>.*\Z//is;

That leaves a trailing newline, if any.  Perhaps the following would be 
better:

  $newstext =~ s/<br>.*\z//is;

And the following would be best (because it is identical, and two 
strokes shorter):

  $newstext =~ s/<br>.*//is;

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


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

Date: Tue, 23 May 2000 13:10:50 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: cut off text after a <br>
Message-Id: <MPG.139485a5e23885e098aabe@nntp.hpl.hp.com>

In article <959070717.5683.0.nnrp-08.9e9872de@news.demon.co.uk> on Tue, 
23 May 2000 09:32:02 +0100, Franck Lalane <f.lalane@no-spam.pra.org.uk> 
says...

 ...

> try
> ($tmpnewshtml) = $newstext =~ m/(.*)?<br>/;
> It should put all the characters before the first <br> in your temp string.

No, it would put all the characters before the *last* <br> (or the first 
newline) in your temp string, because the '?' is misplaced.  It actually 
does nothing where it is, because '.*' always matches.

  if (my ($tmpnewshtml) = $newstext =~ m/(.*?)<br>/is) {
      ... do something with $tmpnewshtml ...
  }

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


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

Date: Tue, 23 May 2000 13:17:27 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: cut off text after a <br>
Message-Id: <MPG.1394872d2c3e324b98aac0@nntp.hpl.hp.com>

In article <959084257.25335.0.nnrp-02.c3ad6973@news.demon.co.uk> on Tue, 
23 May 2000 13:16:05 +0100, W Kemp <bill.kemp@wire2.com> says...
> This line looks odd to me, I would have thought it just gives '1' for  match
> '0' for no match.
> 
> $tmpnewshtml = $newstext =~ m/(.*)?<br>/;
> 
> 
> If you want to do it this way rather than the two other suggestions
> 
> $newstext =~ m/(.*)?<br>/;
> $tmpnewshtml =$1;

That is OK (except for the misplaced '?', as I noted earlier) if and 
only if you want to use the previous value of $1 in this scope, if any, 
should the match fail.  Just as in opening files, it is always wise to 
test the success of a pattern match before using its captured values.

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


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

Date: Tue, 23 May 2000 13:24:57 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: cut off text after a <br>
Message-Id: <MPG.139488f081b4bb0398aac1@nntp.hpl.hp.com>

In article <8gdsdr$auq$1@nnrp1.deja.com> on Tue, 23 May 2000 12:09:38 
GMT, Hardy Merrill <hmerrill@my-deja.com> says...

 ...

> I'll take a shot at this, but this is off the top of my head, and
> untested!

Exactly how long would it take you to test it before posting it to how 
many thousand readers?  I tested it, even though I *knew* what your 
principal error was before testing.

>            You can do an "index" to find the position(call it maybe
> $pos) in the string where "<br>" occurs(which will be the position of
> the "<") - then take the "substr" of the string from 0 to $pos+3.
> 
>     $pos_br = index(newstext,"<br>");
>     $tmpnewshtml = substr($newstext,0,$pos_br+3)

Errors:  Bareword 'newstext'; unterminated statement; offset should be 
4,  not 3.

It is nice to want to help; it is nicer yet to help responsibly.

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


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

Date: Tue, 23 May 2000 12:11:55 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Difference between use and require [was Re: Modules - Newbie question]
Message-Id: <392AD7FB.F994EEAB@jpl.nasa.gov>

Simon McGregor wrote:
> Jeff Zucker <jeff@vpservices.com> wrote in message
> news:3929D94B.66FF6513@vpservices.com...
> > If the module has functions which are exported, then "use" imports them
> > but "require" does not.  That is to say if a module foo defines a
> > function bar() and exports that function,  this would work:
> >
> >   use foo;
> >   &bar();
> >
> > and this would not:
> >
> >   require "foo.pm";
> >   &bar();
> 
> OK... But if I do
> 
> require "foo.pl";
> &bar();
> 
> that seems to work fine, providing that bar() is defined in foo.pl - what's
> the difference?

A more complete explanation of the difference between use and require
can be found at 'perldoc -q require' and by reading the use and require
sections of perlfunc.  While you're at it, read 'perldoc perldoc',
perlmod and perlmodlib.

If foo.pm contains:

  sub bar{
    print "Hi from foo.pm!\n";
  };

  1;

and your script is:

  #!/usr/bin/perl -w
  use strict;

  use lib '~/lib'; # or wherever you put foo.pm
  use foo;

  bar;

Now try to require foo and perl will complain about the bar bareword. 
Perhaps this is the point that the (incorrect) example was trying to
make.

Jon
-- 
Knowledge is that which remains when what is
learned is forgotten. - Mr. King


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

Date: Tue, 23 May 2000 13:32:14 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Difference between use and require [was Re: Modules - Newbie question]
Message-Id: <Pine.GSO.4.10.10005231329300.23375-100000@user2.teleport.com>

On Tue, 23 May 2000, Jon Ericson wrote:

>   use lib '~/lib'; # or wherever you put foo.pm

I don't think that the tilde is meaningful to lib.pm. It's a shell
shortcut. So this is saying (if I'm not mistaken) to look in the current
directory for a directory whose name is a tilde, and in there for the
'lib' subdirectory. 

Cheers!

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



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

Date: Tue, 23 May 2000 18:51:41 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: file locking
Message-Id: <1rAW4.90640$hT2.381973@news1.rdc1.ct.home.com>

Peter J Scott <peter@psdt.com> wrote:
> In article <cIxW4.90589$hT2.381866@news1.rdc1.ct.home.com>,
>  Dan Sugalski <dan@tuatha.sidhe.org> writes:
>>Michel Dalle <michel.dalle@usa.net> wrote:
>>> I've never seen any problems with appending a single line to a
>>> logfile, though... Have I been lucky so far, or would that qualify
>>> as a single write() operation ?
>>
>>You've been lucky. A 2-byte print to a file can theoretically span blocks,
>>and thus be geeked.

> But suppose the logfile writer opens the file for append, prints a line
>(< 8k) and then closes it... that write() couldn't span blocks, it
>should be starting at the beginning of a block.

print uses stdio, which is *not* the same as what the C (and often
system) write function does. Stdio buffers, and buffers will make your
life a mess. write() can potentially make your life a mess too, but its
failure modes are different.

If you have multiple writers then you must lock your files to guarantee
proper and safe output. Since Unix, in general, doesn't do this for you,
(and we're not going there at the moment--it's a reasonable optimization
for the common case) you need to do it yourself.

flock() or expect gook at some point. It's more likely under load, but if
your timing is just right, or you're on an SMP system, it can happen when
your system is nearly dead.

				Dan


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

Date: Tue, 23 May 2000 18:55:49 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: file locking
Message-Id: <VuAW4.90642$hT2.381973@news1.rdc1.ct.home.com>

Michel Dalle <michel.dalle@usa.net> wrote:
> In article <cIxW4.90589$hT2.381866@news1.rdc1.ct.home.com>, Dan Sugalski <dan@tuatha.sidhe.org> wrote:
>>Michel Dalle <michel.dalle@usa.net> wrote:
> [snip of cookie monster :)]
>>> I've never seen any problems with appending a single line to a
>>> logfile, though... Have I been lucky so far, or would that qualify
>>> as a single write() operation ?
>>
>>You've been lucky. A 2-byte print to a file can theoretically span blocks,
>>and thus be geeked.

> Wait - let me get this 100% clear. I open a file for append, print
> a single line (of less than BUFSIZ) to it and close it again.

> Are you telling me this could theoretically span blocks ?

Of course. If the file is 511 bytes and you write out a two-byte line, you
just spanned a block. First byte goes at the end of the existing block,
while the second goes at the start of the new block. More importantly
you're using stdio for print, which introduces yet another layer of
complexity because of the buffering. 

> If so, I definitely need to review my understanding of how
> I/O really works - and I think I'm not the only one here...

I expect a lot of people need to. Perl's built on many layers of
abstraction. This is good, because it saves you a lot of time. On the
other hand it makes understanding some of the odd failure modes when you
step outside the boundaries of what's safe more than a little puzzling.

					Dan


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

Date: Tue, 23 May 2000 18:58:21 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: file locking
Message-Id: <hxAW4.90643$hT2.381973@news1.rdc1.ct.home.com>

Michel Dalle <michel.dalle@usa.net> wrote:

> Thanks, this seems to confirm that for appending a single line of
> information, a simple open(...,">> ") - print - close would be
> reliable enough in most cases...but that larger blocks of data
> need to be handled with a bit more care.

You're mixing layers. write() at the C level's reasonably (though not
always) atomic. Perl's print is above that by a few layers and is *not* in
any way atomic.

Regardless, if your data's important enough to write in the first place,
it's important enough to write properly. flock is your friend--use it.

> You managed to scare me, Randal and Dan :)

This I regard as a good thing. :-P

				Dan


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

Date: Tue, 23 May 2000 12:27:28 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: HELP MEEEEEE
Message-Id: <MPG.13947b7f19c1e47998aabc@nntp.hpl.hp.com>

In article <393083f7.17453627@news.skynet.be> on Tue, 23 May 2000 
14:04:08 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Marco Natoni wrote:
> 
> > I was not clear enough:  How can we live *without* heredocs? :)
> 
> You may, if you wish. Why would you want to?
> 
> print "This is
> a multiline
> string.";

If the contents of the here-doc are not empty, the string will always 
end with a newline.  Hence you have slightly *less* flexibility with a 
here-doc than with an explicit string.

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


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

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


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