[7765] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1390 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 29 21:13:50 1997

Date: Sat, 29 Nov 97 18:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 29 Nov 1997     Volume: 8 Number: 1390

Today's topics:
     2 things are the same yet not equal. <sbachman@saveware.com>
     Re: 2 things are the same yet not equal. (brian d foy)
     Re: How do i Preform a search <billg@networkapparel.com>
     Re: last element in an array? <markm@nortel.ca>
     Re: last element in an array? (Tad McClellan)
     newer than new to perl <tuia@msn.com>
     Re: newer than new to perl (Anders Thelemyr)
     PERL CGI's on NT jjunker@aig.vialink.com
     Re: PERL CGI's on NT <knut@webcom.no>
     Perl resources wanted! <ckpwong@undergrad.math.uwaterloo.ca>
     Re: perl shorter than csh challenge!! <markm@nortel.ca>
     Re: posting to a newsgroup (Danny Aldham)
     Re: Q: alternative to Perl? (Jeremy D. Zawodny)
     Re: Q: alternative to Perl? <markm@nortel.ca>
     Re: Q: Learning perl with no progr. experience (brian d foy)
     Question for all... <hegeman@hevanet.com>
     Re: Resource Kit Anomaly (Jeremy D. Zawodny)
     static variables in Perl? <jgoerzen+usenet@complete.org>
     Re: static variables in Perl? <tchrist@mox.perl.com>
     Which function yields FROM in w command ? <byteshifter@shifted-bytes.de>
     Re: Which platform ? (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Re: Windows 95 flock problem (hapless newbie question) <billg@networkapparel.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 29 Nov 1997 16:54:53 -0600
From: The White Rabbit <sbachman@saveware.com>
Subject: 2 things are the same yet not equal.
Message-Id: <34809D3D.7BD8@saveware.com>

Hello People.
Here is how my probelm goes.

I have a server that watches a port.  It connects fine and it then reads
2 
lines of text (a name, and a password).  The server then opens a passwd
file that has 3 fields (name:passwd:referance).  The server checks to
see
if the user name is the same of the first line in the file.  If not,
reads the
next. If it is it then checks the passwd.  Something wasnt working
right,
so I changed it tocheck both the user name and passwd and read the next
line if the user names arn't equal.  I came to the conclusion that name1
does not equal name1.  That is the name1 read from the port, isnt the
same
as name1 read from the passwd file. (exact current code below).

I have tried =~ and eq and neather of them work in a simple if (
$userport eq 
$userfile ) format.  Anyone else have this problem or have any Idea why
I am  
getting this?  They both look the same when I output them (STDOUT).  The
one 
from the port is also chomped already so I know it isnt an extra return.
Could their be some other white space in it? (maybe if someone could
send
me code to take all whitespace out of a var).

Any Ideas?
[Please reply via email to sbachman@saveware.com]
Scott Bachmann

-----
Code:
IT is the port socket that is already opened.
<Snip>
chomp($username = <IT>);
chomp($userpass = <IT>);
open(LISTPASS,"passwd");
while(<LISTPASS>) {
chomp;
$passright=0;
$userright=0;
($user,$pass,$tobe) = split(/:/);
if ($user =~ $username) { $userright=1; logmes "User right.";}
if ($pass =~ $userpass) { $passright=1; logmes "Pass right.";}
if ($userright==0) { logmes "User wrong."; }
if ($passright==0) { logmes "Pass wrong."; close(LISTPASS);return; }
if ($passright==1 && $userright==1) { last; }    
}
if ($passright == 1 && $userright == 1) {
<Snip>


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

Date: Sat, 29 Nov 1997 20:13:18 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: 2 things are the same yet not equal.
Message-Id: <comdog-ya02408000R2911972013180001@news.panix.com>

In article <34809D3D.7BD8@saveware.com>, sbachman@saveware.com wrote:


>I have tried =~ and eq and neather of them work in a simple if (
>$userport eq 
>$userfile ) format.  Anyone else have this problem or have any Idea why
>I am  
>getting this?  They both look the same when I output them (STDOUT).  The

>if ($user =~ $username) { $userright=1; logmes "User right.";}
>if ($pass =~ $userpass) { $passright=1; logmes "Pass right.";}

the binding operator, =~, expects to bind a scalar to a  
substitution, s///; match, m//;  or translation, tr///.  you probably
wanted something like

   $user =~ m/$username/

however, if you want the two scalars to match exactly, you test should
be either

   #anchor at beginning and end   
   $user =~ m/^$username$/  

or

   $user eq $username

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Sat, 29 Nov 1997 16:07:00 -0500
From: Bill Guindon <billg@networkapparel.com>
To: Mike <news@novahome.com>
Subject: Re: How do i Preform a search
Message-Id: <348083F4.448B7555@networkapparel.com>

(Poster CC'd via email)

Mike wrote:
> 
> I am trying to perform a search on some user input for words found in a kill
> file.
> 
>  foreach $killword (@KILLWORDS)
                    ^
>  {
>   if ( $testwords  =~ /$killwords/i)
                                  ^
Looks like a typo.  Could it really be something that simple?

[snip]




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

Date: 29 Nov 1997 15:19:12 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: last element in an array?
Message-Id: <lq1wwhre9mn.fsf@bmers2e5.nortel.ca>

, snailgem@aol.com writes:
> > For the array @matches, the last element of the array can be refered
> > to as $#matches.
> But I did my research before posting. Maybe I have the wrong book (Teach
> yourself PERL in 21 days).The only reference to $# in it is as a number
> output variable. I couldn't find anything on referencing the last
> element of an array. That's when I posted.

Read the manpages... they are so much more complete :-) "man perldata"
on the first page (near the bottom) has the examples:
         $days               # the simple scalar value "days"
         $days[28]           # the 29th element of array @days
         $days{'Feb'}        # the 'Feb' value from hash %days
         $#days              # the last index of array @days

There we go :-)

> >  You can also find out the number of elements in the
> > array by referring to the array name in a scalar context. (and from
> > the number of elements, you can get the index of the last element.)
> > See the perldata man page for details.
> That's what I was trying (apparently wrongheadedly) to do with:
> $matches[$nu_matches] (where $nu_matches=@matches).

> > But what you probably really want to be doing is using the push()
> > function to append elements to an array. See the entry for push() in
> > the perlfunc man page.
> I intentionally didn't want to use push. I eventually want to change the
> file I'm reading in appending  something to the end of @matches. This
> array can be pretty big, and by using push I would have to substitute
> the whole old @matches with @matches plus the element I just pushed in.
> Instead I  just wanted to find the last element of matches
> ($last_match)  and substitute it with $last_match . $tackedon_stuff. But
> maybe I'm wrong about this too (I'm wrong a lot these days).

Don't feel so bad. push() is one of those magically functions where the
first argument is converted to "pass-by-reference" before continuing.
i.e.

   push(@ARRAY, "happy", "land");

gets converted to:

   push(\@ARRAY, "happy", "land");

It's pretty efficient. (Actually i wouldn't be surprised if push() has it's
own opcode in perl giving it even faster execution time) NOTE: You can't
actually enter the second case... otherwise it'll give an error. (If you're
curious about some of the rules for "proto-typed" sub's... you could try
reading "man perlsub")

