CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Post deleted by alexloas

 



alexloas
Novice

Oct 21, 2009, 11:24 AM

Post #1 of 4 (643 views)
Post deleted by alexloas

 


shawnhcorey
Enthusiast


Oct 21, 2009, 1:10 PM

Post #2 of 4 (637 views)
Re: [alexloas] NEED SERIOUS HELP! [In reply to] Can't Post

Try:

Code
#!/usr/bin/env perl 

use strict;
use warnings;

my $text = '';
{
local $/ = "";
$text = <>;
}
my $dont = "don't";
$text=~s/do not/$dont/g;
print"$text\n";

my $count = () = $text =~/don\'t/g;
print "there are $count don'ts\n";


__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


alexloas
Novice

Oct 21, 2009, 6:16 PM

Post #3 of 4 (626 views)
Re: [shawnhcorey] NEED SERIOUS HELP! [In reply to] Can't Post

Thanks, it worked. But I forgot to clarify something.
I'm trying to make the program print contractions if it recognizes them with if statements.

#!usr/bin/perl
my $text = join('', <>);
$dont = "don't";
$text=~s/do not/$dont/g;

$Dont = "Don't";
$text=~s/Do not/$Dont/g;

$isnt = "isn't";
$text=~s/is not/$isnt/g;
print"$text\n";

print"Replacements: (original => replacement, occurrences)\n";
if ($dont){
while($text =~/don't/g) {$count++}
print "do not => don't, $count\n";
}

if ($Dont){
while($text =~/Don't/g) {$count++}
print "Do not => Don't, $count\n";

}

if ($isnt){
while($text =~/isn't/g) {$count++}
print "is not => isn't, $count\n";

}

Anyone want to give it a try?


alexloas
Novice

Oct 21, 2009, 6:23 PM

Post #4 of 4 (624 views)
Re: [alexloas] NEED SERIOUS HELP! [In reply to] Can't Post

please try to leave comments if you can, thank you.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives