[32035] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3299 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 24 14:09:56 2011

Date: Thu, 24 Feb 2011 11:09:21 -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           Thu, 24 Feb 2011     Volume: 11 Number: 3299

Today's topics:
    Re: arithmetic persistence <ams@dexter.ludd.luth.se>
    Re: books on perl <justin.1102@purestblue.com>
    Re: books on perl <k4monk@gmail.com>
    Re: books on perl <tadmc@seesig.invalid>
    Re: books on perl <justin.1102@purestblue.com>
    Re: books on perl <m@rtij.nl.invlalid>
    Re: books on perl (Randal L. Schwartz)
        Can't get command line perl to work right <laredotornado@zipmail.com>
    Re: Can't get command line perl to work right sln@netherlands.com
    Re: Can't get command line perl to work right <charlie+newsgroups@newint.org>
    Re: Can't get command line perl to work right <glex_no-spam@qwest-spam-no.invalid>
    Re: Can't get command line perl to work right <news@pleier.org>
    Re: Can't get command line perl to work right <uri@StemSystems.com>
    Re: Imager module with GIFs <sherm.pendley@gmail.com>
    Re: Imager module with GIFs <tadmc@seesig.invalid>
    Re: Imager module with GIFs <uri@StemSystems.com>
    Re: newsgroups on perl <jimsgibson@gmail.com>
    Re: newsgroups on perl <ralph@happydays.com>
    Re: Removing empty tags <tadmc@seesig.invalid>
    Re: Removing empty tags <jwcarlton@gmail.com>
    Re: Removing empty tags <NoSpamPleaseButThisIsValid3@gmx.net>
    Re: Ruby on rails training for Perl developers <sherm.pendley@gmail.com>
    Re: Ruby on rails training for Perl developers <RedGrittyBrick@spamweary.invalid>
    Re: Ruby on rails training for Perl developers <sherm.pendley@gmail.com>
    Re: Ruby on rails training for Perl developers <cartercc@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 24 Feb 2011 16:20:49 +0000 (UTC)
From: Martin Str|mberg <ams@dexter.ludd.luth.se>
Subject: Re: arithmetic persistence
Message-Id: <ik60h1$e3l$1@speranza.aioe.org>

Thank you for an interesting problem and solutions. However nobody has
so far mentioned the Memoize perl module, which I guess would help
speed up the original solution. But perhaps not the pruning ones.


-- 
MartinS


------------------------------

Date: Thu, 24 Feb 2011 09:55:01 +0000
From: Justin C <justin.1102@purestblue.com>
Subject: Re: books on perl
Message-Id: <lgmh38-q9q.ln1@zem.masonsmusic.co.uk>

On 2011-02-23, 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?

AIUI (and ICBW, in which case this'll be a learning exercise for me
too), if you do func(%hash) what func receives *is* an array, there's
no 'pointing to'. For example:

my %hash = (
    john => "lennon",
    paul => "macca",
    george => "harrison",
    ringo => "star",
);
func(%hash);

func() would receive an array containing qw/john, lennon, paul, macca,
george, harrison, ringo, star/  ... which can be shown by: 
sub func {
    print $_, "\n" for @_;
}

You could massage the array back into a hash in func() with (for 
example) 
sub func {
    my %hash = @_;
    # do stuff ... 
}

   Justin.

-- 
Justin C, by the sea.


------------------------------

Date: Thu, 24 Feb 2011 03:53:01 -0800 (PST)
From: K4 Monk <k4monk@gmail.com>
Subject: Re: books on perl
Message-Id: <5f9467a5-cd8a-456b-bd24-2f8c7865da30@w9g2000prg.googlegroups.com>

On Feb 24, 5:03=A0am, Tad McClellan <ta...@seesig.invalid> wrote:
> K4 Monk <k4m...@gmail.com> wrote:
> > On Feb 23, 8:09=A0am, 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?

yep, finally!

       "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.  Any arrays or hashes in these
call and return lists will collapse,
       losing their identities--but you may always use pass-by-
reference instead to avoid this. "


------------------------------

Date: Thu, 24 Feb 2011 08:01:00 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: books on perl
Message-Id: <slrnimcor1.4tj.tadmc@tadbox.sbcglobal.net>

Justin C <justin.1102@purestblue.com> wrote:
> On 2011-02-23, 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?
>
> AIUI (and ICBW, in which case this'll be a learning exercise for me
> too), if you do func(%hash) what func receives *is* an array,


Not it *is not* an array.

It is a list.

    perldoc -q list

        What is the difference between a list and an array?


-- 
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: Thu, 24 Feb 2011 14:18:32 +0000
From: Justin C <justin.1102@purestblue.com>
Subject: Re: books on perl
Message-Id: <ou5i38-v64.ln1@zem.masonsmusic.co.uk>

On 2011-02-24, Tad McClellan <tadmc@seesig.invalid> wrote:
> Justin C <justin.1102@purestblue.com> wrote:
>> On 2011-02-23, 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?
>>
>> AIUI (and ICBW, in which case this'll be a learning exercise for me
>> too), if you do func(%hash) what func receives *is* an array,
>
>
> Not it *is not* an array.
>
> It is a list.

kick($self)

I know this, why do I always call it an array?! <shakes head>

   Justin.

-- 
Justin C, by the sea.


------------------------------

Date: Thu, 24 Feb 2011 17:45:42 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: books on perl
Message-Id: <miei38-53b.ln1@news.rtij.nl>

On Thu, 24 Feb 2011 14:18:32 +0000, Justin C wrote:

> kick($self)

Better written as:

$self->kick();

although if kick() does not exist, the former fails at compile time while 
the latter fails at run time.

:-)

M4


------------------------------

Date: Thu, 24 Feb 2011 10:43:17 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: books on perl
Message-Id: <86wrkp46ka.fsf@red.stonehenge.com>

>>>>> "Martijn" == Martijn Lievaart <m@rtij.nl.invlalid> writes:

Martijn> Better written as:

Martijn> $self->kick();

Martijn> although if kick() does not exist, the former fails at compile time while 
Martijn> the latter fails at run time.

And if kick doesn't know what to do with an object of the type that
$self is, it'll have to check that itself unless it's a method call. :)

-- 
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: Thu, 24 Feb 2011 09:41:54 -0800 (PST)
From: Dave <laredotornado@zipmail.com>
Subject: Can't get command line perl to work right
Message-Id: <92fccf6a-6ca8-48f6-a388-28660f353e33@8g2000prb.googlegroups.com>

Hi,

I'm using Perl 5.8.9 on Mac 10.6.3.  I have a file and I want to have
a new file where the uri_escape function is applied to each line of
the file.  However, this call

perl -pi -e 'use URI::Escape; print uri_escape($_)' link_names.txt

only partially works.  The result is a line that contains the escaped
string, and then the original string.  How do I modify the code above
to print out only the escaped string?

Thanks, - Dave


------------------------------

Date: Thu, 24 Feb 2011 10:10:48 -0800
From: sln@netherlands.com
Subject: Re: Can't get command line perl to work right
Message-Id: <9o7dm6ll25f0t56ni5e5fj2trb34p8sp0d@4ax.com>

On Thu, 24 Feb 2011 09:41:54 -0800 (PST), Dave <laredotornado@zipmail.com> wrote:

>Hi,
>
>I'm using Perl 5.8.9 on Mac 10.6.3.  I have a file and I want to have
>a new file where the uri_escape function is applied to each line of
>the file.  However, this call
>
>perl -pi -e 'use URI::Escape; print uri_escape($_)' link_names.txt
>
>only partially works.  The result is a line that contains the escaped
>string, and then the original string.  How do I modify the code above
>to print out only the escaped string?
>
perl -ni -mURI::Escape -e 'print uri_escape($_)' link_names.txt

maybe

-sln


------------------------------