If you know "around" how big your array is going to get... you can do
something else to increase your efficiency.

   my @ARRAY;
   $#ARRAY = 10000;      # Reserve space 

   local $_;
   while (<STDIN>) {
      # Parse $_ into somthing useable? I dunno what your code does.
      push(@ARRAY, $_);
   }

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Sat, 29 Nov 1997 15:45:51 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: last element in an array?
Message-Id: <fe2q56.tv1.ln@localhost>

??? wrote:

: > For the array @matches, the last element of the array can be refered
: > to as $#matches.
: But I did my research before posting. Maybe I have the wrong book (Teach
: yourself PERL in 21 days).


You have the wrong book  ;-(

Though you don't even need a book if you have a proper perl installation...


: The only reference to $# in it is as a number
: output variable. 


But Andrew was not refering to the $# special variable, he was refering
to the two characters $# immediately preceding _an array name_

This is described in the 'perldata' (where else?) man page:

-------------------------
Scalar values are always named with '$', even when referring to a scalar
that is part of an array.  It works like the English word "the".  Thus
we have:

    $days               # the simple scalar value "days"
    $days[28]           # the 29th element of array @days
    $days{'Feb'}        # the 'Feb' value from hash %days
    $#days              # the last index of array @days
-------------------------

This is right near the top of the primary man page for finding
out about Perl's data types...



: I couldn't find anything on referencing the last
  ^^^^^^^^^^^^^^^                             ^^^^
: element of an array. That's when I posted.
  ^^^^^^^


Eh? You are not looking in the most authoratative Perl reference that
exists in the entire world. Namely the man pages that are shipped
with the perl distribution.

Find out where they got installed on your system.

Use them.



grep 'last element' *.pod

finds three hits. One of them is 'perldata' again:

-------------------------
The length of an array is a scalar value.  You may find the length of
array @days by evaluating C<$#days>, as in B<csh>.  (Actually, it's not
the length of the array, it's the subscript of the last element, because
                                                   ^^^^^^^^^^^^
there is (ordinarily) a 0th element.)  Assigning to C<$#days> changes the
 ...
