| Author |
Count how many times find and replaced happened
|
|
| blnukem 2004-04-29, 11:50 am |
| Hi All
Is there a way to count how many times $Line =~ s///; has happened?
foreach my $Line (@ArrayToRead) {
$Line =~ s/TextToFind/TextToReplace/i;
}
Thank You
Blnukem
| |
| Anno Siegel 2004-04-29, 11:50 am |
| blnukem <bill@hotmail.com> wrote in comp.lang.perl.misc:
> Hi All
>
> Is there a way to count how many times $Line =~ s///; has happened?
>
> foreach my $Line (@ArrayToRead) {
> $Line =~ s/TextToFind/TextToReplace/i;
> }
Use grep in scalar context:
my $count = grep s/TextToFind/TextToReplace/i, @ArrayToRead;
Anno
| |
| David K. Wall 2004-04-29, 11:50 am |
| Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> blnukem <bill@hotmail.com> wrote in comp.lang.perl.misc:
>
> Use grep in scalar context:
>
> my $count = grep s/TextToFind/TextToReplace/i, @ArrayToRead;
That's an interesting use of grep and s///.
My first thought was that he meant the number of substitutions, which
can be very different. That is,
my $count;
$count += s/TextToFind/TextToReplace/g for @array;
(note 'g' option)
/me shrugs...
| |
| Tad McClellan 2004-04-29, 11:50 am |
| blnukem <bill@hotmail.com> wrote:
> Is there a way to count how many times $Line =~ s///; has happened?
my $how_many_times = $Line =~ s///;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
| |
|
|
"blnukem" <bill@hotmail.com> wrote in message
news:S%6kc.42117$Gd3.9618519@news4.srv.hcvlny.cv.net...
> Hi All
>
> Is there a way to count how many times $Line =~ s///; has happened?
>
> foreach my $Line (@ArrayToRead) {
> $Line =~ s/TextToFind/TextToReplace/i;
> }
>
my $count = 0;
foreach my $Line (@ArrayToRead) {
$Line =~ s/TextToFind/TextToReplace/i and $count += 1;
}
-Robin
| |
| Tad McClellan 2004-04-30, 3:41 am |
| Robin <webmaster@infusedlight> wrote:
> From: "Robin" <webmaster @ infusedlight . net>
Please choose one posting address and stick to it.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
| |
|
|
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnc92qpb.3qo.tadmc@magna.augustmail.com...
> Robin <webmaster@infusedlight> wrote:
>
>
>
> Please choose one posting address and stick to it.
yeah I did...sorry.
-Robin
| |
| Alien Resident 2004-04-30, 3:42 am |
| Tad McClellan wrote:
> Robin <webmaster@infusedlight> wrote:
>
>
>
>
>
> Please choose one posting address and stick to it.
>
>
oh, yea... a couple got by me. Let's make this simple... contains: infusedlight or Robin
or potential for teeth grinding... OK let's hope that does it.
-AR
| |
| Keith Keller 2004-04-30, 3:42 am |
| -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2004-04-29, Robin <webmaster@infusedlight> wrote:
>
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrnc92qpb.3qo.tadmc@magna.augustmail.com...
[color=darkred]
> yeah I did...sorry.
You did? This is the third address you've used in the span of a few
w s. Webmaster, indeed--I hope your webmaster skillz are markedly
better than your skillz "creating dynamic websites with CGI".
- --keith
- --
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQFAkYcThVcNCxZ5ID8RAoSsAJ9q/DYvsSl2k3mo33pyIUsU4uzSgQCfQQME
O2p6VLy5IL5gJB6me2iXH9w=
=XJEX
-----END PGP SIGNATURE-----
| |
|
|
"Keith Keller" <kkeller-usenet@wombat.san-francisco.ca.us> wrote in message
news:ku0s6c.mq.ln@goaway.wombat.san-francisco.ca.us...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 2004-04-29, Robin <webmaster@infusedlight> wrote:
>
>
> You did? This is the third address you've used in the span of a few
> w s. Webmaster, indeed--I hope your webmaster skillz are markedly
> better than your skillz "creating dynamic websites with CGI".
well, two of those email addresses are prefixed with "webmaster", but it
doesn't improve my webmaster skills.
-Robin
|
|
|
|