Re: ping Purl Gurl? Beginner Level Perl



In article <D4-dncLDQp9ePQfbnZ2dnUVZ_qupnZ2d@xxxxxxxxxxxx>,
Purl Gurl <purlgurl@xxxxxxxxxxxx> wrote:
blmblm wrote:

Purl Gurl wrote:
blmblm wrote:

select STDOUT;$|=1;
@v248=(a .. z);@v216=qw(1 11 12 1 11 12 -8

[...]

Ha! Ha! Now ain't you a cute ass!

Surprise! I actually know something!

I am very surprised.

Right.

Say, maybe Rey and Skitt and those other folks are right that
one can be *too* self-deprecating ....

[ snip ]


I wasted some time trying to understand how a variable could
be named simply "@" or "$" (contrary to what the man pages [1]
were telling me), before deciding that rather than trying
to understand the code by reading it I should just run it.
Once that worked (sort of), I opened the code in a text editor.
vim in a text-only window didn't do a whole lot better than
trn with the high-ASCII characters, but there were enough
clues ....

My code should print,

purl gurl rocks!
PURL GURL ROCKS!
purl gurl rocks!

However, on a single line with previous text vanishing, then
followed by slow deliberate "typing" of one character at a time.
Much like your code but a bit fancier. This is like someone typing,
backspacing out the text, then typing again, several times.

Yes. I may be telling you stuff you already know, but .... :

And it does that on my system too -- but only when I add
that line

select STDOUT;$|=1;

Without that line (or with it, but with the 1 replaced by a 0),
output appears only when a newline is printed. So I get the
two blank lines at the start, and then all of that nifty
typing-and-backspacing stuff is wasted, because nothing
actually appears on the screen until the newline is printed.

Just making sure we're on the same page, though it's probably
not a big deal.

[1] Is this a term known in the Windows world? Explanation
on request. Or you may have enough exposure to Unix/Linux
to know.

Yes, Man Pages. Those manual pages for Perl are very poorly
written. If you are to learn Perl, buy a couple of beginner
books from O'Reilly. "Learning Perl" and "Perl Cookbook" are
two really great books for a start. You can buy both, used,
on Ebay or at Amazon for really cheap. My suggestion is you
not use the Man Pages, this will only slow you down.

Yeah. Well, the Perl man pages seem to me to be in line with
other Unix/Linux man pages -- good as an online reference, not
so good as a tutorial, not the best source of information for
a beginner, but usable if nothing else is readily available.

I do agree with you about the value of a good book, and I
have a copy of one of the O'Reilly books somewhere -- I think
it's _Programming Perl_ -- but have been too lazy to get it
out and start reading. Maybe soon. Sometimes it's more fun
to start by just dinking around a little.

[ snip ]

I want to be sure we are on the same page. This is what
I scraped off my screen before your words vanish,

oyzoyz vf abg fb onq urefrys.

Quite clear there is a one-to-one relationship between
what replaces your text,

blmblm is not so bad herself.

At first, I thought backwards writing but this text flashes
by so quick, I decided to wait and capture.

Yes, obviously a job for output redirection ("capture"?).
(That's what I did with your code, and how I discovered that
it was actually doing something cute with backspaces, which
wasn't apparent from its behavior.)

Looks, at a
quick glance, you have shifted by one half of the number
of letters in our alphabet. Moving from "z" to "m" is
an offset of thirteen.

This seems a rather ROTten way to add creativity.

Quite. Not bad, spotting it without reading the code!

For trivia, you do not need to flush the print buffer
with Perl. Runs fine without your first line.

Maybe on your system [2]. On mine, if I remove that first
line I get different behavior, completely consistent with its
meaning as described in the "perlfunc" man page. Re-read my
description of your program's output.

I am currently running Win XP Pro systems. I need Windows for
all the available programs, not available on *nix machines,
such as my live stock market feed. Making money with my
Windows machines is good motivation for using Win. I also
write a lot, I mean a way lot. I need the graphical word
processors to cut down on my typing time and all that.

Calm down. I didn't say "on that useless piece-of-junk
operating system you're probably running", did I? I might
have thought it, but I didn't say it, so no need to get
defensive about your choice of operating system. Using
something that runs the applications you need makes sense.
I have a couple of dual-boot machines, and much as I prefer
Linux, sometimes booting one of them into Windows is the
quickest way to accomplish a given task.

Here's the point I'm trying to make, though: When you
say

For trivia, you do not need to flush the print buffer
with Perl. Runs fine without your first line.

to me that sounds like you think this is a property of Perl,
and it will work this way everywhere. And I think we agree
that it does not.

[2] It *would* be interesting and useful, however, to know
a little about the environment in which you're running these
programs. My guess is Windows' command shell (command.exe?),
though I could be wrong. It would be completely unsurprising
to me to learn that the Windows command shell and bash (my
current Linux shell) don't behave exactly the same with regard
to buffering of STDOUT. Something that might be interesting --
replace the "1" in that line with a "0" and tell me whether
the program behaves differently in your environment. (It does
in mine.)

Removing the flush, changing from 0 to 1 makes no difference
on a Win machine.

Not that it matters, but I asked about changing from 1 (apparently
the default for Windows) to 0, rather than vice versa.

Flushing is automatic upon "print" being
encountered. Not true for cgi applications but this is related
to a web server. I run Apache on our machines. Apache will
respond to flush commands, in a sense. Flushing is performed
but a final flush does not happen until the cgi application
ends; all printing flushes at program end.

Right, a command shell. This is truly a DOS emulator. I much like
old MS-DOS usage. My experience dates back to DOS 3.x versions and
Win3.x versions. Prior to this, an O/S known as Deskmate which is
an early Radio Shack brand just before Windows hit big. Deskmate,
if I remember right, this places me back in late Seventies or
early Eighties era. Heck, I was a customer of AOL before this
became known as America Online. I can no longer remember what
AOL was called back then, access was dialup through a local
Radio Shack phone number, 1200 baud. I was a teenager then and we
had our baby girl. I needed something, direly needed something
to take my mind off raising a girl more ornery than me.

Our Deskmate computer, used, enjoyed 768 kilobytes of memory,
expanded, and an operating speed of 4 megaHertz; zoom zoom!

The good old days, PC version!

I'm not sure about chronology here, but it could well be that
your early exposure to computers and mine was happening at
about the same time, but in very different worlds: I started
out on mainframes -- a couple of undergraduate courses in the
1970s, six years with IBM-and-compatible mainframes, five
years with various minicomputers, then mostly Unix in grad
school. Probably a fairly typical career path for someone
my age, except for graduate school fairly late in life.

One thing about this career path is that in most of those
jobs someone else was doing hardware setup and at least part
of software setup / sysadmin stuff. So there are gaps in my
knowledge that people who grew up with PCs probably don't have.
I'm working on it. Then again, I think there's stuff I know
that the PC-only people aren't quite clear on.

Yes, buffering on your *nix machine behaves different than Win.

Very believable. But I was curious enough to boot Windows
(XP Pro) on another machine and try some experiments ....

There's a version of Perl on this system that seems to be part
of Cygwin (Unix-like environment for Windows). It's no big
surprise that it behaves like my Linux system:

select STDOUT;$|=0; # buffered output, no cute effects
select STDOUT;$|=1; # unbuffered output, cute effects

But that's in a Unix-like environment. What about something
native? I went to http://www.perl.com, followed links, and
installed something called ActivePerl, which provides among
other things a "perl" command that runs in a command.exe
window. Somewhat to my surprise, though, it behaves just
like the one under Cygwin!

You're getting different results. Different Perl??

However, Windows whoops ass on your puny *nix machine.

Oh, whatever hardware you have can probably run rings around
the machine I'm typing this on -- it's a low-end Dell PC,
which I bought a couple of years as a starter home system,
figuring (correctly) that I wouldn't need much horsepower for
most of the tools I use ....

Oh, wait a minute. I missed my cue there, didn't I? Sorry,
let me try again:

"Oh yeah? That shows how much you know! Linux ROOLZ!"

I dunno. I'm not sure this is an entertaining or useful
activity.

--
Decline To State
(But the e-mail address in the header should work.)
.



Relevant Pages