[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Perl and $_ ?
- Subject: [ale] Perl and $_ ?
- From: mcotner at mediaone.net (Mark Cotner)
- Date: Tue, 12 Jan 1999 07:10:40 -0500
This is a multi-part message in MIME format.
Content-Type: text/plain; charset=us-ascii
Wow, a perl question I can actually answer. I'm still learning myself. My
first project involving modules started yesterday. It's going to be a web
interface to Oracle. Any suggestions from the gallery would be greatly
appreciated. So far I've just read the documentation for DBD-Oracle-0.59,
but have much to learn before this project is complete.
And now the answer to your $_ question.
Personally I don't like the strange shortcuts in perl such as the $_, but
mine's a subjective opinion. The $_ is documented as the default variable
and works in the following way. I most frequently use it during file
operations so that is where I picked my example from:
# Simple counter file exerpt . . . you might want to note that this does not
increment the counter . . .just looks at it
open (COUNTER, "/export/home/nobody/counter") || die ("Unable to open
counter file"); # opens the counter file for reading
# reads the file line by line and performs the following operation on it
# chops the newline after each line
# sets the counter equal to the current line using the default variable
# hmm, not sure what this does, but the book said to do it so I did . . .
You might want to note that my counter file is never larger than 1 line so
the use of the while loop is a bit moot, but works very well to explain the
David S. Jackson wrote:
> Okay, I'm just chugging through "Learning Perl" and came to Chapter 6 and
> the $_ variable. I thought I understood it, but now that I'm chugging
> through Chapter 7 (Regular Expressions) I'm not so sure.
> Could someone explain it to me in their own words with simple examples,
> TIA! :-)
> David S. Jackson http://www.dsj.net
> "You may satisfy all your senses and still not be satisfied."
> --Edward S. Martin
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Description: Card for Mark Cotner
Content-Disposition: attachment; filename="vcard.vcf"
fn: Mark Cotner
org: RoadRunner(formarly MediaOne Express)
adr: 4545 Stonegate Ind. Blvd;;;Stone Mountain;Georgia;30083;United States
email;internet: mcotner at mediaone.net
title: UNIX System Administrator