-------------------------


:  You can also find out the number of elements in the
: > array by referring to the array name in a scalar context. (and from
: > the number of elements, you can get the index of the last element.)
: > See the perldata man page for details.

: That's what I was trying (apparently wrongheadedly) to do with:
: $matches[$nu_matches] (where $nu_matches=@matches).


Not (entirely) wrong headed. $nu_matches should contain the number
of elements in @matches, but since the elements of @matches are
numbered starting at zero rather than one, $matches[$nu_matches] is
one *past* the end of the @matches array.


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


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

Date: Sat, 29 Nov 1997 15:05:32 -0800
From: "jennifer" <tuia@msn.com>
Subject: newer than new to perl
Message-Id: <01bcfd1b$4b1457e0$6a732299@xbwerrsn>

I modestly approach this group to ask a most mundane,simple question and
hopefully, over time, I'll be able to show my face here again.  Here it
goes...
I've installed perl on my win95 system.  It's in the C drive.
I've copied the most simple "hello world" program (if you could call it
that) using my notepad and have named it hello.pl.
I'm at the c:\perl5 prompt in ms-dos and I try to run the program.
C:\perl5\perl hello.pl
A message returns that says "this program cannot be run in dos mode".
I thought that is where you run perl from a win95 system? 


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

Date: Sat, 29 Nov 1997 23:32:59 GMT
From: anderst@XispXalgonet.se (Anders Thelemyr)
Subject: Re: newer than new to perl
Message-Id: <3480a591.6755650@news.algonet.se>

"jennifer" <tuia@msn.com> said:
>I modestly approach this group to ask a most mundane,simple question and
>hopefully, over time, I'll be able to show my face here again.  Here it
>goes...
>I've installed perl on my win95 system.  It's in the C drive.
>I've copied the most simple "hello world" program (if you could call it
>that) using my notepad and have named it hello.pl.
>I'm at the c:\perl5 prompt in ms-dos and I try to run the program.
>C:\perl5\perl hello.pl
>A message returns that says "this program cannot be run in dos mode".
>I thought that is where you run perl from a win95 system? 

I humbly bow my head and join you in hoping for the Answer...  :-)
(Although I haven't installed Perl yet, I just might, and I also thought
you'd run it from a dos box)

______________________________________________________________
*) Remove "XispX" from my address if you feel like emailing me
About BIK!: http://www.swehockey.se/boden/
Hockey Norrland: http://www.algonet.se/~anderst/hockeynorrland/
Hockey Norrbotten: http://www.algonet.se/~anderst/hockeynorrbotten/


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

Date: Sat, 29 Nov 1997 16:21:28 -0600
From: jjunker@aig.vialink.com
To: jjunker@aig.vialink.com
Subject: PERL CGI's on NT
Message-Id: <880841687.581@dejanews.com>

I have a Perl CGI that was written on a UNIX box and 'ported' to NT.  I'm
seeing a major difference in their behaviour.

If I do an:

     open(HANDLE, "file.txt");

on the unix box the Perl CGI script opens a text file in the current CGI
directory.

