Teach me how to fish, regexp

H

Henry

Sam Holden:

Thanks for your post on this thread:

The risk with that is that the man pages on your system will document
the perl installed on your system. The web versions will document
some version of perl which might not be the one you are using.

The basics should be the same, right?
Plus the man pages also document the modules you have installed, rather than
a random selection of them...
Of course. But, as I've said in another post on this thread just now, I
don't find the man pages a very friendly environment, especially for
material of this complexity.
Why not. It's true after all, and hence a reasonable mnemonic.

I guess you are talking about a typographic convention, as in "Candy is
dandy/But liquor is quicker" (Credit: Ogden Nash). I guess I don't see the
parallel, sorry.
"" and undef are the only two values that could be used as something special,
since everything else is a possible literal end of line marker.

I guess so. That issue hasn't stopped the use of escape sequences in other
contexts, right?
undef as "slurp" mode makes sense, since that's more common than paragraph
mode (in my experience anyway) and being undef means a simple 'local $/;'
is enough to enable it.

Some of my colleagues are horrified that I would use slurp mode, so I guess
experiences vary widely.
That leaves "" for something else, and paragraph mode is a good choice in
my opinion, since it's a reasonably commonly wanted operation.

I trying to grasp this, but failing. Maybe after I learn more about perl it
will become clear.
Of course when references arrived a new possibility became available and
(since it's perl) was used...

References? Sorry. I keep getting deeper and deeper. Do I need to
understand 'references'?

Thanks,

Henry

(e-mail address removed) remove 'zzz'
 
H

Henry

HelgiBriem:

Thanks for your post on this thread:

What do you mean? Plain text, a pageful at a time, readily
searchable, isn't friendly enough for you? How much more
friendly can you get. If you prefer, the Activestate distribution
of Perl for Windows, Linux and Solaris, comes with all the
documentation in html format. I use that a little, but usually
prefer perldoc.

I would not want to argue personal preferences, not at all. My preference
would be for html. As I'm working on MacOS X, apparently I'm out of luck.
I disagree. Programming logic in itself takes a while, but
if you are a programmer, you can pick up enough Perl to do
useful things in a couple of weeks, *if* you learn how to use
perldoc. It is the very core of learning Perl, more important than
anything else.

I am a programmer by profession, and I've accomplished some useful work in
perl already. Perhaps this is again a matter of personal preference as
well: I find perl chaotic and not well-bounded. Perhaps that simply means
I'm a different kind of programmer (I am; I work in embedded systems mostly)
or an old-fashioned programmer (possibly).

Would you mind sharing a few bullet points about the keys to getting the
most out of perldoc? From my few first tries, it seems very awkward.
Maybe I'm doing something completely wrong, but I seem to need to do a
vi-style ":q" just to get back to the shell at the end of a doc.

Thanks,

Henry

(e-mail address removed) remove 'zzz'
 
T

Tad McClellan

Henry said:
(e-mail address removed) wrote on 10/9/03 3:53 AM:


[ talking about Perl's std docs ]

My preference
would be for html. As I'm working on MacOS X, apparently I'm out of luck.


No you're not.

Type this:

perldoc pod2html

:)

Would you mind sharing a few bullet points about the keys to getting the
most out of perldoc?


Never use it. (that isn't a joke)

I don't.

I use the std docs many times each day, but never through perldoc.

I only use perldoc as a shorthand for pointing others to the
relevant docs.

I prefer to use vi and grep to read the raw *.pod files.

Because it lets me do things that perldoc does not let me do.



Doing a word search of _all_ of the docs works sometimes, but most
often finds too many hits, so then I try searching other ways:

use an Initial Cap on the search term rather than all lower case,
headlines and the first word in a sentence might be most relevant.

Make an "index" file and grep in the index:

grep ^= perlfaq*.pod >faq.heads

grep ^= *.pod >all.heads

I also have defined an alias that launches my editor with
perlfunc already in it for looking up function arguments and such.

From my few first tries, it seems very awkward.
Maybe I'm doing something completely wrong, but I seem to need to do a
vi-style ":q" just to get back to the shell at the end of a doc.


That is a feature of your pager program, not of perldoc.

perldoc perldoc

says how to set things up to use a different pager if you don't
like whatever the default is on your system.
 
T

Tad McClellan

Henry said:
(Jeez, yet another permutation on scoping rules to learn.)


And here is where you can do that:

"Coping with Scoping":

http://perl.plover.com/FAQs/Namespaces.html

Wow, yet another variation on syntax requirements.


No, you have that backwards.

Yet another _lack_ of syntax requirements.

It lacks the requirement of always using parens.

It lacks the requirement of never using parens.

Perl is into freedom, you get to choose.

I would just as soon
have parens for function arguments required, but that probably shows I
haven't used perl long enough.


I think you are right.

Perl isn't like "other programming languages".

Perl is not a Bondage And Discipline language like, say, Java or C++.

I recommend \d instead of [0-9]).

OK, these are equivalent, though, right?

Right.



It is a matter of writing the easiest-to-read code.

(the corollary is you use whichever _you_ think is easiest to read,
more choice.
)
 
K

ko

Tad said:
[snip]
Would you mind sharing a few bullet points about the keys to getting the
most out of perldoc?

Never use it. (that isn't a joke)

I don't.

I use the std docs many times each day, but never through perldoc.

I only use perldoc as a shorthand for pointing others to the
relevant docs.

I prefer to use vi and grep to read the raw *.pod files.

Because it lets me do things that perldoc does not let me do.



Doing a word search of _all_ of the docs works sometimes, but most
often finds too many hits, so then I try searching other ways:

use an Initial Cap on the search term rather than all lower case,
headlines and the first word in a sentence might be most relevant.

Make an "index" file and grep in the index:

grep ^= perlfaq*.pod >faq.heads

grep ^= *.pod >all.heads

I also have defined an alias that launches my editor with
perlfunc already in it for looking up function arguments and such.

Nice example - thanks :)
 
H

Henry

Tad:

Thanks for your posts on this thread:

#1

Type this:

perldoc pod2html

:)