Date: Thu, 24 Feb 2011 18:11:31 +0000
From: Charlie Harvey <charlie+newsgroups@newint.org>
Subject: Re: Can't get command line perl to work right
Message-Id: <ik670k$9kq$1@news.eternal-september.org>

On 24/02/11 17:41, Dave wrote:
> Hi,
> 
> I'm using Perl 5.8.9 on Mac 10.6.3.  I have a file and I want to have
> a new file where the uri_escape function is applied to each line of
> the file.  However, this call
> 
> perl -pi -e 'use URI::Escape; print uri_escape($_)' link_names.txt
> 
> only partially works.  The result is a line that contains the escaped
> string, and then the original string.  How do I modify the code above
> to print out only the escaped string?
> 
> Thanks, - Dave

Hi Dave,

perl -n -E 'use URI::Escape; say uri_escape($_)' link_names.txt

Cheers,
Charlie


------------------------------

Date: Thu, 24 Feb 2011 12:18:27 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
To: Dave <laredotornado@zipmail.com>
Subject: Re: Can't get command line perl to work right
Message-Id: <4D66A0F3.7090306@qwest-spam-no.invalid>

Dave wrote:
> Hi,
> 
> I'm using Perl 5.8.9 on Mac 10.6.3.  I have a file and I want to have
> a new file where the uri_escape function is applied to each line of
> the file.  However, this call
> 
> perl -pi -e 'use URI::Escape; print uri_escape($_)' link_names.txt
> 
> only partially works.  The result is a line that contains the escaped
> string, and then the original string.  How do I modify the code above
> to print out only the escaped string?


Check the documentation to see what those flags actually do:

perldoc perlrun

Hint: using -p along with print might be redundant.

If you want a new file, then you need to specify it.  Hint: -i


------------------------------

Date: Thu, 24 Feb 2011 19:44:48 +0100
From: pleier <news@pleier.org>
Subject: Re: Can't get command line perl to work right
Message-Id: <ik68u3$794$02$1@news.t-online.com>

On 24.02.2011 18:41, Dave wrote:
> Hi,
>
> I'm using Perl 5.8.9 on Mac 10.6.3.  I have a file and I want to have
> a new file where the uri_escape function is applied to each line of
> the file.  However, this call
>
> perl -pi -e 'use URI::Escape; print uri_escape($_)' link_names.txt
>
> only partially works.  The result is a line that contains the escaped
> string, and then the original string.  How do I modify the code above
> to print out only the escaped string?
>
> Thanks, - Dave

The -p already prints the original line, just leave it and it should work.

  gerhard


------------------------------

Date: Thu, 24 Feb 2011 13:50:39 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Can't get command line perl to work right
Message-Id: <871v2x4680.fsf@quad.sysarch.com>

>>>>> "p" == pleier  <news@pleier.org> writes:

  >> perl -pi -e 'use URI::Escape; print uri_escape($_)' link_names.txt

  p> The -p already prints the original line, just leave it and it should work.

leave what? uri_escape returns a value so it needs to either be printed
explicitly or assigned to $_.

these should be equivilent:

perl -pi -e 'use URI::Escape; $_ = uri_escape($_)' link_names.txt
perl -ni -e 'use URI::Escape; print uri_escape($_)' link_names.txt

and using -M is a little cleaner too:

perl -pi -MURI::Escape -e '$_ = uri_escape($_)' link_names.txt

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Wed, 23 Feb 2011 21:30:25 -0500
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Imager module with GIFs
Message-Id: <m2oc62maf2.fsf@sherm.shermpendley.com>

jwcarlton <jwcarlton@gmail.com> writes:

> Sherm, I had no idea that people had started
> going back to the 3-argument form; I thought that was old school!

You thought wrong. It's the newer form, and has been preferred since it
was introduced; 2-argument open() is supported only for the sake of
compatibility with old scripts.

See perldoc -q "How can I open a file with a leading"

sherm--

-- 
Sherm Pendley
                                   <http://camelbones.sourceforge.net>
Cocoa Developer


------------------------------