However, the same command, also run as a CGI but on an NT box, attempts to
open that file BUT in the D:\PERL\BIN directory (where the Perl executable
is).

We have developed a temporary workaround but how can we get Perl on the
NT box to behave correctly?  Is there a patch that I'm not aware of?  Is
there an NT API that gets the current directory?

Any help is apprecitated!!

Jon
jjunker@aig.vialink.com

P.S.  Please, CC: me as well if you would.  THANKS!!

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Sat, 29 Nov 1997 23:42:27 +0100
From: Knut Brobakken <knut@webcom.no>
To: jjunker@aig.vialink.com
Subject: Re: PERL CGI's on NT
Message-Id: <34809A53.9A9427E0@webcom.no>

This is a multi-part message in MIME format.
--------------335DB9D41E142018F5930D89
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

You should check out the documentation of the Win32 extentions to Perl
(assuming you use the ActiveState port of Perl (which is freely
obtainable from www.activestate.com))

These are in your perl\docs\Perl-Win32 directory.

I quote from the file called "win32ext.html":

Win32::GetCwd 
     Returns the current active drive and directory. This function does
not return a UNC path, since the functionality required to required
     for such a feature is not available under Windwos 95.

Win32::SetCwd NEWDIRECTORY 
     Sets the current active drive and directory. This function does not
work with UNC paths, since the functionality required to required
     for such a feature is not available under Windwos 95.


Hope this works! Good Luck!

Knut Brobakken
(knut@webcom.no)

jjunker@aig.vialink.com wrote:
> 
> I have a Perl CGI that was written on a UNIX box and 'ported' to NT.  I'm
> seeing a major difference in their behaviour.
> 
> If I do an:
> 
>      open(HANDLE, "file.txt");
> 
> on the unix box the Perl CGI script opens a text file in the current CGI
> directory.
> 
> However, the same command, also run as a CGI but on an NT box, attempts to
> open that file BUT in the D:\PERL\BIN directory (where the Perl executable
> is).
> 
> We have developed a temporary workaround but how can we get Perl on the
> NT box to behave correctly?  Is there a patch that I'm not aware of?  Is
> there an NT API that gets the current directory?
> 
> Any help is apprecitated!!
> 
> Jon
> jjunker@aig.vialink.com
> 
> P.S.  Please, CC: me as well if you would.  THANKS!!
> 
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet
--------------335DB9D41E142018F5930D89
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Knut Brobakken
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Knut Brobakken
n:              Brobakken;Knut
org:            WebCom
adr:            Postboks 3944 Ullevaal, 0806 OSLO;;Hvitsteinbakken 5, 3080 HOLMESTRAND;;;Internet UIN: 4203261;Norge
email;internet: knut@webcom.no
tel;work:       22 18 76 31
tel;fax:        22 18 76 01
tel;home:       33 05 17 71
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------335DB9D41E142018F5930D89--



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

Date: Sat, 29 Nov 1997 18:10:26 GMT
From: Cindy Wong <ckpwong@undergrad.math.uwaterloo.ca>
Subject: Perl resources wanted!
Message-Id: <Pine.SUN.3.95q.971129125329.25140A-100000@napier.uwaterloo.ca>

Hi all!

As an academic requirement, I have to write a report of some sort.  And
since I found myself *very* interested (or addicted, whichever you prefer
;) to perl, I'm thinking of writing something about perl.  The report will
be around 2000-3000 words.  Below is a list of possible topics I have
thought of so far:

- evolution of perl
- strength and weaknesses of perl
- perl vs c++ (or interpreted vs compiled in general)
- security issues about perl
- perl and WWW (or intranet)
- object-oriented programming in perl
- a user manual