Jeez, is there no part of perl that doesn't have a secret door... behind
which is (of course) an additional secret door?
Never use it. (that isn't a joke)

I don't.

I use the std docs many times each day, but never through perldoc.

I only use perldoc as a shorthand for pointing others to the
relevant docs.

I prefer to use vi and grep to read the raw *.pod files.

I'm perfectly willing to use grep, but vi is pushing it. The last time I
used it for anything significant was over 20 years ago.
Because it lets me do things that perldoc does not let me do.

I can see that.
Doing a word search of _all_ of the docs works sometimes, but most
often finds too many hits, so then I try searching other ways:

use an Initial Cap on the search term rather than all lower case,
headlines and the first word in a sentence might be most relevant.

Good suggestion!
Make an "index" file and grep in the index:

grep ^= perlfaq*.pod >faq.heads

grep ^= *.pod >all.heads

I also have defined an alias that launches my editor with
perlfunc already in it for looking up function arguments and such.

I can see why you would do this. Ummm, would it be silly to ask why an
effective index isn't simply part of the doc package? Of course it would.
That is a feature of your pager program, not of perldoc.

perldoc perldoc

says how to set things up to use a different pager if you don't
like whatever the default is on your system.

Hmmm, there's a mystery here that would lead me _way_ off topic. I'll work
it out.
#2


And here is where you can do that:

"Coping with Scoping":

http://perl.plover.com/FAQs/Namespaces.html

Bookmarked! Excellent!

Hmmmm. I find the use of "my" as in

for (my $i=0; $i<100; $i++) {

.... "to confine the scope of $i to the for loop." either brilliant or
appallingly chaotic, I'm not sure yet.
No, you have that backwards.

Yet another _lack_ of syntax requirements.

It lacks the requirement of always using parens.

It lacks the requirement of never using parens.

Perl is into freedom, you get to choose.

Philosophy, eh? (I'll note that "you get to choose" rhymes with "Nothing
left to lose". Ooop, never mind.)

OK, I'll choose to always use parens to enclose function call args.
I think you are right.

Perl isn't like "other programming languages".

Perl is not a Bondage And Discipline language like, say, Java or C++.

Jeez, I'm a pervert!

Robert Frost defined "freedom" as "moving easy in harness". I guess (oops)
that proves he was into B&D, too.
It is a matter of writing the easiest-to-read code.

(the corollary is you use whichever _you_ think is easiest to read,
more choice.

Well, yes, of course. I'll do that. But I would do it anyway, even with
some inherent restrictions on choice form the language itself.

Thanks,

Henry

(e-mail address removed) remove 'zzz'
 
T

Tad McClellan

Henry said:
(e-mail address removed) wrote on 10/10/03 4:50 PM:


I'm perfectly willing to use grep, but vi is pushing it.


vi is "meta" there.

Substitute "my favorite editor" where I said "vi".

either brilliant or
appallingly chaotic, I'm not sure yet.


We get that a lot here. :)

I remember when I first learned Perl too...


Just in case you don't have enough to read yet (heh), here's Larry
talking about how Perl is more like natural language that most
"conventional" programming languages:

http://www.wall.org/~larry/natural.html


Perl is a bit of a shift in thinking if you are used to other
programming languages.
 
H

Henry

Tad McClellan:

Thanks for your post on this thread:

(e-mail address removed), Tad McClellan at


vi is "meta" there.

Substitute "my favorite editor" where I said "vi".

OK. (Unfortunately, I haven't found the right editor for MacOS yet, but
_that_ is a completely different subject.)
We get that a lot here. :)

I remember when I first learned Perl too...

Just in case you don't have enough to read yet (heh), here's Larry talking
about how Perl is more like natural language that most "conventional"
programming languages:

http://www.wall.org/~larry/natural.html


Perl is a bit of a shift in thinking if you are used to other programming
languages.

(We seem to be diverging form the original topic a bit. I'd be willing to
take this off line, if that makes sense.)

I read Larry Wall's piece on "Natural Language Principals in Perl" as you
recommend. I would have to say that his personal approach --flexibility,
humor, and modesty-- are very refreshing.

Since he discusses "natural language" I'm wondering why he didn't write perl
in actual natural language, e.g., for my issue maybe something like this:
"Slurp standard input in paragraph mode. Split at every at least double
empty line followed by a section number..." One could define "section
number" either in quasi-english terms or --if necessary-- as a regular
expression, or dip deeper via extensions as required.

I don't find his approach wholly convincing, though. I'd like to defer
further comment until I've spent more time using perl, and --in particular--
until after I've solved the problem I set out to do.

Hmmm...I've almost forgotten... Oh, that's it, I was trying to sniff some
legal codes, do some massaging of the content to make it more amenable to
analysis. There's no doubt in my mind that I'll be able to do this with
perl, and nothing but perl. All the components, and much more, are
available. I'm simply worried about mastering chaos in two regimes at
once.

Thanks,

Henry

(e-mail address removed) remove 'zzz'
 
A

Anno Siegel

[ talking about Perl's std docs ]
Never use it. (that isn't a joke)

I don't.

I use the std docs many times each day, but never through perldoc.

I only use perldoc as a shorthand for pointing others to the
relevant docs.

I prefer to use vi and grep to read the raw *.pod files.

Because it lets me do things that perldoc does not let me do.

I like perldoc for its ability to find docs in places I don't care to
remember. "view `perldoc -l <something>`" gives me both worlds.

Anno
 
R

Roy Johnson

David H. Adler said:
That caveat is exactly what makes it a bad *reference*.

No, it's a fine reference for anything that isn't likely to change.
Very few things have changed to be backward-incompatible. Very few. So
if you look it up in the Camel, it's almost sure to work.

There might be new features you don't get informed about, but as a new
Perl programmer, it's unlikely that those details are what you're
looking for. If I need to know the arguments to split(), that's not
going to change. The Camel is a good *basic* reference.

If you want an alternative to looking everything up online, the Camel
is the way to go. If you don't, yay. Perldoc is always there for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top