Date: Wed, 23 Feb 2011 22:05:58 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Imager module with GIFs
Message-Id: <slrnimblva.3d4.tadmc@tadbox.sbcglobal.net>

jwcarlton <jwcarlton@gmail.com> wrote:

> I had no idea that people had started
> going back to the 3-argument form;


It is not possible to "go back" to something that did not
previously exist...


> Is there a technical/speed advantage? 


It is much less likely to inject a bug.


-- 
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 23:42:55 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Imager module with GIFs
Message-Id: <87mxlm6o1c.fsf@quad.sysarch.com>

>>>>> "SP" == Sherm Pendley <sherm.pendley@gmail.com> writes:

  SP> jwcarlton <jwcarlton@gmail.com> writes:
  >> Sherm, I had no idea that people had started
  >> going back to the 3-argument form; I thought that was old school!

  SP> You thought wrong. It's the newer form, and has been preferred since it
  SP> was introduced; 2-argument open() is supported only for the sake of
  SP> compatibility with old scripts.

not exactly. i doubt it would ever be dropped. there are some useful
things you can do with 2 arg open that you can't with 3 arg. you can
pass in a file name with a | (leading or trailing depending on needs)
and run a program instead of opening a file. the caller can do that only
if it is 2 arg open. with 3 arg the caller would need to specify an
extra arg in the api. not a big win but it is useful for example to pass
in a compressed file with the decompressor as its filter. the perl open
never needs to know about the compression.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Thu, 24 Feb 2011 09:47:53 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: newsgroups on perl
Message-Id: <240220110947538108%jimsgibson@gmail.com>

In article
<054b8801-93a7-483b-a294-4a60676e733b@z27g2000prz.googlegroups.com>, K4
Monk <k4monk@gmail.com> wrote:

> which newsgroups (apart from comp.lang.perl.misc) are the most active
> in the perl community?

perldoc -q newsgroups

-- 
Jim Gibson


------------------------------

Date: Thu, 24 Feb 2011 13:51:55 -0500
From: Ralph Malph <ralph@happydays.com>
Subject: Re: newsgroups on perl
Message-Id: <89da7$4d66a8cc$ce534406$26602@news.eurofeeds.com>

On 2/24/2011 12:47 PM, Jim Gibson wrote:
> In article
> <054b8801-93a7-483b-a294-4a60676e733b@z27g2000prz.googlegroups.com>, K4
> Monk<k4monk@gmail.com>  wrote:
>
>> which newsgroups (apart from comp.lang.perl.misc) are the most active
>> in the perl community?
>
> perldoc -q newsgroups
This answer is incorrect. The OP is asking about which are "most active".
Responding with an irrelevant command line reveals a severe case of 
social retardation.
The answer is: comp.lang.perl.misc is the most active. comp.lang.perl.tk 
gets a light amount of traffic and the rest
of the perl groups are currently all but dead. These things change. Or 
they should. UseNet isn't very popular right now.
Oh, and there are a number of perl.* groups. Some of these get some
action. I think the perl6 ones are the most active. They probably aren't 
what you(or anybody else) are looking for. They seem to mainly mirror 
narrowly focused mailing lists.



------------------------------

Date: Wed, 23 Feb 2011 22:10:22 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Removing empty tags
Message-Id: <slrnimbm7j.3d4.tadmc@tadbox.sbcglobal.net>

jwcarlton <jwcarlton@gmail.com> wrote:

> I'm trying to convert this:
>
><span class="Apple-style-span" style="font-family: Arial, Verdana,
> Helvetica, sans-serif; "><br></span>
>
> To:
>
><br>

> $text =~ s/<span[^>]*>(<br>)*<\/span>/$1/gi;
>
> This doesn't appear to work, though.


It works for me.


------------------------
#!/usr/bin/perl
use warnings;
use strict;

$_ = '<span class="Apple-style-span" style="font-family: Arial, Verdana,
Helvetica, sans-serif; "><br></span>';

s/<span[^>]*>(<br>)*<\/span>/$1/gi;