I'm still in the stage of researching materials, and since I'm fairly new
to perl (I didn't know what it is 6 months ago), I'm calling for sources
of old perl documents, probably old perl man pages or FAQ.

Meanwhile, maybe I should start surfing CPAN, www.perl.org and
www.perl.com ...

If anyone has any kind of suggestions or sources, please email me at
  ckpwong@undergrad.math.uwaterloo.ca

Any help is appriciated!

Cindy
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/IT/M/O dx s-:- a--- C+++>$ U++>++++$ P+++>++++$ L++>++++ 
E>++ W++ N++ o? K? w-->--- O? M V? PS PE+ Y+ PGP?>++ !t !5 X 
R+ tv b++ DI++++ !D G>+++ e+>++ h! r++ x? 
------END GEEK CODE BLOCK------



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

Date: 29 Nov 1997 15:06:48 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: perl shorter than csh challenge!!
Message-Id: <lq1zpmnea7b.fsf@bmers2e5.nortel.ca>

abigail@fnx.com (Abigail) writes:
> Bryan Wilkinson (nardo@pobox.com) wrote on 1551 September 1993 in
> <URL: news:34806f1c.6349850@news.supernews.com>:
> ++ 
> ++ here it is, in two lines of perl
> ++ 
> ++ open(FILE, $file_name);
> ++ eval('$'.(grep(/^c/, <FILE>))[0]);
> ++ 
> ++ and with backticks it can be done in one line:
> ++ 
> ++ eval('$'.(grep(/^c/, `cat $file_name`))[0]);
> 
> One line, no backticks, no eval:
> 
> perl -wane '$cvalue = $F [2] if $F [0] eq "c"' filename
> 

I hate to be the one to say it... but what's the point in putting it in
$cvalue if it doesn't ever come back out? :-) And btw... this basic string
(with random spaces stripped) was in my original post :-)

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: 29 Nov 1997 12:16:12 -0800
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: posting to a newsgroup
Message-Id: <65pt6c$hqj$1@lennon.postino.com>

X-Newsreader: TIN [version 1.2 PL2]

Chu Tsz-Tat (ctt@usa.net) wrote:
: anybody know how to post message to a newsgroup using perl scripts?
: i'm quite new to perl, so i dont know how to do?
: can itbe done by 'sendmail'?

I run this script every 15 minutes to push news out from our
server to our ISP.

#!/usr/bin/perl -w 
# script to post news
$|=1;
print "Running..\n";
require News::NNTPClient ;
$c = new News::NNTPClient("204.191.136.3") || die "Down $1";  # news.istar.ca
open(LIST,"/usr/local/spool/news/out.going/istar") || exit ; # nothing to post
while (<LIST>) {
    @article="" ;
    print "Posting $_ \n";
    @article_id = split(/ /,$_) ;
   open(ARTICLE,"</usr/local/spool/news/$article_id[0]") || die "open $! \n";
   while(<ARTICLE>) {
     push(@article,$_) ;
   }
    close(ARTICLE);
  if( $c->post(@article)) {
		print "Article transfered\n";
		} else {
		$result=$c->message ;
		print "Article rejected: ", $result,"\n" ;
		@result=split(/ /,$result) ;
		print "Result 0 is : $result[0] \n";
		unless ($result[0] eq "435") { die "$result" };
		}
   }


--
Danny Aldham           SCO Ace , MCSE , JAPH , DAD
I wak'd, she fled, and day brought back my night. jm


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

Date: Sat, 29 Nov 1997 20:28:34 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Q: alternative to Perl?
Message-Id: <34817ac8.9063853@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Sat, 29 Nov 1997 10:47:36 -0800, "Xah" <xah@best.com> wrote:

>Are there alternative languages comparable to Perl with respect to text
>manipulation?
>
>I'm wondering because I'm not too thrilled by Perl's grammar, but need
>Perl's text manipulation power.

Python (1.5) now has a Perl-style regex module. Perhaps Phyton's
OO-syntax would be easier for you?

  http://www.python.org/

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: 29 Nov 1997 15:25:48 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Q: alternative to Perl?
Message-Id: <lq1vhxbe9bn.fsf@bmers2e5.nortel.ca>

"Xah" <xah@best.com> writes:
> Are there alternative languages comparable to Perl with respect to text
> manipulation?
> 
> I'm wondering because I'm not too thrilled by Perl's grammar, but need
> Perl's text manipulation power.

sh, sed, and awk? :-) (that was a joke... laugh :-) )

Perl offers alot more than text manipulation to its users. I don't think the
problem is perl's grammar, but rather it's idea that "you can do anything you
want however you want." Programmers take that too far sometimes and do
"whatever" they want in the first way they think of implementing it... alot
of NASTY perl code is in existance today. This doesn't make perl nasty...
it means people have to start using discipline when writing perl. For every
problem, there is a clean and tidy solution, as well as a really messy
hard-to-understand solution.

