[32826] in Perl-Users-Digest
Perl-Users Digest, Issue: 4091 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 6 14:09:38 2013
Date: Fri, 6 Dec 2013 11:09:04 -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 Fri, 6 Dec 2013 Volume: 11 Number: 4091
Today's topics:
anything like cassandra or riak in perl? <visphatesjava@gmail.com>
Re: anything like cassandra or riak in perl? <vilain@NOspamcop.net>
Extract sample (w/o replacement) <gamo@telecable.es>
Re: Extract sample (w/o replacement) <peter@makholm.net>
Re: Extract sample (w/o replacement) <gamo@telecable.es>
Re: Extract sample (w/o replacement) <hjp-usenet3@hjp.at>
Re: Extract sample (w/o replacement) <gamo@telecable.es>
Why is this sub removing newlines?? <jblack@nospam.com>
Re: Why is this sub removing newlines?? <rweikusat@mobileactivedefense.com>
Re: Why is this sub removing newlines?? (hymie!)
Re: Why is this sub removing newlines?? <jimsgibson@gmail.com>
Re: Why is this sub removing newlines?? <cwilbur@chromatico.net>
Re: Why is this sub removing newlines?? <ben@morrow.me.uk>
Re: Why is this sub removing newlines?? <ben@morrow.me.uk>
Re: Why is this sub removing newlines?? <news@lawshouse.org>
Re: Why is this sub removing newlines?? <gamo@telecable.es>
Re: Why is this sub removing newlines?? <jblack@nospam.com>
Re: Why is this sub removing newlines?? <rweikusat@mobileactivedefense.com>
Re: Why is this sub removing newlines?? <jurgenex@hotmail.com>
Re: Why is this sub removing newlines?? <ben@morrow.me.uk>
Re: Why is this sub removing newlines?? <jimsgibson@gmail.com>
Re: Why is this sub removing newlines?? <janek_schleicher@yahoo.de>
Re: Why is this sub removing newlines?? <rweikusat@mobileactivedefense.com>
Re: Why is this sub removing newlines?? perlpilot@gmail.com
Re: Why is this sub removing newlines?? <jblack@nospam.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 5 Dec 2013 22:01:21 -0800 (PST)
From: johannes falcone <visphatesjava@gmail.com>
Subject: anything like cassandra or riak in perl?
Message-Id: <99fb4dd4-92cb-41e3-8b8a-7aa2ff743841@googlegroups.com>
whats perls answer to mongodb?
------------------------------
Date: Fri, 06 Dec 2013 00:47:39 -0800
From: Michael Vilain <vilain@NOspamcop.net>
Subject: Re: anything like cassandra or riak in perl?
Message-Id: <vilain-F714D1.00473906122013@news.individual.net>
In article <99fb4dd4-92cb-41e3-8b8a-7aa2ff743841@googlegroups.com>,
johannes falcone <visphatesjava@gmail.com> wrote:
> whats perls answer to mongodb?
That's not a function of perl itself. It's a function of the DBI and
Mongodb driver.
http://search.cpan.org/dist/MongoDB/
How to install it:
http://docs.mongodb.org/ecosystem/drivers/perl/
--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]
------------------------------
Date: Fri, 06 Dec 2013 12:34:51 +0100
From: gamo <gamo@telecable.es>
Subject: Extract sample (w/o replacement)
Message-Id: <l7scot$alg$1@speranza.aioe.org>
It's a better way to do this?
my @matrix = 1..10_000_000;
sub extract{
my $ind = int rand ($#matrix+1);
($matrix[$ind],$matrix[-1]) = ($matrix[-1],$matrix[$ind]);
return pop @matrix;
}
The goal is to extact random elements without using shuffle, and
ever removing them from the original list.
TIA
------------------------------
Date: Fri, 06 Dec 2013 13:48:28 +0100
From: Peter Makholm <peter@makholm.net>
Subject: Re: Extract sample (w/o replacement)
Message-Id: <87wqjiqh5v.fsf@vps1.hacking.dk>
gamo <gamo@telecable.es> writes:
> my @matrix = 1..10_000_000;
>
> sub extract{
> my $ind = int rand ($#matrix+1);
> ($matrix[$ind],$matrix[-1]) = ($matrix[-1],$matrix[$ind]);
> return pop @matrix;
> }
I would use splice instead of reordering the array
sub extract {
my $index = int rand @matrix;
return splice @matrix, $index, 1;
}
but I don't know if it faster. Benchmarking is left to the reader if it
is important.
//Makholm
------------------------------
Date: Fri, 06 Dec 2013 14:10:28 +0100
From: gamo <gamo@telecable.es>
Subject: Re: Extract sample (w/o replacement)
Message-Id: <l7sic6$rjg$1@speranza.aioe.org>
El 06/12/13 13:48, Peter Makholm escribió:
> gamo <gamo@telecable.es> writes:
>
>> my @matrix = 1..10_000_000;
>>
>> sub extract{
>> my $ind = int rand ($#matrix+1);
>> ($matrix[$ind],$matrix[-1]) = ($matrix[-1],$matrix[$ind]);
>> return pop @matrix;
>> }
>
> I would use splice instead of reordering the array
>
> sub extract {
> my $index = int rand @matrix;
>
> return splice @matrix, $index, 1;
> }
>
> but I don't know if it faster. Benchmarking is left to the reader if it
> is important.
>
> //Makholm
>
Something is wrong, because splice it's a lot slower.
Thanks
------------------------------
Date: Fri, 6 Dec 2013 18:53:27 +0100
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: Extract sample (w/o replacement)
Message-Id: <slrnla43on.g52.hjp-usenet3@hrunkner.hjp.at>
On 2013-12-06 13:10, gamo <gamo@telecable.es> wrote:
> El 06/12/13 13:48, Peter Makholm escribió:
>> gamo <gamo@telecable.es> writes:
>>> my @matrix = 1..10_000_000;
>>>
>>> sub extract{
>>> my $ind = int rand ($#matrix+1);
>>> ($matrix[$ind],$matrix[-1]) = ($matrix[-1],$matrix[$ind]);
>>> return pop @matrix;
>>> }
>>
>> I would use splice instead of reordering the array
>>
>> sub extract {
>> my $index = int rand @matrix;
>>
>> return splice @matrix, $index, 1;
>> }
>>
>> but I don't know if it faster. Benchmarking is left to the reader if it
>> is important.
>>
>> //Makholm
>>
>
> Something is wrong, because splice it's a lot slower.
That was to be expected. Think for a moment what splice does.
hp
--
_ | Peter J. Holzer | Fluch der elektronischen Textverarbeitung:
|_|_) | | Man feilt solange an seinen Text um, bis
| | | hjp@hjp.at | die Satzbestandteile des Satzes nicht mehr
__/ | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel
------------------------------
Date: Fri, 06 Dec 2013 19:34:28 +0100
From: gamo <gamo@telecable.es>
Subject: Re: Extract sample (w/o replacement)
Message-Id: <l7t5bl$nv1$1@speranza.aioe.org>
El 06/12/13 18:53, Peter J. Holzer escribió:
>> Something is wrong, because splice it's a lot slower.
> That was to be expected. Think for a moment what splice does.
>
> hp
When it srinks the size of the list, re-indexing, or
something worst. Anyway, I thought that there could be
a more efficient method than mine.
Thanks
------------------------------
Date: Thu, 5 Dec 2013 12:50:36 -0600
From: John Black <jblack@nospam.com>
Subject: Why is this sub removing newlines??
Message-Id: <MPG.2d0a86f45a55040a98979f@news.eternal-september.org>
This sub is just supposed to strip off whitespace (at both the beginning and end of a
string). But its also stripping off newlines at the end of the string! Why would that be?
\s does not include newline, right?
sub trim()
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
John Black
------------------------------
Date: Thu, 05 Dec 2013 19:09:54 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Why is this sub removing newlines??
Message-Id: <87y53zazct.fsf@sable.mobileactivedefense.com>
John Black <jblack@nospam.com> writes:
> This sub is just supposed to strip off whitespace (at both the beginning and end of a
> string). But its also stripping off newlines at the end of the string! Why would that be?
> \s does not include newline, right?
>
> sub trim()
> {
> my $string = shift;
> $string =~ s/^\s+//;
> $string =~ s/\s+$//;
> return $string;
> }
[rw@sable]~#perl -e 'print "\n" =~ /\s/, "\n"'
1
------------------------------
Date: 05 Dec 2013 19:40:21 GMT
From: hymie@lactose.homelinux.net (hymie!)
Subject: Re: Why is this sub removing newlines??
Message-Id: <52a0d6a5$0$47761$862e30e2@ngroups.net>
In our last episode, the evil Dr. Lacto had captured our hero,
John Black <jblack@nospam.com>, who said:
>\s does not include newline, right?
perldoc perlre
"\s" means the five characters "[ \f\n\r\t]"
--hymie! http://lactose.homelinux.net/~hymie hymie@lactose.homelinux.net
-------------------------------------------------------------------------------
------------------------------
Date: Thu, 05 Dec 2013 11:51:09 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Why is this sub removing newlines??
Message-Id: <051220131151097098%jimsgibson@gmail.com>
In article <MPG.2d0a86f45a55040a98979f@news.eternal-september.org>,
John Black <jblack@nospam.com> wrote:
> This sub is just supposed to strip off whitespace (at both the beginning and
> end of a
> string). But its also stripping off newlines at the end of the string! Why
> would that be?
> \s does not include newline, right?
'perldoc perlre' contains these excerpts:
Character Classes and other Special Escapes
...
In addition, Perl defines the following:
Sequence Note Description
...
\s [3] Match a whitespace character
...
[3] See "Backslash sequences" in perlrecharclass for details.
(end)
Following that reference to 'perldoc perlrecharclass' yields:
Whitespace
"\s" matches any single character that is considered whitespace. The
exact set of characters matched by "\s" depends on whether the source
string is in UTF-8 format and the locale or EBCDIC code page that is in
effect. If it's in UTF-8 format, "\s" matches what is considered
whitespace in the Unicode database; the complete list is in the table
below. Otherwise, if there is a locale or EBCDIC code page in effect,
"\s" matches whatever is considered whitespace by the current locale or
EBCDIC code page. Without a locale or EBCDIC code page, "\s" matches
the horizontal tab ("\t"), the newline ("\n"), the form feed ("\f"),
the carriage return ("\r"), and the space. (Note that it doesn't match
the vertical tab, "\cK".) Perhaps the most notable possible surprise
is that "\s" matches a non-breaking space only if the non-breaking
space is in a UTF-8 encoded string or the locale or EBCDIC code page
that is in effect has that character. See "Locale, EBCDIC, Unicode and
UTF-8".
(end)
So, yes, \s does include the newline.
--
Jim Gibson
------------------------------
Date: Thu, 05 Dec 2013 14:28:58 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Why is this sub removing newlines??
Message-Id: <87bo0vhzb9.fsf@new.chromatico.net>
>>>>> "JB" == John Black <jblack@nospam.com> writes:
JB> \s does not include newline, right?
perldoc perlrecharclass:
"\s" matches any single character considered whitespace.
and the following table:
0x00009 CHARACTER TABULATION h s
0x0000a LINE FEED (LF) vs
0x0000b LINE TABULATION v
0x0000c FORM FEED (FF) vs
0x0000d CARRIAGE RETURN (CR) vs
0x00020 SPACE h s
0x00085 NEXT LINE (NEL) vs [1]
0x000a0 NO-BREAK SPACE h s [1]
So yes, newline *is* considered whitespace.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Thu, 5 Dec 2013 20:13:50 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Why is this sub removing newlines??
Message-Id: <uc37na-csg1.ln1@anubis.morrow.me.uk>
Quoth hymie@lactose.homelinux.net (hymie!):
> In our last episode, the evil Dr. Lacto had captured our hero,
> John Black <jblack@nospam.com>, who said:
> >\s does not include newline, right?
>
> perldoc perlre
>
> "\s" means the five characters "[ \f\n\r\t]"
Only true under /a. Under Unicode matching it matches Unicode space
characters, which is a much larger set. Under locale matching, it uses
isspace(), which may or may not include characters like NBSP. (It should
always include newline.)
Ben
------------------------------
Date: Thu, 5 Dec 2013 20:16:55 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Why is this sub removing newlines??
Message-Id: <ni37na-csg1.ln1@anubis.morrow.me.uk>
Quoth Jim Gibson <jimsgibson@gmail.com>:
>
> Following that reference to 'perldoc perlrecharclass' yields:
>
> Whitespace
>
> "\s" matches any single character that is considered whitespace. The
> exact set of characters matched by "\s" depends on whether the source
> string is in UTF-8 format and the locale or EBCDIC code page that is in
> effect. If it's in UTF-8 format, "\s" matches what is considered
> whitespace in the Unicode database; the complete list is in the table
> below. Otherwise, if there is a locale or EBCDIC code page in effect,
> "\s" matches whatever is considered whitespace by the current locale or
> EBCDIC code page. Without a locale or EBCDIC code page, "\s" matches
> the horizontal tab ("\t"), the newline ("\n"), the form feed ("\f"),
> the carriage return ("\r"), and the space. (Note that it doesn't match
> the vertical tab, "\cK".) Perhaps the most notable possible surprise
> is that "\s" matches a non-breaking space only if the non-breaking
> space is in a UTF-8 encoded string or the locale or EBCDIC code page
> that is in effect has that character. See "Locale, EBCDIC, Unicode and
> UTF-8".
That's a pretty old copy of that documentation. Since 5.14 the Unicode
Bug has been fixed, and character-class matching no longer depends on
the internal format of the string.
Ben
------------------------------
Date: Thu, 05 Dec 2013 21:30:33 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: Why is this sub removing newlines??
Message-Id: <iZOdncAogdLnbT3PnZ2dnUVZ7sqdnZ2d@giganews.com>
On 05/12/13 18:50, John Black wrote:
> \s does not include newline, right?
John, I would have agreed with you. Plainly we're both wrong, as the
follow-ups, not to mention the documentation, have shown, but what is it
we're (mis)remembering? There's some circumstance in which newline \n
behaves differently from the other white space characters.
--
Henry Law Manchester, England
------------------------------
Date: Thu, 05 Dec 2013 22:53:02 +0100
From: gamo <gamo@telecable.es>
Subject: Re: Why is this sub removing newlines??
Message-Id: <l7qsju$k1n$1@speranza.aioe.org>
El 05/12/13 19:50, John Black escribió:
> This sub is just supposed to strip off whitespace (at both the beginning and end of a
> string). But its also stripping off newlines at the end of the string! Why would that be?
> \s does not include newline, right?
>
> sub trim()
> {
> my $string = shift;
> $string =~ s/^\s+//;
> $string =~ s/\s+$//;
> return $string;
> }
>
> John Black
>
This is absurd, but maybe do just what you want to do:
:~/test$ cat test.trim
#!/usr/bin/perl -W
$s = " only this:
";
print trim($s);
sub trim{
my $string = shift;
my $space = ' ';
$string =~ s/$space+//;
$string = reverse $string;
$string =~ s/$space+//;
$string = reverse $string;
return $string;
}
:~/test$ perl test.trim
only this:
:~/test$
Best regards
------------------------------
Date: Thu, 5 Dec 2013 15:56:46 -0600
From: John Black <jblack@nospam.com>
Subject: Re: Why is this sub removing newlines??
Message-Id: <MPG.2d0ab29a546464fd9897a0@news.eternal-september.org>
In article <iZOdncAogdLnbT3PnZ2dnUVZ7sqdnZ2d@giganews.com>, news@lawshouse.org says...
>
> On 05/12/13 18:50, John Black wrote:
> > \s does not include newline, right?
>
> John, I would have agreed with you. Plainly we're both wrong, as the
> follow-ups, not to mention the documentation, have shown, but what is it
> we're (mis)remembering? There's some circumstance in which newline \n
> behaves differently from the other white space characters.
Now that I see that \s includes vertical and horizontal types of characters, it makes more
sense. Up to this point, I've been using \s as a shortcut for spaces or tabs. I'll have to
keep this in mind - I had wanted that trim function to not strip the newlines (and not add
any either if there wasn't one). Should not be hard to workaround. Thanks all.
John Black
------------------------------
Date: Thu, 05 Dec 2013 22:00:51 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Why is this sub removing newlines??
Message-Id: <87pppbarfw.fsf@sable.mobileactivedefense.com>
Henry Law <news@lawshouse.org> writes:
> On 05/12/13 18:50, John Black wrote:
>> \s does not include newline, right?
>
> John, I would have agreed with you. Plainly we're both wrong, as the
> follow-ups, not to mention the documentation, have shown, but what is
> it we're (mis)remembering? There's some circumstance in which newline
> \n behaves differently from the other white space characters.
Guess: There's a circumstance where it behaves differently from other
characters, namely, a . won't match \n unless the s-flag is used
together with the match operator.
------------------------------
Date: Thu, 05 Dec 2013 14:11:16 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Why is this sub removing newlines??
Message-Id: <fau1a9l2ntuln8vhscm5jdlt9diinvgbhv@4ax.com>
John Black <jblack@nospam.com> wrote:
>In article <iZOdncAogdLnbT3PnZ2dnUVZ7sqdnZ2d@giganews.com>, news@lawshouse.org says...
>>
>> On 05/12/13 18:50, John Black wrote:
>> > \s does not include newline, right?
>>
>> John, I would have agreed with you. Plainly we're both wrong, as the
>> follow-ups, not to mention the documentation, have shown, but what is it
>> we're (mis)remembering? There's some circumstance in which newline \n
>> behaves differently from the other white space characters.
>
>Now that I see that \s includes vertical and horizontal types of characters, it makes more
>sense. Up to this point,
Try looking at it from a programming language point of view. Most modern
programming languages are free-format, i.e. in the program code a single
space is as good as 20 tabs or as 5 newlines. Therefore there is some
sense in including all of them in \s.
jue
------------------------------
Date: Thu, 5 Dec 2013 22:47:46 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Why is this sub removing newlines??
Message-Id: <idc7na-avh1.ln1@anubis.morrow.me.uk>
Quoth John Black <jblack@nospam.com>:
> In article <iZOdncAogdLnbT3PnZ2dnUVZ7sqdnZ2d@giganews.com>,
> news@lawshouse.org says...
> >
> > On 05/12/13 18:50, John Black wrote:
> > > \s does not include newline, right?
> >
> > John, I would have agreed with you. Plainly we're both wrong, as the
> > follow-ups, not to mention the documentation, have shown, but what is it
> > we're (mis)remembering? There's some circumstance in which newline \n
> > behaves differently from the other white space characters.
>
> Now that I see that \s includes vertical and horizontal types of
> characters, it makes more sense. Up to this point, I've been using \s
> as a shortcut for spaces or tabs. I'll have to keep this in mind - I
> had wanted that trim function to not strip the newlines (and not add
> any either if there wasn't one). Should not be hard to workaround.
You want \h or \p{Blank} or [[:blank:]] (depending on what Unicode
semantics you want). Note that, unlike \s, /a will not restrict the
range of \h, since it was newly introduced in 5.10. Of course, it's
probably easier to just use [ \t] if that's what you mean...
Ben
------------------------------
Date: Thu, 05 Dec 2013 17:08:13 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Why is this sub removing newlines??
Message-Id: <051220131708136110%jimsgibson@gmail.com>
In article <ni37na-csg1.ln1@anubis.morrow.me.uk>, Ben Morrow
<ben@morrow.me.uk> wrote:
> Quoth Jim Gibson <jimsgibson@gmail.com>:
> >
> > Following that reference to 'perldoc perlrecharclass' yields:
> >
> > Whitespace
> >
<snipped>
> That's a pretty old copy of that documentation. Since 5.14 the Unicode
> Bug has been fixed, and character-class matching no longer depends on
> the internal format of the string.
>
> Ben
Thanks. It's from 5.12.4, which is what I am using.
--
Jim Gibson
------------------------------
Date: Fri, 06 Dec 2013 09:22:51 +0100
From: Janek Schleicher <janek_schleicher@yahoo.de>
Subject: Re: Why is this sub removing newlines??
Message-Id: <bgdfqrFptafU1@mid.individual.net>
Am 05.12.2013 19:50, schrieb John Black:
> This sub is just supposed to strip off whitespace (at both the beginning and end of a
> string). But its also stripping off newlines at the end of the string! Why would that be?
> \s does not include newline, right?
>
> sub trim()
> {
> my $string = shift;
> $string =~ s/^\s+//;
> $string =~ s/\s+$//;
> return $string;
> }
BTW,
is there any reason to reinvent the wheel.
There are several CPAN-modules doing one of the most often needed Jobs:
- https://metacpan.org/pod/String::Trim
- https://metacpan.org/pod/String::Strip
- https://metacpan.org/pod/Text::Trim
In case it makes the source code more readable, shorter, easier to
maintain and will often have less bugs.
Greetings,
Janek
------------------------------
Date: Fri, 06 Dec 2013 14:29:55 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Why is this sub removing newlines??
Message-Id: <87siu63vdo.fsf@sable.mobileactivedefense.com>
Janek Schleicher <janek_schleicher@yahoo.de> writes:
> Am 05.12.2013 19:50, schrieb John Black:
>> This sub is just supposed to strip off whitespace (at both the beginning and end of a
>> string). But its also stripping off newlines at the end of the string! Why would that be?
>> \s does not include newline, right?
>>
>> sub trim()
>> {
>> my $string = shift;
>> $string =~ s/^\s+//;
>> $string =~ s/\s+$//;
>> return $string;
>> }
>
> BTW,
> is there any reason to reinvent the wheel.
> There are several CPAN-modules doing one of the most often needed Jobs:
> - https://metacpan.org/pod/String::Trim
> - https://metacpan.org/pod/String::Strip
> - https://metacpan.org/pod/Text::Trim
Using a gross oversimplification, there is only one 'wheel'[*] but there
are already at least three different CPAN modules for deleting
characters at the beginning or the end of a string. Consequently, none
of them can be the equivalent of 'the wheel' for solving this problem.
[*] Actually, there are all kinds of different wheels and new kinds are
constantly being invented.
------------------------------
Date: Fri, 6 Dec 2013 07:50:34 -0800 (PST)
From: perlpilot@gmail.com
Subject: Re: Why is this sub removing newlines??
Message-Id: <8b061445-837f-4d23-82d9-99c25eb1f13a@googlegroups.com>
On Thursday, December 5, 2013 4:00:51 PM UTC-6, Rainer Weikusat wrote:
> Henry Law <news@lawshouse.org> writes:
>=20
> > On 05/12/13 18:50, John Black wrote:
>=20
> >> \s does not include newline, right?
>=20
> >
>=20
> > John, I would have agreed with you. Plainly we're both wrong, as the
>=20
> > follow-ups, not to mention the documentation, have shown, but what is
>=20
> > it we're (mis)remembering? There's some circumstance in which newline
>=20
> > \n behaves differently from the other white space characters.
>=20
>=20
>=20
> Guess: There's a circumstance where it behaves differently from other
>=20
> characters, namely, a . won't match \n unless the s-flag is used
>=20
> together with the match operator.
Also, there's the fact that $ in regex matches the end of the string or bef=
ore the newline at the end. If you're thinking of or expecting that secon=
d behavior and have forgotten about greediness, you may expect that the new=
line wouldn't be removed in the expression s/\s+$//;
Maybe a bit of a stretch, but as long we're guessing what's in other people=
's heads ... :-)
-Scott
------------------------------
Date: Fri, 6 Dec 2013 10:58:23 -0600
From: John Black <jblack@nospam.com>
Subject: Re: Why is this sub removing newlines??
Message-Id: <MPG.2d0bbe2660ade52c9897a1@news.eternal-september.org>
In article <idc7na-avh1.ln1@anubis.morrow.me.uk>, ben@morrow.me.uk says...
> Of course, it's
> probably easier to just use [ \t] if that's what you mean...
Well, for many long regexs \s is used a lot and they are already ugly enough without
substituting [ \t] everywhere. I think that now that I know \n is included, I can be careful
and work around that when it matters with [ \t] or something else. Thanks.
John Black
------------------------------
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 4091
***************************************