[29045] in Perl-Users-Digest
Perl-Users Digest, Issue: 289 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 1 14:10:07 2007
Date: Sun, 1 Apr 2007 11:09:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 1 Apr 2007 Volume: 11 Number: 289
Today's topics:
Re: A Perl Beginner <please@nospam.net>
Re: A Perl Beginner <tadmc@augustmail.com>
Re: A Perl Beginner <please@nospam.net>
Help developing web app darioses@gmail.com
Re: How to make send key ([tab] [tab]Text [Enter]) in s <lambik@kieffer.nl>
Pop3 emulation for Outlook Client dgcoventry@gmail.com
Re: Pop3 emulation for Outlook Client <thepoet_nospam@arcor.de>
Re: Pop3 emulation for Outlook Client dgcoventry@gmail.com
Regexp question John.Peterson.jr@gmail.com
Re: Regexp question <thepoet_nospam@arcor.de>
Re: Regexp question <wahab-mail@gmx.de>
Re: Regexp question <rvtol+news@isolution.nl>
Re: Regexp question <jurgenex@hotmail.com>
Re: Regexp question <purlgurl@purlgurl.net>
Re: Regexp question <stoupa@practisoft.cz>
Re: Shifting Away <please@nospam.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 01 Apr 2007 01:41:49 -0700
From: Xiong Changnian <please@nospam.net>
Subject: Re: A Perl Beginner
Message-Id: <please-083435.01414901042007@free.teranews.com>
In article <1174315194.575442.128730@l77g2000hsb.googlegroups.com>,
"The light" <tochiunamka@gmail.com> wrote:
> What will be
> best
> way to start?
I think it's a good question. I'd suggest you forget what you want
ultimately to do -- for the time being. Your mission may be just a tad
advanced for your first learning project.
First, download and install perl. It's available for your platform; I'll
bet you a dollar. See:
http://www.perl.org/get.html
You want perl itself; you can get more modules later. You'll get a lot
of them with the standard download anyway.
Second, be sure you have a decent text editor. You can use almost
anything, including Office Word, but a "real" text editor is the right
tool for the job. If you're not on a Mac, too bad; no BBEdit for you.
But you do have many choices:
http://www.google.com/search?q=text+editor
Crimson Editor is a free download for Windows:
http://www.crimsoneditor.com/
Third, write the following code in your new text editor and run it with
your new copy of perl:
use strict;
use warnings;
print ("hello, world");
See what happens. Now, make it say something else. Then, without looking
up how, change it so that it does a simple arithmetic problem, like 432
+ 9.05. Take a guess and try that. If it doesn't work, try something
else.
Try some more stuff, whatever comes into your head. If you have any kind
of programming background at all, write something that ought to work in
that language. Run it and try to fix it so it runs under Perl. Don't be
scared if it works first time!
Forget about HTML for now. Basically, nothing you write for a web
browser will do anything for you in Perl. Later, you will learn how to
get Perl to write HTML *for* you. Not yet.
Fourth, start reading about Perl. Others will tell you to start here or
here but I say it doesn't matter much where you begin, since you'll
eventually make the rounds of quite a few standard books and online
resources. You might begin, as one poster suggested, with:
http://learn.perl.org/
I didn't; I dove into the "man" pages, such as perlfaq, perlsyn, perlop,
perlsub, installed along with perl itself on your own machine. Soon,
you'll want a copy of the Camel Book:
Programming Perl, 3rd Edition, Wall, Christiansen, Orwant
It's an O'Reilly book so you should be able to find it anywhere, even at
Fry's. The Llama Book is also good to have and you might rather start
there:
Learning Perl, 3rd Edition, Schwartz, Phoenix
Do *not* try to read all at one sitting! Perl books are like fine
literature; you read a page, then you think about it awhile. If
something sparks a thought, write some code and run it. See what it
does.
There is no shame in copying code directly out of the book. But it gets
more fun when you tinker with it to see what you can change. Things get
interesting when you are fooling with an example from *this* book on
page 123 and you remember a line from *that* book; put them together and
see what happens.
Spend a lot of time reading docs and writing small programs. Then, spend
a lot more time reading docs and writing more small programs. Move up as
fast as you feel comfortable.
At some point, it will not hurt you to read one or another "best
practices" guide. They do not agree on all points so take them for what
they are: style guides, not word of law. But in general, clean code is
happy code.
Read this newsgroup. Read another newsgroup. Read this newsgroup some
more.
Spend some more time reading docs and browsing around online for
discussions of features that interest you. Go back and rewrite some of
the stuff you wrote a couple weeks ago. Make it better.
Fifth, find a Perl Buddy. The ideal Perl Buddy is also learning Perl but
is a little ahead of you. The neighborhood Perl Wizard is probably not
the best choice but if you can get him/her/it to speak, listen. There's
nothing wrong with a Perl Buddy who is just about where you are. Both of
you will learn from one another and nobody loses or feels he's wasting
time. A good Perl Buddy lives two houses down on the same side of your
street and works the same shift as you. Spend time with your Perl Buddy.
Continue to read every single thing about Perl you can lay hands on.
Write code until your fingers cramp, then take a break. Learn to look
with suspicion when someone tells you that you must Do It This Way. When
you hear this, go to the keyboard and Do It That Way. Then start over
and Do It Another Way.
All the programs you are writing are learning projects. It doesn't
matter what rules you break so long as you don't build bad habits.
Decide for yourself what a "bad habit" is. Air your opinions cautiously.
Be ready to change them radically and quickly.
Write more code.
Write more code.
Start insisting that your code really works.
Sixth, you are now ready to tackle the *job*, which need you first
mentioned. Narrow your field of study to the specific areas that touch
on the job. Read more stuff. Post questions here. Talk to people. Code
up your solution. Make it work. Make it better.
Done.
* * *
In Case of Failure:
You will repeatedly encounter, at short intervals and at many levels,
failure. Your code will not work as expected -- or, occasionally, *will*
work when you think it shouldn't. You may encounter what Pirsig called
the "gumption trap" -- air hissing from your brain. You may try
everything you can imagine and still fail to get the motorcycle running.
You will receive much sage advice from Real Programmers when your code
fails. Here is my two cents:
* Remember that failure is the most important part of learning in
general and especially of programming. There is no learning without
failure. All your learning efforts are nothing until, intentionally or
not, you fail. Only then can you put your brain in gear and try to
figure out WHY.
* Understand that programming is a purely intellectual, logical
exercise. The machine does not care what you think, only what you write.
Your muttered pleas, threats, and curses are unheard.
* Read Zen and the Art of Motorcycle Maintenance, Robert M. Pirsig. It's
not about Zen and it's not really about motorcycles, either. It's partly
about the process of thinking and partly about a man who took a very
long trip inside his head. Nobody should attempt to solve any problem
without this kind of background. (IMO.)
* Look at your code awhile without thinking too much about it. Wait for
your error to stand up and talk to you. While this may seem silly at
first, it is the fastest way to find some bugs. It's a useful skill to
develop and the only way to do so is to try it.
* If your code is throwing an exception or reporting a warning, perl
will report a line number in the source. This *may* be near the actual
place you screwed up. Remember that when perl reports a slew of errors,
only the first one or two are likely significant. Concentrate on those.
* Bring out the debugging tools. Simple problems are often discovered by
salting your code with print statements. Perl has a debugger; learn to
use it. Learn how to set breakpoints and step through just the buggy
code, avoiding the stuff that works.
* Be honest. Did you do something you *knew* was a bit funny? Did you
use a word, symbol, idiom, or gadget without *certainly* understanding
it? Go back to the docs and read up. Be sure you understand exactly what
you think all your code really does. Watch out for "black box"
explanations rolling around in your head. Open them up and see what's
inside.
* Go back to your last working backup and run it again. (You *are*
making and filing away regular backups. Right?) Does it still work? If
not, what could possibly have changed? If so, what have you changed
since?
* Watch out for value traps. You may want to do something that you think
will be easy or a really good idea; later, you are blocked from solving
the big problem because you are mentally committed to this relatively
minor technique or feature that you "know" is Right. Consider trashing
the special neato thing and making the routine work without it. Later,
you might figure out a way to restore the neatoness; maybe you'll forgo
it.
* Tear out buggy code blocks and replace them with code that *must* run,
even if it doesn't do what you want. When your main program works again,
grab all the stuff you cut out and write the bare minimum of framework
needed to run the buggy blocks. Ruthlessly eliminate irrelevant features
from the test bed. As soon as it works, ask why.
* Construct a purely synthetic expression of the bug. Imagine that it is
all Perl's fault and you will show the world with your terse example
that reduces the bug to its essential elements. Can you write a new,
self-contained bundle of code that does the same nasty thing? If not,
why? If so, can you find the bug now? When you decided that the new,
test code would fail in the same way as your project, what assumptions
did you make? Which hold?
* See if there isn't a CPAN module that does it, what ever it is. Some
would say you should do this even before writing code but I say, you
learn by DIY. At some point, you may want to just get the job done,
though.
* When frustration begins to flood and gumption ebbs, take a break.
Pirsig recommends recutting rusty, stripped, or jimmied threads on nuts
and bolts while recharging one's personal gumption tank, exhausted from
trying to figure out why the engine won't start. I recommend documenting
your existing, working code. Write clear, complete documentation for
each subroutine. Fill in comments beside working code. Write POD. Return
to sections you've already commented and rewrite the docs. Check for the
common condition that you have edited the code but the docs no longer
track. Bring them up to speed.
* Loop all the above. These are not numbered steps; perhaps I should say
"wander through the above". Return frequently to the simple exercise of
looking over your code and checking for the obvious -- missing
semicolons, improperly paired braces, $ when you mean @, [] when you
mean ().
* Turn it off. Life awaits beyond the cathode ray tube. Purchase a ball
of an agreeable size and shape and throw it. If you can find a young
person to throw it back to you, so much the better. Take out the
garbage. Drink your favorite beverage. Eat; low blood sugar stalls the
brain. Sleep. Pay your bills. Roof the garage. If you have employment,
pursue it. Return refreshed.
* If you're still stalled after several iterations of the above, you
should at least have a very clear idea of what you don't like. Condense
this to its bare essentials -- a veritable Perl haiku of a bug. If the
disagreeable behavior persists, this is now the time to post to a
newsgroup. Wait for suggestions. Try them.
* Loop....
--
Xiong Changnian
xiong102ATxuefangDOTcom
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Sun, 1 Apr 2007 06:19:51 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: A Perl Beginner
Message-Id: <slrnf0v5an.61b.tadmc@tadmc30.august.net>
Xiong Changnian <please@nospam.net> wrote:
> The Llama Book is also good to have and you might rather start
> there:
>
> Learning Perl, 3rd Edition, Schwartz, Phoenix
The Llama book is in its 4th edition now.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 01 Apr 2007 09:01:26 -0700
From: Xiong Changnian <please@nospam.net>
Subject: Re: A Perl Beginner
Message-Id: <please-7A8B08.09012501042007@free.teranews.com>
In article <slrnf0v5an.61b.tadmc@tadmc30.august.net>,
Tad McClellan <tadmc@augustmail.com> wrote:
> The Llama book is in its 4th edition now.
I stand corrected, thank you.
--
Xiong Changnian
xiong102ATxuefangDOTcom
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: 1 Apr 2007 08:43:49 -0700
From: darioses@gmail.com
Subject: Help developing web app
Message-Id: <1175442229.149757.163640@p77g2000hsh.googlegroups.com>
Hello,
I'm looking for help in developing a Web site in Perl, HTML and
Javascript.
If anyone is interested in earning money by working on these
technologies from home a few hours a week please contact me
------------------------------
Date: Sun, 1 Apr 2007 12:12:28 +0200
From: "Lambik" <lambik@kieffer.nl>
Subject: Re: How to make send key ([tab] [tab]Text [Enter]) in some program (Internet Explorer or otepad)?
Message-Id: <460f84b5$0$751$5fc3050@dreader2.news.tiscali.nl>
"max" <max@xxx.tovle.ct> wrote in message
news:eul21e$m7d$1@ss408.t-com.hr...
> How to make send key ([tab] [tab]Text [Enter]) in some program (Internet
> Explorer or Notepad)?
use Win32::Setupsup qw(WaitForAnyWindow SendKeys);
#PPM install http://theoryx5.uwinnipeg.ca/ppms/Win32-Setupsup.ppd.
if (WaitForAnyWindow('notepad', \my $window,60_000, 500)) {
SendKeys($window, "\\tab\\\\tab\\Tekst\\RET\\",1);
}
------------------------------
Date: 1 Apr 2007 05:54:33 -0700
From: dgcoventry@gmail.com
Subject: Pop3 emulation for Outlook Client
Message-Id: <1175432073.608418.172170@b75g2000hsg.googlegroups.com>
Hi.
We have an email server which is not accessible from outside the
building.
What I want to do is to have a linux box with an MTA take the mail off
the server (192.168.0.10) and place it as a file on some server space
I'm renting.
That shouldn't be a problem.
However, I need for my boss to access the email from Outlook Express
as he is comfortable with it
What I would need is to set the email client to access my server space
on port 80 and somehow trigger a perl script to pass the file to
Outlook in a form that won't freak Outlook out.
Would this be possible?
The obvious solution would be to set up the linux box as a mail server
and have Outlook connect directly, but unfortunately our connection is
not a static IP.
Anyone got any thoughts?
------------------------------
Date: Sun, 01 Apr 2007 17:01:13 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Pop3 emulation for Outlook Client
Message-Id: <460fc92d$0$15959$9b4e6d93@newsspool4.arcor-online.net>
dgcoventry@gmail.com schrieb:
> Hi.
>
> We have an email server which is not accessible from outside the
> building.
>
> What I want to do is to have a linux box with an MTA take the mail off
> the server (192.168.0.10) and place it as a file on some server space
> I'm renting.
>
> That shouldn't be a problem.
>
> However, I need for my boss to access the email from Outlook Express
> as he is comfortable with it
>
> What I would need is to set the email client to access my server space
> on port 80 and somehow trigger a perl script to pass the file to
> Outlook in a form that won't freak Outlook out.
>
> Would this be possible?
No, and even if it were, the concept is thoroughly broken. You'll give
yourself and your boss more headache than healthy if you pursue this.
> The obvious solution would be to set up the linux box as a mail server
> and have Outlook connect directly, but unfortunately our connection is
> not a static IP.
If it is just for a few of mailboxes, this is definitely overkill.
Set up NAT on your firewall to enable POP3S (tcp/995) or IMAPS (tcp/993)
port forwarding to your mailserver, configure secure POP3 or IMAP on
the server itself and install a DynDNS client on one of the servers
behind the firewall (accounts there are for free). All your boss then
needs to do is configure yourname.dyndns.org as the server and enable
secure communication, everything else will work as normal. Together with
encrypted SMTP he will also have a secure way to send messages, which
wouldn't work with your solution.
Btw., Outlook Express[TM] and Outlook[TM] are two completely different
pieces of software.
-Chris
------------------------------
Date: 1 Apr 2007 08:25:39 -0700
From: dgcoventry@gmail.com
Subject: Re: Pop3 emulation for Outlook Client
Message-Id: <1175441139.681193.321750@n76g2000hsh.googlegroups.com>
On Apr 1, 5:01 pm, Christian Winter <thepoet_nos...@arcor.de> wrote:
> No, and even if it were, the concept is thoroughly broken. You'll give
> yourself and your boss more headache than healthy if you pursue this.
Okay, I'll take your word for it. It did seem that the main stumbling
block would be how to get Outlook (or Outlook Express?) to trigger the
http call.
> If it is just for a few of mailboxes, this is definitely overkill.
> Set up NAT on your firewall to enable POP3S (tcp/995) or IMAPS (tcp/993)
> port forwarding to your mailserver, configure secure POP3 or IMAP on
> the server itself and install a DynDNS client on one of the servers
> behind the firewall (accounts there are for free). All your boss then
> needs to do is configure yourname.dyndns.org as the server and enable
> secure communication, everything else will work as normal. Together with
> encrypted SMTP he will also have a secure way to send messages, which
> wouldn't work with your solution.
I'll have a look at dybdns.org and see if I can utilise that. Thanks
very much for the suggestion.
> Btw., Outlook Express[TM] and Outlook[TM] are two completely different
> pieces of software.
I'm not really familiar with them, but, as I say my boss likes it
(whichever one he uses)
> -Chris
Thanks very much for your comments and suggestions, Chris.
- Dave Coventry
------------------------------
Date: 1 Apr 2007 01:51:03 -0700
From: John.Peterson.jr@gmail.com
Subject: Regexp question
Message-Id: <1175417463.593771.124360@y66g2000hsf.googlegroups.com>
I have a variable like the one below. It contains nested braces pair.
I'd like to create regexp that changes the variable value to the
string "hello world". Can anyone help with that?
$test = "hello
{{ text
{{innerbrace}}
some text
{{innerbrace2}}
some text
}} world";
------------------------------
Date: Sun, 01 Apr 2007 11:04:16 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Regexp question
Message-Id: <460f7584$0$15941$9b4e6d93@newsspool4.arcor-online.net>
John.Peterson.jr@gmail.com wrote:
> I have a variable like the one below. It contains nested braces pair.
> I'd like to create regexp that changes the variable value to the
> string "hello world". Can anyone help with that?
>
> $test = "hello
> {{ text
> {{innerbrace}}
> some text
> {{innerbrace2}}
> some text
> }} world";
>
Have a look at Regexp::Common.
$test =~ s/$RE{balanced}{-begin => "{{"}{-end => "}}"}//;
should do the trick (any leftover newlines shouldn't be too
hard to filter out manually).
-Chris
------------------------------
Date: Sun, 01 Apr 2007 15:03:14 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Regexp question
Message-Id: <euoatg$ad6$1@mlucom4.urz.uni-halle.de>
John.Peterson.jr@gmail.com wrote:
> I have a variable like the one below. It contains nested braces pair.
> I'd like to create regexp that changes the variable value to the
> string "hello world". Can anyone help with that?
>
> $test = "hello
> {{ text
> {{innerbrace}}
> some text
> {{innerbrace2}}
> some text
> }} world";
Christians recommendation is meant to
follow if the things between the braces
and their nesting may mean something.
But if you only have to 'cut out the garbage',
i.e. if the braces don't mean anything, you
could do a simple:
...
if( $test =~ /([^{\r\n]+).*}([^}\r\n]+)/s ) {
print "$1$2\n";
}
...
which does retain the text parts before
and after any brace in the string (and
also chops line endings) by means of
a greedy .* and a short backtracking.
Regards
Mirco
------------------------------
Date: Sun, 1 Apr 2007 15:42:41 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Regexp question
Message-Id: <euojvq.1gs.1@news.isolution.nl>
John.Peterson.jr@gmail.com schreef:
> I have a variable like the one below. It contains nested braces pair.
> I'd like to create regexp that changes the variable value to the
> string "hello world". Can anyone help with that?
>
> $test = "hello
> {{ text
> {{innerbrace}}
> some text
> {{innerbrace2}}
> some text
> }} world";
s/\{.*\}/ /s, s/\s+/ / for $test;
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sun, 01 Apr 2007 14:18:14 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Regexp question
Message-Id: <GaPPh.2976$5x6.1931@trndny02>
John.Peterson.jr@gmail.com wrote:
> I have a variable like the one below. It contains nested braces pair.
> I'd like to create regexp that changes
That's not possible. REs match or don't match a string, they do not replace
anything.
Did you mean the s/// operator instead?
> the variable value to the
> string "hello world". Can anyone help with that?
>
> $test = "hello
> {{ text
> {{innerbrace}}
> some text
> {{innerbrace2}}
> some text
> }} world";
This should do nicely
s =~ /.*/hello world/;
At least it completely fulfills your specification.
Now, if you meant something else, then maybe you could refine your
specification?
jue
------------------------------
Date: Sun, 01 Apr 2007 08:45:17 -0700
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: Regexp question
Message-Id: <ppidnSq7gPYTTpLbnZ2dnUVZ_vzinZ2d@giganews.com>
John.Peterson wrote:
> I have a variable like the one below. It contains nested braces pair.
> I'd like to create regexp that changes the variable value to the
> string "hello world". Can anyone help with that?
> $test = "hello
> {{ text
> {{innerbrace}}
> some text
> {{innerbrace2}}
> some text
> }} world";
$test =~ s/\n.*}//s;
Purl Gurl
------------------------------
Date: Sun, 1 Apr 2007 18:34:54 +0200
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: Regexp question
Message-Id: <euoo8l$2v10$1@ns.felk.cvut.cz>
<John.Peterson.jr@gmail.com> píse v diskusním príspevku
news:1175417463.593771.124360@y66g2000hsf.googlegroups.com...
>I have a variable like the one below. It contains nested braces pair.
> I'd like to create regexp that changes the variable value to the
> string "hello world". Can anyone help with that?
>
> $test = "hello
> {{ text
> {{innerbrace}}
> some text
> {{innerbrace2}}
> some text
> }} world";
>
$test =~ s/^(.*?)\{.*\}(.*)$/$1$2/s;
$test =~ s/\s+/ /sg;
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
------------------------------
Date: Sun, 01 Apr 2007 09:10:18 -0700
From: Xiong Changnian <please@nospam.net>
Subject: Re: Shifting Away
Message-Id: <please-4549E0.09101801042007@free.teranews.com>
In article <x7hcs0wtjh.fsf@mail.sysarch.com>,
Uri Guttman <uri@stemsystems.com> wrote:
> the light needs to be shown inside your head.
> you chosen level is wrong.
> if you code in a pass by value style which is the recommended and taught
> style it is a pass by value language.
> nothing you say matters about this.
> it doesn't matter what you think or how it is implemented.
> few ignore me or maybe more should.
Okay, I think my question's been answered. My apologies to Mr. Guttman.
I hope other members of this group will forgive me if somewhere down the
road, I repeat some other question that Mr. Guttman has already answered
for me, on the offchance that I've failed to read it.
--
Xiong Changnian
xiong102ATxuefangDOTcom
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 289
**************************************