[15438] in Perl-Users-Digest
Perl-Users Digest, Issue: 2848 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 23 14:11:21 2000
Date: Sun, 23 Apr 2000 11:10:13 -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: <956513413-v9-i2848@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 23 Apr 2000 Volume: 9 Number: 2848
Today's topics:
Re: purpose of use vars () ? msouth@fulcrum.org
Re: Response from perlbug@perl.com (Mike Fry)
Re: setpwent/getpwent <gellyfish@gellyfish.com>
Tab and space <amai@pacific.net.sg>
Re: Tab and space (Kragen Sitaker)
Re: Tab and space (Craig Berry)
Re: Tab and space <amai@pacific.net.sg>
Re: Tab and space <rootbeer@redcat.com>
Re: Tab and space (Craig Berry)
Re: Very easy, quick question.... <gellyfish@gellyfish.com>
Re: Very easy, quick question.... (Steve)
Re: Which book? mark_g@cyberdude.com
Re: Which book? <bowman@montana.com>
Re: Which book? <elaine@chaos.wustl.edu>
Re: Writing to STDIN <lwaibel@cwia.com>
Re: Writing to STDIN <tony_curtis32@yahoo.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Apr 2000 17:55:22 GMT
From: msouth@fulcrum.org
Subject: Re: purpose of use vars () ?
Message-Id: <8dvdea$kuj$1@inxs.ncren.net>
stephen <schan_ca@geocities.com> wrote:
It's much easier for other people to follow the discussion if you
put your response after what you're responding to. The way you
did it is referred to posting "Jeopardy style" (because the answer
comes first, then the question). Just leave the part that you're
responding to in, and respond below it. (and trim out anything
that isn't necessary.
> Ok, I think I get it now.
> Before I use to do this:
> ------------
> package aaa;
> use strict;
> $aaa::var_1 = 'howdy';
> $bbb::var_2 = 'doody';
> ----------------
I assume you meant $aaa::var_2 rather than $bbb::var_2 here? Otherwise,
what you're talking about isn't remotely similar to what you're doing
below:
> I explicitly declare every var to be visible
> outside the package with the package
> prefix "$aaa"
Well, I'm not sure if you've go it or not. You're not making the variable
visible, really. You're being explicit about the fact that you're _using_
the variable that is visible to anyone who can see the package.
What you're doing with the $aaa:: is telling Perl exactly
which var_1 you mean. You have to do that here, because you're
using 'strict', and it won't let you get away with just saying
$var_1. Let's see what happens without use strict:
package aaa;
$var_1 = 'howdy'; # you just assigned 'howdy' to $aaa::var_1
Now, say we're in some other file, we could do:
require 'fileaaa';
print $aaa::var_1, ", pardner\n";
You were assigning to a variable that's visible outside the
package, you just weren't being explicit about it. With
use strict, you would have to do (well, you don't _have_ to,
because use vars lets you out of it):
package aaa;
use strict;
$aaa::var_1 = 'howdy';
If you don't have the aaa:: there, it's not even going to compile.
'use strict' says, among other things, "don't let me just say $var_1
when I mean $aaa::var_1".
Okay, now here's where 'use vars' comes in. It's sort of a relaxation
of 'use strict'--it says, "okay, in general, I don't want you to let
me say $foo when I'm talking about $aaa::foo, but there are a few
variables here that I'm using all over and I don't want to have to
type the aaa:: every time. Here they are."*
Now you can use those variables (in that file) without "fully
qualifying" them.
*(But see below, it's not just to save you typing.)
> now I could do this:
> ----------------
> package aaa;
> use strict;
> use vars qw ($var_1, $var_2);
You don't want that comma! You want strings separated by
whitespace! This will compile without complaining (I think), but
won't do what you want!
> $var_1 = 'howdy';
> $var_2 = 'doody';
> ----------------
> So basically, "use vars" is used to declare any
> variables visible outside it's package.
Well, it's declaring '$var_1', in this file, to refer to
'$aaa::var_1', which, yes, is visible outside the package.
> Now I hope I have it right?
Now I hope _I_ have it right. After reading 'perldoc vars' I realize that
I didn't understand all of what 'use vars' is really about. But I am
reasonably sure I haven't led you astray here. The other implications
of 'use vars', and a perhaps more critical use of them, is to help out
with AutoLoad()'ed routines that need to be able to see the variables,
and might not be able to if they were declared with my(). At least
that's what I got out of the 'vars' documentation.
But I don't think you have to worry about that yet.
To summarize:
In file 'fileaaa', if you have
package aaa;
use strict;
use vars qw($yo);
my $ya;
$yo = 1; # that's really $aaa::yo, visible outside
$ya = 2; # that's not $aaa::ya, and not visible outside
sub foo {
print "yo is $yo, ya is $ya\n";
}
1;
Then in file 'useaaa.pl' you have
#!/usr/bin/perl -w
use strict;
require 'fileaaa';
print "aaa::yo is $aaa::yo \n";
print "aaa::ya is $aaa::ya \n";
print "here's what &aaa::foo says:\n";
&aaa::foo();
the output is:
Name "aaa::yo" used only once: possible typo at useaaa.pl line 5.
Name "aaa::ya" used only once: possible typo at useaaa.pl line 6.
aaa::yo is 1
Use of uninitialized value at useaaa.pl line 6.
aaa::ya is
here's what &aaa::foo says:
yo is 1, ya is 2
See how $aaa::ya gives you an unitialized value warning? Nobody
initialized it, $ya, a my() variable in fileaaa, is not related
to $aaa::ya, and not visible outside fileaaa. However, the
subroutine &aaa::foo is in package aaa, and it:
a) can see $ya, knowing its value is 2
and
b) knows that $yo means $aaa::yo in fileaaa, because use vars
declared that to be so.
I hope that helps, and that I have not introduced too much
confusion.
[Jeopardectomy]
mike
------------------------------
Date: 23 Apr 2000 14:01:45 +0200
From: nospam.yrfekim@nospam.acirfai.com (Mike Fry)
Subject: Re: Response from perlbug@perl.com
Message-Id: <UdqMGoQ7Ipid-pn2-dElMh2MiGzVf@minitower>
On Sun, 23 Apr 2000 03:31:05, Rick Delaney <rick.delaney@home.com>
wrote:
> Not with an address like that. ;-) Actually, you should receive an
> acknowledgement with a bug ticket number if you have a valid email
> address. Beyond that, perldoc perlbug.
>
Ooops! Looks like my mail reader has only sent the From: header
(supposed to foil spammers) and not the Reply To:
Actually, one of the bugs was indirectly about perlbug, which is why I
couldn't use it to report my errors. Guess I'll have to do as you
advised and search through the perlbug database. I seem to recall trying
to do this previously without much success. Has anyone any tips on
searching when you don't have a bug ticket number?
--
Regards, Mike Fry
email: mikefry@iafrica.com
------------------------------
Date: 23 Apr 2000 10:28:59 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: setpwent/getpwent
Message-Id: <8dufor$rt0$1@orpheus.gellyfish.com>
On 22 Apr 2000 12:37:40 +0100 Jonathan Stowe wrote:
>
> BTW on some systems getpwent() *will not* return the encrypted password
> from /etc/shadow because a separate set of library functions are used
> to access this information. OS that do this include SCO OpenServer and Linux.
I lied about this with respect to Linux and Perl 5.6.0 - it was brought in
with :
[ 3367] By: gsar on 1999/05/10 09:55:51
Log: shadow password support for Solaris (needs Configure help to
determine HAS_GETSPENT)
From: "Patrick O'Brien" <pdo@cs.umd.edu>
Date: Sat, 01 May 1999 19:41:17 -0400
Message-Id: <199905012341.TAA23989@optimus.cs.umd.edu>
Subject: getpwent() under solaris
Branch: perl
! pp_sys.c
This still does apply to earlier versions of Perl and may still apply to
other OS which have yet different shadow password support.
/J\
--
The strong must protect the sweet
--
fortune oscar homer
------------------------------
Date: Sun, 23 Apr 2000 22:32:36 +0800
From: "Amai Ng" <amai@pacific.net.sg>
Subject: Tab and space
Message-Id: <8dv18q$1hs$1@newton.pacific.net.sg>
Hi,
I am not very sure about Perl and Unix, just need to know if a 'Tab' is just
more white space, or itself is another character?
I need to cut a line of columns, where the delim can be either 'Tab' or
space.... so I am trying to find a way to detect which is which at the point
of running the script.
Thanks a million!
Amai
------------------------------
Date: Sun, 23 Apr 2000 15:39:09 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Tab and space
Message-Id: <xOEM4.2396$D%4.3225807@news-east.usenetserver.com>
In article <8dv18q$1hs$1@newton.pacific.net.sg>,
Amai Ng <amai@pacific.net.sg> wrote:
>I am not very sure about Perl and Unix, just need to know if a 'Tab' is just
>more white space, or itself is another character?
There is a tab character, normally denoted \t in doublequoted Perl
strings and regexes. It is whitespace, in that it is matched by \s.
Some text editors will insert spaces instead of tabs when you press the
Tab key. Some of them will even delete spaces under some
circumstances.
>I need to cut a line of columns, where the delim can be either 'Tab' or
>space.... so I am trying to find a way to detect which is which at the point
>of running the script.
Just use \s, which matches either. :)
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
The power didn't go out on 2000-01-01 either. :)
------------------------------
Date: Sun, 23 Apr 2000 15:58:31 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Tab and space
Message-Id: <sg67d7fl6e128@corp.supernews.com>
Amai Ng (amai@pacific.net.sg) wrote:
: I am not very sure about Perl and Unix, just need to know if a 'Tab' is just
: more white space, or itself is another character?
Both. The tab character (\t, or \x09, or \cI) and the space character
(' ', \x20) are distinct. However, both are included in the whitespace
character class \s.
: I need to cut a line of columns, where the delim can be either 'Tab' or
: space.... so I am trying to find a way to detect which is which at the point
: of running the script.
Were you to split on /(\s+)/, the field values would alternate with the
spaces separating them in the resulting array, and you could therefore
examine what kinds of whitespace were there originally.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "The road of Excess leads to the Palace
of Wisdom" - William Blake
------------------------------
Date: Mon, 24 Apr 2000 00:26:48 +0800
From: "Amai Ng" <amai@pacific.net.sg>
Subject: Re: Tab and space
Message-Id: <8dv7vm$5es$1@newton.pacific.net.sg>
Hi,
thanks for the reply. I would just like to find out, can 'split' work just
like 'cut' of shell script? I have just learnt shell script, and currently
is trying to get only 2 columns of data out of a chunk of data from 'ps'. If
I used 'limit' field of 'split', will it work exactly the same?
Once again, thanks for helping,
Amai
"Amai Ng" <amai@pacific.net.sg> wrote in message
news:8dv18q$1hs$1@newton.pacific.net.sg...
Hi,
I am not very sure about Perl and Unix, just need to know if a 'Tab' is just
more white space, or itself is another character?
I need to cut a line of columns, where the delim can be either 'Tab' or
space.... so I am trying to find a way to detect which is which at the point
of running the script.
Thanks a million!
Amai
------------------------------
Date: Sun, 23 Apr 2000 09:37:12 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Tab and space
Message-Id: <Pine.GSO.4.10.10004230936360.25963-100000@user2.teleport.com>
On Mon, 24 Apr 2000, Amai Ng wrote:
> I would just like to find out, can 'split' work just like 'cut' of
> shell script?
Have you seen the entry for 'split' in the perlfunc manpage? Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 23 Apr 2000 17:31:12 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Tab and space
Message-Id: <sg6cr036l6e176@corp.supernews.com>
Amai Ng (amai@pacific.net.sg) wrote:
: thanks for the reply. I would just like to find out, can 'split' work just
: like 'cut' of shell script? I have just learnt shell script, and currently
: is trying to get only 2 columns of data out of a chunk of data from 'ps'. If
: I used 'limit' field of 'split', will it work exactly the same?
Cut has two main behaviors -- fixed-width-field cutting and field-
separator cutting. The perl functions substr or unpack are good for the
first purpose, and split for the second. See the documentation on each
for more details.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "The road of Excess leads to the Palace
of Wisdom" - William Blake
------------------------------
Date: 23 Apr 2000 10:41:58 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Very easy, quick question....
Message-Id: <8dugh6$s4b$1@orpheus.gellyfish.com>
On 23 Apr 2000 07:10:20 GMT AmazingAl5 wrote:
> I just have one question: ALL i'm trying to do is simply execute:
>
> print "Hello World";
>
> on the Win32 system. Yes I do have ActivePerl (the latest version) and I even
> have the latest PDK. The answer would be GREATLY appreciated.
Open a DOS window. Assuming you have the file containing your Perl program
in the current directory (and it is called hello.pl ) type:
perl hello.pl
You can also use the program pl2bat to wrap your program as a .bat file
so that it can be run by just typing its name. On NT you can also use the
ASSOC and FTYPE to create an assocation which will have a similar effect
however this apparently causes problems with I/O redirection.
/J\
--
If this were really a nuclear war we'd all be dead meat by now.
--
fortune oscar homer
------------------------------
Date: 23 Apr 2000 17:06:56 GMT
From: sjlen@ndirect.co.uk (Steve)
Subject: Re: Very easy, quick question....
Message-Id: <slrn8g6728.815.sjlen@zero-pps.localdomain>
On 23 Apr 2000 07:10:20 GMT, AmazingAl5 wrote:
>I just have one question: ALL i'm trying to do is simply execute:
>
> print "Hello World";
>
>on the Win32 system. Yes I do have ActivePerl (the latest version) and I even
>have the latest PDK. The answer would be GREATLY appreciated.
> Thanks!
> AL
A couple of years ago I tried perl on win95, and was also stuck at the very
first hurdle and the solution was that the first line of the file needed
to be something like
#!C:\PERL\BIN\PERL %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
call your script file something like hello.bat, then from the comand line
in the directory of your script type hello and press enter.
Hope this helps.
--
Cheers
Steve email mailto:sjlen@ndirect.co.uk
%HAV-A-NICEDAY Error not enough coffee 0 pps.
web http://www.ndirect.co.uk/~sjlen/
or http://start.at/zero-pps
3:19pm up 3 days, 36 min, 4 users, load average: 1.02, 1.12, 1.08
------------------------------
Date: Sun, 23 Apr 2000 12:45:16 GMT
From: mark_g@cyberdude.com
Subject: Re: Which book?
Message-Id: <8dur8q$kjp$1@nnrp1.deja.com>
I'm getting the impression that "Programming Perl" doesn't cover OOP.
Is this the case?
TIA
--
Mark Grocock (mark_g@cyberdude.com)
In article <39019D38.175D08FE@awod.com>,
Michael Hearne <mhearne@awod.com> wrote:
> I haven't used 'Learning Perl' much, but 'Programming Perl' is
invaluable,
> once you basically know the syntax of the language. I learned Perl by
> stealing code and thumbing through 'Programming Perl'. 'Advanced Perl
> Programming' (I think that's the title) is really good, too, once you
get
> to the stage where you want to do any OO stuff, or interfacing with
Tk.
>
> mark_g@cyberdude.com wrote:
>
> > Which of the O'Reilly Perl books is best for someone who knows a
little
> > bit of Perl programming but wants a more complete knowledge of the
> > language, "Learning Perl" or "Programming Perl" ?
> >
> > TIA
> >
> > --
> >
> > Mark Grocock (mark_g@cyberdude.com)
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 23 Apr 2000 08:56:08 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: Which book?
Message-Id: <g4EM4.2107$JN3.11364@newsfeed.slurp.net>
<mark_g@cyberdude.com> wrote in message news:8dur8q$kjp$1@nnrp1.deja.com...
> I'm getting the impression that "Programming Perl" doesn't cover OOP.
> Is this the case?
The 2nd Edition has two chapters. Chapt 4, References and Nested Data
Structures,
sets the background, and Chapt 5, Packages, Modules, and Object Classes,
goes into
detail, including some hints on object design.
These are not OOP tutorials but, should you choose to use Perl in an OOP
manner,
cover the basic constructs.
The material in the documentation supplied with the Perl package can be used
to supplement
the book, or vice versa.
------------------------------
Date: Sun, 23 Apr 2000 16:08:27 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Which book?
Message-Id: <B5289878.2EA5%elaine@chaos.wustl.edu>
in article 8dur8q$kjp$1@nnrp1.deja.com, mark_g@cyberdude.com at
mark_g@cyberdude.com quoth:
> I'm getting the impression that "Programming Perl" doesn't cover OOP.
> Is this the case?
If you are looking for an OO Perl book, have a look at Damian Conway's
"Object Oriented Perl" published by Manning.
e.
------------------------------
Date: Sun, 23 Apr 2000 10:08:57 PDT
From: Larry R. Waibel <lwaibel@cwia.com>
Subject: Re: Writing to STDIN
Message-Id: <VA.0000002f.0532f8b2@cwia.com>
In article <8dq2ul$cjt$1@brokaw.wa.com>, Lauren Smith wrote:
> Here's a fairly hackish WTDI.
>
> Create a program that prints "N" and call it from your Perl program using
> backticks.
>
Thanks for the idea but I'm not sure it would work. The program is expecting
a 'N' in STDIN. Your program would put it in a variable. I'm looking for a
way to stuff characters directly into STDIN.
------------------------------
Date: 23 Apr 2000 12:12:09 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Writing to STDIN
Message-Id: <87snwcwxli.fsf@shleppie.uh.edu>
>> On Sun, 23 Apr 2000 10:08:57 PDT,
>> Larry R. Waibel <lwaibel@cwia.com> said:
> Thanks for the idea but I'm not sure it would work. The
> program is expecting a 'N' in STDIN. Your program would
> put it in a variable. I'm looking for a way to stuff
> characters directly into STDIN.
perldoc perlipc
hth
t
------------------------------
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 2848
**************************************