print "$_\n";
------------------------


If you can post a short and complete program that we can run that
duplicates the problem you are having, then we can surely help
you fix it...


-- 
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 21:11:47 -0800 (PST)
From: jwcarlton <jwcarlton@gmail.com>
Subject: Re: Removing empty tags
Message-Id: <82d8c15b-6d69-4839-b33d-572b4e3e533f@k17g2000pre.googlegroups.com>

> It works for me.
>
> ------------------------
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> $_ = '<span class="Apple-style-span" style="font-family: Arial, Verdana,
> Helvetica, sans-serif; "><br></span>';
>
> s/<span[^>]*>(<br>)*<\/span>/$1/gi;
>
> print "$_\n";
> ------------------------
>
> If you can post a short and complete program that we can run that
> duplicates the problem you are having, then we can surely help
> you fix it...


That's really pretty much all there is! I'll paste the whole function
below; the only thing I'm leaving out is the part at the top where it
declares a few variables, logs the user in (which doesn't affect the
$text variable), and then prints the data to MySQL.

The data comes from a contenteditable, and when people paste things it
needs to be manipulated a bit, which is mostly what this function
does. I don't have a sample of raw content (I don't save it before it
runs through the function), but here's a sample of a complete string
that was printed (I left the content because I thought you guys might
get a kick out of it):

<span class="Apple-style-span" style="font-family: Arial, Verdana,
Helvetica, sans-serif; "><b>"We ALL got problems....If you're gonna be
dumb, ya gotta be tough."</b></span><br><br><span class="Apple-style-
span" style="font-family: Arial, Verdana, Helvetica, sans-serif;
"><br></span>


And the function:

sub fixtext {
  $text = $_[0];

  $text =~ s/&nbsp;/ /gi;

  # Convert <em> to <i> and <strong> to <b>, saves a few steps later
  $text =~ s/<em>(.*?)<\/em>/<i>$1<\/i>/gsi;
  $text =~ s/<strong>(.*?)<\/strong>/<b>$1<\/b>/gsi;

  # Strip Javascript
  $text =~ s/<script.*?>.*?<\/script>//gsi;
  $text =~ s/onmouseover=".*?"//gsi;
  $text =~ s/onclick=".*?"//gsi;

  ### Only Allow Specified Tags
  my $lt=chr(1);
  my $gt=chr(2);
    $text =~ s/<br>/$lt br $gt/gi;

    $text =~ s/<(\/{0,1})(div.*?)>/$lt$1$2$gt/gsi;
    $text =~ s/<(\/{0,1})(span.*?)>/$lt$1$2$gt/gsi;

    $text =~ s/<(\/{0,1})(table.*?)>/$lt$1$2$gt/gsi;
    $text =~ s/<(\/{0,1})(tr.*?)>/$lt$1$2$gt/gsi;
    $text =~ s/<(\/{0,1})(td.*?)>/$lt$1$2$gt/gsi;

    $text =~ s/<(\/{0,1})(b|p)>/$lt$1$2$gt/gsi;
    $text =~ s/<(\/{0,1})(u|i)>/$lt$1$2$gt/gsi;

    $text =~ s/<(\/{0,1})(font.*?)>/$lt$1$2$gt/gsi;

    $text =~ s/<(\/{0,1})(img.*?)>/$lt$1$2$gt/gsi;

    # delete all other tags
    $text =~ s/<.+?>//gs;

  $text =~ s/$lt/</g;
  $text =~ s/$gt/>/g;
  $text =~ s/< br >/<br>/gi;
  ###

  # Strip Word junk
  $text =~ s/Normal 0 false.*?}//gsi;
  $text =~ s/Normal 0 MicrosoftInternetExplorer4.*?}//gsi;
  $text =~ s/\/\* Style Definitions \*\/.*?}//gsi;
  $text =~ s/Normal\.dotm .*? false false//gsi;

  $text =~ s/white-space: nowrap;*//gsi;
  $text =~ s/style="(\s*)"//gsi;

  # Strip empty tags
  $text =~ s/<font[^>]*>\s*<\/font>/ /gi;
  $text =~ s/<font[^>]*>(<br>)*<\/font>/<br><br>/gi;

  $text =~ s/<span[^>]*>\s*<\/span>/ /gi;
  $text =~ s/<span[^>]*>(<br>)*<\/span>/$1/gsi;

  $text =~ s/<i>(\s*)<\/i>/$1/gi;
  $text =~ s/<b>(\s*)<\/b>/$1/gi;
  $text =~ s/<u>(\s*)<\/u>/$1/gi;

  $text =~ s/<div>\s*<\/div>/<br>/gi;
  $text =~ s/<div>(.*?)<\/div>/<br><br>$1/gsi;

  # Limit repeating characters
  $text =~ s/(.)\1{4,}/$1$1$1$1/g;

  # Strip opening, trailing, or repeating whitespace, <br>
  $text =~ s/\s+/ /gs;
  $text =~ s/^\s+|\s+$//g;

  $text =~ s/(<br><br>)+/<br><br>/gi;
  $text =~ s/^(<br>)+|(<br>)+$//gi;

  return $text;
}


