I'm sure there are more elegant ways to do this, and I'm sure they'll be
coming through the list shortly, but here's an option:


my @days =('Sunday','Monday','Tuesday',
'Wednesday','Thursday','Friday','Saturday');
foreach my $text(@days) {
 $text =~ s/day/day\'s Games/;
}


-----
Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Erich C. Beyrent
Sent: Wednesday, December 04, 2002 10:34 AM
To: [EMAIL PROTECTED]
Subject: Puzzle of the Week


Hey everyone,

I have a string of data that I am parsing that looks like this:

        # Replace all of the apostrophed days of week
        if ($text =~ s/(Sunday's)|(Sunday's Games)/)
                {
                $day = "Sunday";
                $text =~ s/(Sunday's)|(Sunday's Games)//;
                }
        elsif ($text =~ s/(Monday's)|(Monday's Games)/)
                {
                $day = "Monday";
                $text =~ s/(Monday's)|(Monday's Games)//;
                }
        elsif ($text =~ s/(Tuesday's)|(Tuesday's Games)/)
                {
                $day = "Tuesday";
                $text =~ s/(Tuesday's)|(Tuesday's Games)//;
                }
        elsif ($text =~ s/(Wednesday's)|(Wednesday's Games)/)
                {
                $day = "Wednesday";
                $text =~ s/(Wednesday's)|(Wednesday's Games)//;
                }
        elsif ($text =~ s/(Thursday's)|(Thursday's Games)/)
                {
                $day = "Thursday";
                $text =~ s/(Thursday's)|(Thursday's Games)//;
                }
        elsif ($text =~ s/(Friday's)|(Friday's Games)/)
                {
                $day = "Friday";
                $text =~ s/(Friday's)|(Friday's Games)//;
                }
        elsif ($text =~ s/(Saturday's)|(Saturday's Games)/)
                {
                $day = "Saturday";
                $text =~ s/(Saturday's)|(Saturday's Games)//;
                }

Surely there is a more efficient and cleaner way to code this.  Any and all
assistance is GREATLY appreciated.

Thanks!

-Erich-

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to