I don't know of any other languages offhand that give the user as big a
handle on regular expressions as perl does. Try converting some of the
regexp heavy code you find into C and i think it will get longer X10 :-)

sorry i couldn't help :-)
mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Sat, 29 Nov 1997 20:06:30 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Q: Learning perl with no progr. experience
Message-Id: <comdog-ya02408000R2911972006300001@news.panix.com>

In article <8c1zzza71z.fsf@gadget.cscaper.com>, Randal Schwartz <merlyn@stonehenge.com> wrote:

>Unfortunately, I have yet to read a "from zero programming to workable
>Perl knowledge" book that I'd recommend.  Most of the books that
>dummies can read are books that only dummies would want to read. :-)

the catch is that you have to start *somewhere*, and for a lot of
programming newbies with whom i've dealt, "Learning Perl" [1] has been 
an okay place to start.  of course, these people (mostly science types)
didn't stop there - their noses were in books on numerical methods,
database thingys, and algorithm theory too - but at least with Perl
they were getting useful work done the same week that they started with
Perl, whereas the start-up time with FORTRAN and C (and even Java) was 
much longer, even after they had been working with Perl.

part of a programmer's skill is picking up things by reading, and 
"Learning Perl" is a gentle introduction to this since the style is
very readable (instead of technically dense, which you get when you
move on to the reference work "Programming Perl" [2]), especially if you
pick up on the hidden themes.

[1] Learning Perl
Randal L. Schwartz & Tom Christiansen
ISBN 1-56592-284-0 
<URL:http://www.oreilly.com>

[2] Programming Perl
Larry Wall, Tom Christensen & Randal L. Schwartz
ISBN 1-56592-149-6
<URL:http://www.oreilly.com>

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
cartoon fans should enjoy "Learning Perl"


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

Date: Sat, 29 Nov 1997 11:19:26 -0800
From: Chris Hege <hegeman@hevanet.com>
Subject: Question for all...
Message-Id: <34806ABD.C8D6E09D@hevanet.com>

I am doing an english paper for school and I need some opinions on
whether computer programming should be taught as a required class from
elementary or middle school and on up.
If you could give me a minute of your time that would be great.  Thanks
everyone
Chris



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

Date: Sat, 29 Nov 1997 20:27:10 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Resource Kit Anomaly
Message-Id: <3480792e.8653883@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On 29 Nov 1997 10:33:18 -0800, Russ Allbery <rra@stanford.edu> wrote:

>If you went to the Perl conference, they already *gave* you a free book,
>so why complain?  :)

Oh yeah... That one only cost how much of the $700+ conference? :-)

No, I'm not complaining there...

>Personally, like most of you, I already own a lot of
>O'Reilly books, but I won't rule out wanting to buy 10 more over the next
>year.  They're good.

Agreed. They are good. I, however, am unlikely to buy 10 more in the
next 12 months. I've already got about 8 books on my stack of books to
read. :-(

>This is a really standard sort of offer; I'm not sure why people are
>complaining.

Probably because O'Reilly tends to be very good about not sending us
"FANTASIC OFFERS" like most other book companies. When I got a card
from them to let me know of this wonderful sale, I opened it right
away to see what it is I qualified for. [Sales junk from most other
companies goes directly to the trash--without evening opening it
first.]

Either that, or we just like to complain once in a while. :-)

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: 29 Nov 1997 11:15:55 -0600
From: John Goerzen <jgoerzen+usenet@complete.org>
Subject: static variables in Perl?
Message-Id: <87n2infwok.fsf@garfield.complete.org>

Hi,

In C, one can declare a variable inside a function to be static.  This
causes that variable to be within only that function's scope (not
ordinarily accessible elsewhere) but the variable is not recreated
each time the function is called -- its contents are preserved.  Can a
Perl subroutine do the same thing?  If so, how?  If not, why not?  Is
there a better equivolent in Perl?

Thanks,
John

