[32034] in Perl-Users-Digest
Perl-Users Digest, Issue: 3298 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 23 21:09:34 2011
Date: Wed, 23 Feb 2011 18:09:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 23 Feb 2011 Volume: 11 Number: 3298
Today's topics:
Re: books on perl <k4monk@gmail.com>
Re: books on perl <tadmc@seesig.invalid>
Re: books on perl <jurgenex@hotmail.com>
Re: data transformation, Perl and MicroSoft <cartercc@gmail.com>
Re: data transformation, Perl and MicroSoft <cwilbur@chromatico.net>
Re: Imager module with GIFs <jwcarlton@gmail.com>
Re: Imager module with GIFs <jwcarlton@gmail.com>
Re: Imager module with GIFs <jurgenex@hotmail.com>
Re: Imager module with GIFs <jwcarlton@gmail.com>
newsgroups on perl <k4monk@gmail.com>
Re: newsgroups on perl (Randal L. Schwartz)
Re: passing (and getting) references to/from functions <k4monk@gmail.com>
Removing empty tags <jwcarlton@gmail.com>
Re: Ruby on rails training for Perl developers sln@netherlands.com
Re: Ruby on rails training for Perl developers <cartercc@gmail.com>
Re: Ruby on rails training for Perl developers (Randal L. Schwartz)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 23 Feb 2011 15:25:57 -0800 (PST)
From: K4 Monk <k4monk@gmail.com>
Subject: Re: books on perl
Message-Id: <0812d5fc-fe7a-41b2-8eb1-9aa051bd3224@o18g2000prh.googlegroups.com>
On Feb 23, 8:09=A0am, J rgen Exner <jurge...@hotmail.com> wrote:
> K4 Monk <k4m...@gmail.com> wrote:
> >Thank you! btw, I posted this in another newsgroup but never got a
> >response. After reading this thread and one of the booke (HOP) I have
> >realized that I don't know Perl. I've never used functions extensively
> >and don't understand how they work.
>
> See "perldoc perlsub"
>
> >And here's a program I wrote to
> >prove it.
>
> >#!/usr/bin/perl
> >use strict;
>
> Good. But you should also enable warnings.
>
> =A0 =A0 =A0 =A0 use warnings;
>
> >sub func {
> > =A0 =A0my %list;
> > =A0 =A0$list{"map"} =3D "key";
> > =A0 =A0$list{"l"}=3D"j";
>
> You can write such an initialization more easily as
> =A0 =A0 =A0 =A0 my %list =3D (
> =A0 =A0 =A0 =A0 =A0 =A0 "map" =3D> "key",
> =A0 =A0 =A0 =A0 =A0 =A0 "l" =3D> "j");
>
> > =A0 =A0my @arr;
> > =A0 =A0push (@arr, "egg");
> > =A0 =A0push (@arr, "hell");
>
> Most people would probably do a simple
> =A0 =A0 =A0 =A0 my @arr =3D ('egg", "hell");
>
> > =A0 =A0return (%list, @arr);
>
> You are aware that you are returning a list with 6 elements, mixing your
> hash and array elements indiscrimently togehter, aren't you?
Thank you jue, no I wasn't aware of this, and on my end I spent an
hour looking for the but gave up.
> Just like arguments the return value of a sub is just a list of scalars,
> too, =A0and any sub-structure or composite data will be flattened.
so, even if I do a func(%hash), on func's end it gets an array of a
scalar pointing to %hash?
>
> >}
>
> > my @arrref =3D &func();
>
> Just print the lenght of the array here
> =A0 =A0 =A0 =A0 print scalar(@arrref);
nice. I noted this down.
> and it will tell you that @arrref contains 6 elements.
>
> > my %l =3D %{$arrref[0]};
> > my @r =3D @{$arrref[1]};
>
> Whatever you are trying to do here doesn't work because @arrref already
> contains the wrong data. If you want to preserve your return hash and
> return array from sub func then first of all you have to return a
> reference to them instead of their values (see "Make Rule 1" in "Making
> References" in "perldoc perlreftut")
>
> =A0 =A0 =A0 =A0 return (\%list, \@arr);
>
> Then the rest will more or less fall into place on its own.
>
> jue
Thanks jue for your help!
------------------------------
Date: Wed, 23 Feb 2011 18:03:46 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: books on perl
Message-Id: <slrnimb7p6.30b.tadmc@tadbox.sbcglobal.net>
K4 Monk <k4monk@gmail.com> wrote:
> On Feb 23, 8:09Â am, J rgen Exner <jurge...@hotmail.com> wrote:
>> K4 Monk <k4m...@gmail.com> wrote:
>> >I've never used functions extensively
>> >and don't understand how they work.
>>
>> See "perldoc perlsub"
Have you done that yet?
Did you take note of the beginning of the 2nd paragraph?
The Perl model for function call and return values is simple: all
functions are passed as parameters one single flat list of scalars,
and all functions likewise return to their caller one single flat
list of scalars.
>> >sub func {
>> > Â Â my %list;
>> > Â Â $list{"map"} = "key";
>> > Â Â $list{"l"}="j";
>> > Â Â my @arr;
>> > Â Â push (@arr, "egg");
>> > Â Â push (@arr, "hell");
>> > Â Â return (%list, @arr);
>>
>> You are aware that you are returning a list with 6 elements, mixing your
>> hash and array elements indiscrimently togehter, aren't you?
>
> Thank you jue, no I wasn't aware of this, and on my end I spent an
> hour looking for the but gave up.
Huh?
Just call the function, and print out what it returns:
print "$_\n" for func();
>> Just like arguments the return value of a sub is just a list of scalars,
>> too, Â and any sub-structure or composite data will be flattened.
>
> so, even if I do a func(%hash), on func's end it gets an array of a
> scalar pointing to %hash?
No, it gets a list containing six values.
Either
map, key, l, j, egg, hell
or
l, j, map, key, egg, hell
There is nothing "pointing to" %hash because %hash does not
even exist outside of your subroutine.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Wed, 23 Feb 2011 16:16:07 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: books on perl
Message-Id: <tj8bm6lpe8qq606lsuoabpro71q5usf0lr@4ax.com>
K4 Monk <k4monk@gmail.com> wrote:
>so, even if I do a func(%hash), on func's end it gets an array of a
>scalar pointing to %hash?
No. It gets a flat(!) list(!) which is composed of the alternating keys
and values of %hash, i.e. if %hash has 5 entries then the argument list
@_ of func(%hash) will contain 10 values.
jue
------------------------------
Date: Wed, 23 Feb 2011 06:27:04 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: data transformation, Perl and MicroSoft
Message-Id: <869a36c6-15b0-4ff7-bace-8862db57fdf1@j35g2000prb.googlegroups.com>
On Feb 22, 9:37=A0pm, Charlton Wilbur <cwil...@chromatico.net> wrote:
> Yes. =A0However, you seem to be assuming that the *perception* of value
> actually adds value, and that the added value will be in an area that
> you find useful. =A0Those are both unwarranted leaps.
I've now spend about a week playing with this. Microsoft has done a
typical Microsoft thing, produced the ability to 'program' a SSIS
application by pulling components off the shelf and connect them by
drawing on a GUI. IOW, managers can 'program' an application without
actually knowing anything about the language or technology they use.
From the managers POV, I can see the value -- it allows them to build
apps without requiring the services of a software guy and without
knowing much about software. In this respect, I work like this all the
time building physical things, using premanufactured components bought
at the building supply or hardware store.
I agree that the perception of value is important. Not as important as
the reality, but still important. In the long haul, the market will
determine either the reality or the fantasy of the perception, and I
suspect that in the case of Microsoft SSIS, the market will validate
the product.
I can do the same thing, and more, with less effort in less time using
Perl, but the downside is that I have spent years learning how.
Managers will spend a LOT of money to be able to have some of this
ability without learning Perl (or any technology for that matter).
CC.
------------------------------
Date: Wed, 23 Feb 2011 16:39:03 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: data transformation, Perl and MicroSoft
Message-Id: <861v2yfn2g.fsf@mithril.chromatico.net>
>>>>> "cc" == ccc31807 <cartercc@gmail.com> writes:
cc> I've now spend about a week playing with this. Microsoft has
cc> done a typical Microsoft thing, produced the ability to
cc> 'program' a SSIS application by pulling components off the shelf
cc> and connect them by drawing on a GUI. IOW, managers can
cc> 'program' an application without actually knowing anything about
cc> the language or technology they use.
Wow, revolutionary!
That concept, as it happens, predates Windows.
http://en.wikipedia.org/wiki/Fourth-generation_programming_language
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Wed, 23 Feb 2011 16:30:09 -0800 (PST)
From: jwcarlton <jwcarlton@gmail.com>
Subject: Re: Imager module with GIFs
Message-Id: <6a37cb1c-5133-4403-ac96-770ad40ac254@o21g2000prn.googlegroups.com>
On Feb 22, 11:10=A0pm, "Dr.Ruud" <rvtol+use...@xs4all.nl> wrote:
> On 2011-02-23 04:48, John W. Krahn wrote:
>
> > jwcarlton wrote:
> >> $pic =3D~ s/[^A-Za-z0-9\._ \-=3D@\x80-\xFE]/_/go;
>
> > [...] The characters A-Z, a-z, 0-9 and _ can be abbreviated
> > with \w.
>
> Be careful with that advice. A \w matches many, many code points.
>
> --
> Ruud
Thanks for the tips. Sherm, I had no idea that people had started
going back to the 3-argument form; I thought that was old school! LOL
Is there a technical/speed advantage? Or is it just one of those
things?
Off topic, I learned recently that, in school, kids are now being
taught "mean" instead of "average". My parents learned "mean", but we
learned "average", and now kids are back to "mean". Education goes in
circles, I guess :-)
------------------------------
Date: Wed, 23 Feb 2011 16:26:20 -0800 (PST)
From: jwcarlton <jwcarlton@gmail.com>
Subject: Re: Imager module with GIFs
Message-Id: <c78eb394-1f8d-4b67-b655-e1ccd8a086ea@j35g2000prb.googlegroups.com>
On Feb 22, 3:19=A0pm, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
wrote:
> jwcarlton wrote:
> >> Where's the following:
>
> >> use Imager;
> >> use strict;
> >> use warnings;
>
> >> ???
>
> > I obviously didn't want to paste the entire script, just the relevant
> > parts. I'm also using use CGI::Carp qw(fatalsToBrowser).
>
> Obviously... =A0Ever read the posting guidelines?
>
>
>
> >>> ($filename, $ext) =3D $pic =3D~ m/(.*)\.(.*)/;
> >> What's the value of $pic?
>
> > $pic is the file name of the uploaded image. In this case, it's found
> > with the following:
>
> > $old_pic =3D upload('pic');
>
> etc..
> what does $image->write_types() report?
>
> Possibly you don't have the GIF library installed or when installing
> Imager it didn't find it. =A0Did make test work?
>
> Check the README for hints on giflib.
>
> I'd suggest removing CGI from the equation and start with an
> image on your machine and make sure you can read/write to
> other formats, if that works, then it should work as a CGI,
> provided it works for other formats.
You're right on this one. I took for granted that giflib installed
with Imager, but apparently not.
I found giflib on SourceForge, but I have no clue how to install it.
I've been looking everywhere for installation instructions (at least
something with little SSH experience can follow), but can't find
anything :-(
I hate to ask this type of question, but can you point me in the right
direction on getting started? This is a live, active server with
minimal tech support, so if I mess up, I could be down for awhile.
------------------------------
Date: Wed, 23 Feb 2011 17:14:15 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Imager module with GIFs
Message-Id: <g4cbm69mtnjjb73s7bqeuea20npt6cl00j@4ax.com>
jwcarlton <jwcarlton@gmail.com> wrote:
>I hate to ask this type of question, but can you point me in the right
>direction on getting started? This is a live, active server with
>minimal tech support, so if I mess up, I could be down for awhile.
Aeeehhhm, excuse me for asking stupid questions, but are you hinting at
that you are developing code on a live server?
jue
------------------------------
Date: Wed, 23 Feb 2011 17:24:10 -0800 (PST)
From: jwcarlton <jwcarlton@gmail.com>
Subject: Re: Imager module with GIFs
Message-Id: <9e163403-ef21-47a4-a207-a91071650091@p16g2000vbo.googlegroups.com>
On Feb 23, 8:14=A0pm, J rgen Exner <jurge...@hotmail.com> wrote:
> jwcarlton <jwcarl...@gmail.com> wrote:
> >I hate to ask this type of question, but can you point me in the right
> >direction on getting started? This is a live, active server with
> >minimal tech support, so if I mess up, I could be down for awhile.
>
> Aeeehhhm, excuse me for asking stupid questions, but are you hinting at
> that you are developing code on a live server?
>
> jue
Yup. I have 2 servers; one is used for shared accounts, and the other
(this one) is used for this one site. So, I don't have a non-live
server to test with.
------------------------------
Date: Wed, 23 Feb 2011 15:27:36 -0800 (PST)
From: K4 Monk <k4monk@gmail.com>
Subject: newsgroups on perl
Message-Id: <054b8801-93a7-483b-a294-4a60676e733b@z27g2000prz.googlegroups.com>
which newsgroups (apart from comp.lang.perl.misc) are the most active
in the perl community?
------------------------------
Date: Wed, 23 Feb 2011 17:16:47 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: newsgroups on perl
Message-Id: <86wrkq5j0g.fsf@red.stonehenge.com>
>>>>> "K4" == K4 Monk <k4monk@gmail.com> writes:
K4> which newsgroups (apart from comp.lang.perl.misc) are the most active
K4> in the perl community?
It's not like there's a long list.
comp.lang.perl.announce
comp.lang.perl.misc
comp.lang.perl.moderated
comp.lang.perl.modules
comp.lang.perl.tk
That's it.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion
------------------------------
Date: Wed, 23 Feb 2011 00:14:30 -0800 (PST)
From: K4 Monk <k4monk@gmail.com>
Subject: Re: passing (and getting) references to/from functions
Message-Id: <2dbfcf27-bd20-4224-a495-de380be47670@k17g2000pre.googlegroups.com>
On Feb 23, 7:47=A0am, Xho Jingleheimerschmidt <xhos...@gmail.com>
wrote:
> Beyond that, it is hard to figure out what you *expect* to happen, so it
> is hard to explain why your expectations were not met.
hi sln, jue and Xho, thanks to all three of you for taking the time.
In my code
> push (@list, "map");
> push (@list, "key");
> push (@list, "l");
> push (@list, "j");
> return ( \@list, \@arr );
I intended to use a hash %list which should have been
$list{"map"}=3D"key";
$list{"l"}=3D"j";
but because I couldn't figure out how to return it from a function, I
changed it into an array.
------------------------------
Date: Wed, 23 Feb 2011 17:22:20 -0800 (PST)
From: jwcarlton <jwcarlton@gmail.com>
Subject: Removing empty tags
Message-Id: <88323a92-b220-4d94-bd3b-aa25161976b2@y3g2000vbh.googlegroups.com>
I've just started changing my processing over to HTML::HTML5::Parser,
so please bear with me on this.
I've been using a regex to remove empty tags, but I see one that's not
working so I assume there's either a typo, or an error in the logic.
I'm trying to convert this:
<span class="Apple-style-span" style="font-family: Arial, Verdana,
Helvetica, sans-serif; "><br></span>
To:
<br>
It should also catch <span...></span> (with nothing inside), or
<span...> </span> (with a whitespace inside).
"class" and "style" can be anything (or non-existent), so I'm just
trying to remove <span, followed by anything (or nothing) to the first
>, then the following </span>
Here's what I'm using:
$text =~ s/<span[^>]*>\s*<\/span>/ /gi;
$text =~ s/<span[^>]*>(<br>)*<\/span>/$1/gi;
This doesn't appear to work, though. The string I posted above
actually came through verbatim, so it must have matched false.
Of course, I know that this would fail on nested <span></span> tags,
which is why I'm switching over to HTML::HTML5::Parser. But in the
meanwhile, why did this one not match?
------------------------------
Date: Wed, 23 Feb 2011 11:54:14 -0800
From: sln@netherlands.com
Subject: Re: Ruby on rails training for Perl developers
Message-Id: <mbpam6h8jvupbek1rvr40u9t3uumqkbtpt@4ax.com>
On Mon, 21 Feb 2011 21:19:21 -0800 (PST), Wan Li Zhu <zhurama@gmail.com> wrote:
>If you're a Perl developer in the Boston area looking to learn Ruby,
>Fairhaven Capital and thoughtbot are teaming up to offer Ruby on Rails
>training courses in Boston at 50% off regular price ($600 for 2 full
>days of training, intro and advanced levels).
>
>Details at http://workshops.thoughtbot.com/fairhaven
Can I get a refund if you don't teach me to program in Ruby
in 2 full days?
-sln
------------------------------
Date: Wed, 23 Feb 2011 14:11:14 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Ruby on rails training for Perl developers
Message-Id: <f2e57dba-43df-4c64-99dd-2f80939e5801@w7g2000pre.googlegroups.com>
On Feb 22, 12:19=A0am, Wan Li Zhu <zhur...@gmail.com> wrote:
> If you're a Perl developer in the Boston area looking to learn Ruby,
> Fairhaven Capital and thoughtbot are teaming up to offer Ruby on Rails
> training courses in Boston at 50% off regular price ($600 for 2 full
> days of training, intro and advanced levels).
>
> Details athttp://workshops.thoughtbot.com/fairhaven
Ruby is a sweet looking language and nice to use. It's nicer for
beginners, a bit on the slow side, but makes up for in in syntax. In
that regard, it's a step up from Java, PHP, etc.
OTOH Rails sux.
What I can't figure out is why a Perl developer would have much
interest in learning Ruby. If you've mastered Perl, it won't take much
to learn Ruby. I'd be interested to know how many Perl developers
attend this event. I guess would be zero, or possibly less.
CC.
------------------------------
Date: Wed, 23 Feb 2011 17:15:24 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Ruby on rails training for Perl developers
Message-Id: <861v2y6xn7.fsf@red.stonehenge.com>
>>>>> "ccc31807" == ccc31807 <cartercc@gmail.com> writes:
ccc31807> Ruby is a sweet looking language and nice to use. It's nicer for
ccc31807> beginners, a bit on the slow side, but makes up for in in syntax. In
ccc31807> that regard, it's a step up from Java, PHP, etc.
And it's a nice prototype for Perl6. Glad that the Ruby community got a
chance to shake out some of the new features.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 3298
***************************************