------------------------------

Date: Thu, 24 Feb 2011 17:43:43 +0100
From: Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@gmx.net>
Subject: Re: Removing empty tags
Message-Id: <4d668ac3$0$7651$9b4e6d93@newsspool1.arcor-online.net>

On 24.02.2011 06:11, jwcarlton wrote:
>> If you can post a short and complete program that we can run that
>> duplicates the problem you are having, then we can surely help
>> you fix it...
> 
> 
> That's really pretty much all there is! I'll paste the whole function
> below; the only thing I'm leaving out is the part at the top where it
> declares a few variables, logs the user in (which doesn't affect the
> $text variable), and then prints the data to MySQL.

We are not interested in whole long functions but only on the relevant
parts.

> The data comes from a contenteditable, and when people paste things it
> needs to be manipulated a bit, which is mostly what this function
> does. I don't have a sample of raw content (I don't save it before it
> runs through the function), but here's a sample of a complete string
> that was printed (I left the content because I thought you guys might
> get a kick out of it):

First: try the string you have posted. Your function will remove the
second span part!

And then: why don't you output the string before putting it in your
function? You need to look at the input!

Solution is probably simple: you are doing a lot of replacements. Assume
the input is "<span><br><b></b></span>". Then you don't remove the spam.
But later you remove the b. If you reverse the order, you would also
remove the span.

So you can try running the fixtext function more than once or try to
change the order of your 10000 replacements.

- Wolf

Next time please try to post a short program that one can run without
changing/adding anything! Often writing such a short program will point
you to the problem so that you can solve it on your own.



------------------------------

Date: Wed, 23 Feb 2011 21:19:57 -0500
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Ruby on rails training for Perl developers
Message-Id: <m2sjvemawi.fsf@sherm.shermpendley.com>

ccc31807 <cartercc@gmail.com> writes:

> What I can't figure out is why a Perl developer would have much
> interest in learning Ruby.

Why would a red painter be interested in learning blue? Could someone
who only knew one color honestly claim to be a painter to begin with?

sherm--

-- 
Sherm Pendley
                                   <http://camelbones.sourceforge.net>
Cocoa Developer


------------------------------

Date: Thu, 24 Feb 2011 14:01:33 +0000
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: Ruby on rails training for Perl developers
Message-Id: <4d6664b2$0$12159$fa0fcedb@news.zen.co.uk>

On 24/02/2011 02:19, Sherm Pendley wrote:
> ccc31807<cartercc@gmail.com>  writes:
>
>> What I can't figure out is why a Perl developer would have much
>> interest in learning Ruby.
>
> Why would a red painter be interested in learning blue?

I don't know of any decorators or artists who only know red -- so this 
looks a bit like a man of straw to me.

I can't claim familiarity with LISP or APL or hundreds of other fine 
programming languages. Nevertheless I have programmed in a handful of 
languages and regard myself as a programmer despite not knowing Ruby.