-- 
John Goerzen          | Developing for Debian GNU/Linux (www.debian.org)
Custom Programming    | Debian GNU/Linux is a free replacement for
jgoerzen@complete.org | DOS/Windows -- check it out at www.debian.org.
----------------------+----------------------------------------------
Find out how to avoid all those pesky crashes, lockups, application errors,
and slow applications at http://www.debian.org -- Debian can replace Windows
95 with a much more stable operating system.


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

Date: 30 Nov 1997 01:05:43 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: static variables in Perl?
Message-Id: <65qe57$k7m$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, John Goerzen <jgoerzen+usenet@complete.org> writes:
:In C, one can declare a variable inside a function to be static.  This
:causes that variable to be within only that function's scope (not
:ordinarily accessible elsewhere) but the variable is not recreated
:each time the function is called -- its contents are preserved.  Can a
:Perl subroutine do the same thing?  If so, how?  If not, why not?  Is
:there a better equivolent in Perl?

This is covered in the standard perlsub(1) manpage included with
every proper perl distribution.  Citing the v5.004_04 version,
look for this:

       sub BEGIN {
	   my $secret_val = 0;
	   sub gimme_another {
	       return ++$secret_val;
	   }
       }

And the surrounding explanation.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    "Historically speaking, the presence of wheels in Unix has never precluded
    their reinvention."
    	--Larry Wall


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

Date: Sat, 29 Nov 1997 23:02:15 +0100
From: Michael Agbaglo <byteshifter@shifted-bytes.de>
Subject: Which function yields FROM in w command ?
Message-Id: <348090E7.2C685D16@shifted-bytes.de>

10:55pm  up  4:48,  2 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@  IDLE   JCPU   PCPU  WHAT
byteshif ttyp0    pitfall.shifted-  6:13pm  0.00s  0.40s  0.05s  w
byteshif ttyp1    pitfall.shifted- 10:37pm  1:39   0.38s  0.16s  -bash

as you can see the FROM field is truncated... but I like to get the FQDN
to set $DISPLAY.
any idea which function to call ?

replies via email preferred - thanks.


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

Date: Sat, 29 Nov 97 17:27:04 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Which platform ?
Message-Id: <3480973f$1$ofn$mr2ice@speaker>

In <3480b101.9311160@news.tornado.be>, on 11/28/97 at 11:55 AM,
   bart.mediamind@tornado.be (Bart Lateur) said:
+-----
| I think you should test the $^O special variable.
| Although this tells me I'm on OS/2, while I'm only using the OS/2 port on a
| DOS/Win3.1 PC. Hmm.
+--->8

Perl's configuration mechanism was never intended to cope with multiplatform
EMX/RSX... besides, would you complain about it doing the same in a PC
emulator running under MacOS/Solaris/SCO/whatever?

-- 
brandon s. allbery           [Team OS/2][Linux][JAPH]        bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)                  KF8NH
"Never piss off a bard, for they are not at all subtle and your name scans to
 `Greensleeves'."  ---unknown, quoted by Janet D. Miles in alt.callahans



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

Date: Sat, 29 Nov 1997 16:29:12 -0500
From: Bill Guindon <billg@networkapparel.com>
To: Benjamin Geer <benjamin.geer@worldnet.att.net>
Subject: Re: Windows 95 flock problem (hapless newbie question)
Message-Id: <34808928.D4F70B03@networkapparel.com>

To the best of my (admittedly limited) knowledge, Win95 does NOT support
FLOCK.  This topic was recently (heavily) covered.  Try searching
www.dejanews.com for more info.

(sender CC'd via email)

Benjamin Geer wrote:
> 
> Using code lifted from "Learning Perl for Win32", I'm writing a little CGI
> script, under Windows 95, that takes form input and appends it to a file.
> The program runs fine, as long as this line is commented out :
> 
> flock(MESSAGES, $LOCK_EX) || bail("Can't flock $filename : $!");
> 
> Otherwise, the program seems to hang there, and the browser gets an
> incomplete page.  Perhaps flock is never getting the lock on the file?  This
> happens even with a freshly created file.
> 
> I'm using ActiveState's Perl 5.003 Build 312 and Microsoft's Personal Web
> Server.
> 
> I'm really stumped.  The program is so small that I'm attaching it.




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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1390
**************************************

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