> Could someone
> who only knew one color honestly claim to be a painter to begin with?

Yes.
Just as I regard Ansell Adams a photographer and Benedict XVI a priest.


-- 
RGB


------------------------------

Date: Thu, 24 Feb 2011 09:35:50 -0500
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Ruby on rails training for Perl developers
Message-Id: <m2hbbtmreh.fsf@sherm.shermpendley.com>

RedGrittyBrick <RedGrittyBrick@spamweary.invalid> writes:

> On 24/02/2011 02:19, Sherm Pendley wrote:
>> ccc31807<cartercc@gmail.com>  writes:
>>
>>> What I can't figure out is why a Perl developer would have much
>>> interest in learning Ruby.
>>
>> Why would a red painter be interested in learning blue?
>
> I don't know of any decorators or artists who only know red -- so this
> looks a bit like a man of straw to me.

I'm referring to a house painter, not artist. Was that a misunderstanding,
or a deliberate straw man of your own?

> I can't claim familiarity with LISP or APL or hundreds of other fine
> programming languages. Nevertheless I have programmed in a handful of
> languages and regard myself as a programmer despite not knowing Ruby.

Once again, you're (intentionally?) missing the point. It's not Ruby in
particular that I'm referring to; it's the recognition that many languages
are useful, and the curiosity to learn more than one. Someone who knows
only one language, and lacks the curiosity to learn more, isn't a very
useful programmer IMHO.

>> Could someone
>> who only knew one color honestly claim to be a painter to begin with?
>
> Just as I regard Ansell Adams a photographer and Benedict XVI a priest.

*Any* analogy fails if you (deliberately?) take it too far beyond the
intended meaning.

sherm--

-- 
Sherm Pendley
                                   <http://camelbones.sourceforge.net>
Cocoa Developer


------------------------------

Date: Thu, 24 Feb 2011 06:54:06 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Ruby on rails training for Perl developers
Message-Id: <e16c34d9-b555-497c-8b1b-1610a37d9b0a@o18g2000prh.googlegroups.com>

On Feb 23, 9:19=A0pm, Sherm Pendley <sherm.pend...@gmail.com> wrote:
> > What I can't figure out is why a Perl developer would have much
> > interest in learning Ruby.
>
> Why would a red painter be interested in learning blue? Could someone
> who only knew one color honestly claim to be a painter to begin with?

Thank you for the opportunity to clarify this.

We (speaking as one who uses Perl as his primary language) all know
and use other languages all day, every day -- like SQL, HTML, XML,
CSS, JavaScript, and so on. Not that these are Turing complete, but
they ARE languages that you must learn in order to use.

Also, most of us have used and continue to use other 'big' languages,
like C, or Java. I came to Perl from Java, and actually revert to Java
when I work on a big project. Java allows you to organize your code in
classes, with attributes and methods, and for a big project with lots
of classes it results in a product much easier to understand than
Perl. It's not that you /couldn't/ write a big app in Perl, it's just
that most use Java, or C++, or C#.

Ruby has a saying that it's Perl done right. Having used a little
Ruby, I can see how this saying makes sense. However, Perl is a more
powerful language than Ruby (my opinion), and a Perlista who learns
Ruby for the purpose of replacing his language of choice with Ruby is
moving in the wrong direction. IOW, it would be like a sports driver
giving up a Porsche for a VW in order to go faster.

I fully agree with you point about learning other languages. I have
been studying Common Lisp and Erlang, and have begun to rewrite some
of my Perl scripts in Lisp. Also, this year (2011) I have been
introduced to Prolog and R, and have placed both of these languages
near the top of my to-learn list. Prolog especially -- it's not a
replacement for Perl, but it will do different things, and you can
certainly use Perl and Prolog in tandem, the first to produce the
facts and rules from a data file and the second to search for your
results.

CC.


------------------------------

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 3299
***************************************


home help back first fref pref prev next nref lref last post