Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options


by azatoth (Curate)
on Feb 02, 2001 at 19:16 UTC ( [id://55997] : CUFP . print w/replies, xml ) Need Help??

Finished - my

Cockney Rhyming Slang Converter

Only takes one string at a time. Also adds a "Norf Lahndan" accent...

#!/usr/bin/perl -w use strict; my $eng; print "\n\n"; print "\tWelcome to the CRSC!\n"; print "\t(Cockney Rhyming Slang Converter)\n"; print "\n\n"; print "Enter a sentence to be converted :\n"; ($eng = <STDIN>); $eng =~ s/my/me/ig; $eng =~ s/your/yer/ig; $eng =~ s/you're/yer/ig; $eng =~ s/\byou\b/ya/ig; $eng =~ s/aren't you/int'cha/ig; $eng =~ s/out/aht/ig; $eng =~ s/um/am/ig; $eng =~ s/uc/ac/ig; $eng =~ s/or(?!o)/aw/ig; #$eng =~ s/oro/oro/ig; # UPDATED : Props to Chipmunk and Boo $eng =~ s/al/aw/ig; $eng =~ s/ath/arf/ig; $eng =~ s/ith/iv/ig; $eng =~ s/\bh/'/ig; $eng =~ s/ow/ah/ig; $eng =~ s/ath/arf/ig; $eng =~ s/ord/awd/ig; $eng =~ s/ith/iv/ig; $eng =~ s/oth/uvv/ig; $eng =~ s/\bten/cock and hen/ig; $eng =~ s/\bgrand/bag of sand/ig; $eng =~ s/\btwo/bottle of glue/ig; $eng =~ s/\bfiver/lady godiva/ig; $eng =~ s/\bsix/dorothy dicks/ig; $eng =~ s/\beight/garden gate/ig; $eng =~ s/\bninety-nine/calvin klein/ig; $eng =~ s/\ball-dayer/leo sayer/ig; $eng =~ s/\balone/jack jones/ig; $eng =~ s/\barm\b/chalk farm/ig; $eng =~ s/\barmy/kate carney/ig; $eng =~ s/\barse/bottle and glass/ig; $eng =~ s/\bback/hammer and tack/ig; $eng =~ s/\bballs/cobblers awls/ig; $eng =~ s/\bbank/iron tank/ig; $eng =~ s/\bpub\b/nuclear sub/ig; $eng =~ s/\bstella/nelson mandela/ig; $eng =~ s/\bboozer/battle cruiser/ig; $eng =~ s/\bbeard/strange and wierd/ig; $eng =~ s/\bbed/uncle ted/ig; $eng =~ s/\bbeef/itchy teeth/ig; $eng =~ s/\bbeers/britney spears/ig; $eng =~ s/\bbelieve/adam and eve/ig; $eng =~ s/\bbelly/derby kelly/ig; $eng =~ s/\bbent/stoke-on-trent/ig; $eng =~ s/\bbike/dick van dyke/ig; $eng =~ s/\bbigot/lester piggot/ig; $eng =~ s/\bbint/polo mint/ig; $eng =~ s/\bbitches/ronald riches/ig; $eng =~ s/\bbitter/apple fritter/ig; $eng =~ s/\bblazer/razor/ig; $eng =~ s/\bblood/claret/ig; $eng =~ s/\bblotto/santa's grotto/ig; $eng =~ s/\bboat/nanny goat/ig; $eng =~ s/\bbollocks/jackson pollocks/ig; $eng =~ s/\bbombs/uncle toms/ig; $eng =~ s/\bbomb/uncle tom/ig; $eng =~ s/\bboss/profit and loss/ig; $eng =~ s/\bbottle/aristotle/ig; $eng =~ s/\btwo/bottle of glue/ig; $eng =~ s/\bbreasts/georgie bests/ig; $eng =~ s/\bbroke/hearts of oak/ig; $eng =~ s/\bbullshitter/little critter/ig; $eng =~ s/\bbum/deaf and dumb/ig; $eng =~ s/\bbunk/pineapple chunk/ig; $eng =~ s/\bburp/wyatt earp/ig; $eng =~ s/\bburst/geoff hurst/ig; $eng =~ s/\bbutter/mutter and stutter/ig; $eng =~ s/\bcab/sherbet dab/ig; $eng =~ s/\bcafe/colonel gadaffi/ig; $eng =~ s/\bcar/jam jar/ig; $eng =~ s/\bcash/sausage and mash/ig; $eng =~ s/\bcat/this and that/ig; $eng =~ s/\bchancer/bengal lancer/ig; $eng =~ s/\bcell/flowery dell/ig; $eng =~ s/\bchange/rifle range/ig; $eng =~ s/\bchapel/pineapple/ig; $eng =~ s/\bcharlie/boutros boutros gali/ig; $eng =~ s/\bchat/top hat/ig; $eng =~ s/\bcheese/john cleese/ig; $eng =~ s/\bcheque/gregory peck/ig; $eng =~ s/\bcheck/gregory peck/ig; $eng =~ s/\bchest/bird's nest/ig; $eng =~ s/\bchilly/picadilly/ig; $eng =~ s/\bchin/harry lin/ig; $eng =~ s/\bchinky/thumb and pinky/ig; $eng =~ s/\bchink/tiddlywink/ig; $eng =~ s/\bchips/jockeys whips/ig; $eng =~ s/\bcider/wynona rider/ig; $eng =~ s/\bcigar/la-di-da/ig; $eng =~ s/\bcigarette/snout/ig; $eng =~ s/\bclock/tick-tock/ig; $eng =~ s/\bclue/scooby doo/ig; $eng =~ s/\bcoat/weasel and stoat/ig; $eng =~ s/\bcold/soldiers bold/ig; $eng =~ s/\bcopper/bottle and stopper/ig; $eng =~ s/\bcorner/johnny horner/ig; $eng =~ s/\bcrap/pony and trap/ig; $eng =~ s/\bcrime/lemon and lime/ig; $eng =~ s/\bcripple/raspberry ripple/ig; $eng =~ s/\bcrust/you must/ig; $eng =~ s/\bcupboard/mother hubbard/ig; $eng =~ s/\bcurry/ruby murray/ig; $eng =~ s/\bcustoms and excise/church boys/ig; $eng =~ s/\bdaft/fore and aft/ig; $eng =~ s/\bdance/jack palance/ig; $eng =~ s/\bdaughter/bricks and mortar/ig; $eng =~ s/\bdead/brown bread/ig; $eng =~ s/\bdeaf/mutt and jeff/ig; $eng =~ s/\bdiet/brixton riot/ig; $eng =~ s/\bdinner/john skinner/ig; $eng =~ s/\bdock/red sock/ig; $eng =~ s/\bdog/cherry hog/ig; $eng =~ s/\bdole/rock and roll/ig; $eng =~ s/\bdollar/oxford scholar/ig; $eng =~ s/\bdoor/patrick moore/ig; $eng =~ s/\bdope/bob hope/ig; $eng =~ s/\bdose/half a gross/ig; $eng =~ s/\bdraft/george raft/ig; $eng =~ s/\bdrink/kitchen sink/ig; $eng =~ s/\bdrunk/elephant's trunk/ig; $eng =~ s/\bdump/forest gump/ig; $eng =~ s/\bears/lords and peers/ig; $eng =~ s/\beasy/bright and breezy/ig; $eng =~ s/\beighth/henry/ig; $eng =~ s/\belbow/spanish archer/ig; $eng =~ s/\bemail/british rail/ig; $eng =~ s/\bexam/green eggs and ham/ig; $eng =~ s/\beyes/mince pies/ig; $eng =~ s/\bface/boat race/ig; $eng =~ s/\bfaces/airs and graces/ig; $eng =~ s/\bfacts/brass tacks/ig; $eng =~ s/\bfake/ricki lake/ig; $eng =~ s/\bfanny/jack and danny/ig; $eng =~ s/\bfart/horse and cart/ig; $eng =~ s/\bfarting/george martin/ig; $eng =~ s/\bfault/whiskey malt/ig; $eng =~ s/\bfavour/cheesey quaver/ig; $eng =~ s/\bfax/nail and tacks/ig; $eng =~ s/\bfeet/plates of meat/ig; $eng =~ s/\bfifty/nifty/ig; $eng =~ s/\bfingers/longers and lingers/ig; $eng =~ s/\bflannel/suez canal/ig; $eng =~ s/\bflares/lionel blairs/ig; $eng =~ s/\bflash/harry dash/ig; $eng =~ s/\bflush/snow and slush/ig; $eng =~ s/\bflying squad/sweeney todd/ig; $eng =~ s/\bfork/roast pork/ig; $eng =~ s/\bgas/bottle of bass/ig; $eng =~ s/\bgeezer/fridge freezer/ig; $eng =~ s/\bgiggles/flight leiutenant biggles/ig; $eng =~ s/\bgin/vera lynn/ig; $eng =~ s/\bgin and tonic/philharmonic/ig; $eng =~ s/\bgirl/twist and twirl/ig; $eng =~ s/\bgiro/nightboat to cairo/ig; $eng =~ s/\bglobes/turtle doves/ig; $eng =~ s/\bgo\b/scapa flow/ig; $eng =~ s/\bgoal/sausage roll/ig; $eng =~ s/\bgravy/army and navy/ig; $eng =~ s/\bgreek/bubble and squeak/ig; $eng =~ s/\bgrief/omar sharif/ig; $eng =~ s/\bguts/comic cuts/ig; $eng =~ s/\bgym/fatboy slim/ig; $eng =~ s/\bhaemorrhoid/emma freud/ig; $eng =~ s/\bhair/tony blair/ig; $eng =~ s/\bham/uncle sam/ig; $eng =~ s/\bhammer/windjammer/ig; $eng =~ s/\bhand/ivory band/ig; $eng =~ s/\bhands/german bands/ig; $eng =~ s/\bhandy/jack and dandy/ig; $eng =~ s/\bhanky/widow twanky/ig; $eng =~ s/\bharsh/rodney marsh/ig; $eng =~ s/\bhat/tit for tat/ig; $eng =~ s/\bhead/loaf of bread/ig; $eng =~ s/\bheart/horse and cart/ig; $eng =~ s/\bhill/jack and jill/ig; $eng =~ s/\bhooker/one time looker/ig; $eng =~ s/\bhooter/pea shooter/ig; $eng =~ s/\bhorse/charing cross/ig; $eng =~ s/\bhot/peas in the pot/ig; $eng =~ s/\bhouse/cat and mouse/ig; $eng =~ s/\bhusband/old pot and pan/ig; $eng =~ s/\bice/white mice/ig; $eng =~ s/\bill/jimmy hill/ig; $eng =~ s/\bjacket/desmond hacket/ig; $eng =~ s/\bjail/rusty nail/ig; $eng =~ s/\bjeans/steve mcqueens/ig; $eng =~ s/\bjesus christ/cheese and rice/ig; $eng =~ s/\bjewellery/tom foolery/ig; $eng =~ s/\bjoke/rum and coke/ig; $eng =~ s/\bjudge/chocolate fudge/ig; $eng =~ s/\bkettle/hansel and gretel/ig; $eng =~ s/\bkeys/dancing fleas/ig; $eng =~ s/\bkid/saucepan lid/ig; $eng =~ s/\bkidney/sydney/ig; $eng =~ s/\bkipper/jack the ripper/ig; $eng =~ s/\bknackered/cream crackered/ig; $eng =~ s/\bknackers/jacobs crackers/ig; $eng =~ s/\bknees/biscuits and cheese/ig; $eng =~ s/\bknickers/alan whickers/ig; $eng =~ s/\bknife/drum and fife/ig; $eng =~ s/\blager/forsythe saga/ig; $eng =~ s/\blater/baked potatah/ig; $eng =~ s/\blather/how's your father/ig; $eng =~ s/\blaugh/giraffe/ig; $eng =~ s/\bleg/mystic meg/ig; $eng =~ s/\blegs/bacon and eggs/ig; $eng =~ s/\bliar/holy friar/ig; $eng =~ s/\blie/pork pie/ig; $eng =~ s/\blighter/kungfu fighter/ig; $eng =~ s/\blights/ian wrights/ig; $eng =~ s/\blodger/artful dodger/ig; $eng =~ s/\blook/butcher's hook/ig; $eng =~ s/\blost it/kate mossed it/ig; $eng =~ s/\blove/rubber glove/ig; $eng =~ s/\bmarge/little and large/ig; $eng =~ s/\bmark/finsbury park/ig; $eng =~ s/\bmarker/ronnie barker/ig; $eng =~ s/\bmarried/cash and carried/ig; $eng =~ s/\bmate/china plate/ig; $eng =~ s/\bmeat pie/dog's eye/ig; $eng =~ s/\bmeeting/buster keaton/ig; $eng =~ s/\bmental/chicken oriental/ig; $eng =~ s/\bmess/slits in a dress/ig; $eng =~ s/\bmiddle/hey diddle diddle/ig; $eng =~ s/\bmilk/acker bilk/ig; $eng =~ s/\bminge/edinburgh fringe/ig; $eng =~ s/\bmisses/plates and dishes/ig; $eng =~ s/\bmoney/bugs bunny/ig; $eng =~ s/\bmotor/haddock and bloater/ig; $eng =~ s/\bmouth/north and south/ig; $eng =~ s/\bmrs/love and kisses/ig; $eng =~ s/\bnark/grass in the park/ig; $eng =~ s/\bneck/bushel and peck/ig; $eng =~ s/\bnerves/west ham reserves/ig; $eng =~ s/\bnice/chicken and rice/ig; $eng =~ s/\bnick/shovel and pick/ig; $eng =~ s/\bnightmare/lionel blair/ig; $eng =~ s/\bnippy/bungle and zippy/ig; $eng =~ s/\bnose/i suppose/ig; $eng =~ s/\bnothing/nixies/ig; $eng =~ s/\bnumbers/cucumbers/ig; $eng =~ s/\bnun/hot cross bun/ig; $eng =~ s/\boff/frank bough/ig; $eng =~ s/\bold man/pot and pan/ig; $eng =~ s/\bout of order/alan border/ig; $eng =~ s/\bown/jack/ig; $eng =~ s/\bpants/alans/ig; $eng =~ s/\bpaper/linen draper/ig; $eng =~ s/\bpark/plimsoll mark/ig; $eng =~ s/\bparty/russell harty/ig; $eng =~ s/\bpee/rosy lee/ig; $eng =~ s/\bpenny/abergavenny/ig; $eng =~ s/\bpension/shawshank/ig; $eng =~ s/\bphone/dog and bone/ig; $eng =~ s/\bpiano/joanna/ig; $eng =~ s/\bpiddle/jimmy riddle/ig; $eng =~ s/\bpiles/farmer giles/ig; $eng =~ s/\bpillow/weeping willow/ig; $eng =~ s/\bpills/mick mills/ig; $eng =~ s/\bpinched/half-inched/ig; $eng =~ s/\bpish/single fish/ig; $eng =~ s/\bpiss\b/gypsy's kiss/ig; $eng =~ s/\bpissed/brahms and liszt/ig; $eng =~ s/\bplace/drum and bass/ig; $eng =~ s/\bplanner/elsie tanner/ig; $eng =~ s/\bplease/hairy knees/ig; $eng =~ s/\bpocket/sky rocket/ig; $eng =~ s/\bpolice/old bill/ig; $eng =~ s/\bponce/charlie ronce/ig; $eng =~ s/\bpork/mickey rourke/ig; $eng =~ s/\bpots/norman watts/ig; $eng =~ s/\bpounds/quid/ig; $eng =~ s/\bpox/cardboard box/ig; $eng =~ s/\bprat/paper hat/ig; $eng =~ s/\bpregnant/keith chegwin/ig; $eng =~ s/\bprick/hampton wick/ig; $eng =~ s/\bpriest/far east/ig; $eng =~ s/\bprinter/bernie winter/ig; $eng =~ s/\bpunters/billie bunters/ig; $eng =~ s/\bquarter/farmer's daughter/ig; $eng =~ s/\bqueer/chelsea pier/ig; $eng =~ s/\brabbits/nuns and habits/ig; $eng =~ s/\brain/andy cain/ig; $eng =~ s/\brally/manchester scally/ig; $eng =~ s/\brandy/mahatma ghandi/ig; $eng =~ s/\braw/bale of straw/ig; $eng =~ s/\breadies/duane eddies/ig; $eng =~ s/\breasons/four seasons/ig; $eng =~ s/\breek/ancient greek/ig; $eng =~ s/\brent/duke of kent/ig; $eng =~ s/\bride/charlie pride/ig; $eng =~ s/\bright/isle of wight/ig; $eng =~ s/\bring/highland fling/ig; $eng =~ s/\bring on finger/ling and linger/ig; $eng =~ s/\briver/shake and shiver/ig; $eng =~ s/\broad/frog and toad/ig; $eng =~ s/\brookie/biscuit and cookie/ig; $eng =~ s/\brough/brian clough/ig; $eng =~ s/\brow/bull and cow/ig; $eng =~ s/\bsack/tin tack/ig; $eng =~ s/\bsause/rocking horse/ig; $eng =~ s/\bscar/mars bar/ig; $eng =~ s/\bscore/bobby moore/ig; $eng =~ s/\bscot/sweaty sock/ig; $eng =~ s/\bscotch/gold watch/ig; $eng =~ s/\bscouse/mickey mouse/ig; $eng =~ s/\bseen/pearly queen/ig; $eng =~ s/\bshag\b/zig and zag/ig; $eng =~ s/\bshagged/melvyn bragged/ig; $eng =~ s/\bshark/noah's ark/ig; $eng =~ s/\bshave/all-night rave/ig; $eng =~ s/\bship/Happeny dip/ig; $eng =~ s/\bshit\b/eartha kitt/ig; $eng =~ s/\bshits\b/san moritz/ig; $eng =~ s/\bshite\b/barry white/ig; $eng =~ s/\bshitter/gary glitter/ig; $eng =~ s/\bshocker/barry crocker/ig; $eng =~ s/\bshoes/rhythm and blues/ig; $eng =~ s/\bshoulder/spark and smoulder/ig; $eng =~ s/\bshout/brussel sprout/ig; $eng =~ s/\bshovel/lord lovel/ig; $eng =~ s/\bshower/eiffel tower/ig; $eng =~ s/\bsick/tom dick/ig; $eng =~ s/\bsimple/dolly dimple/ig; $eng =~ s/\bsister/skin and blister/ig; $eng =~ s/\bskint/borassic lint/ig; $eng =~ s/\bslash/charlie nash/ig; $eng =~ s/\bslaughtered/son and daughtered/ig; $eng =~ s/\bsleep/bo peep/ig; $eng =~ s/\bsmile/carpet pile/ig; $eng =~ s/\bsnake/joe blake/ig; $eng =~ s/\bsoap/band of hope/ig; $eng =~ s/\bsocks/almond rocks/ig; $eng =~ s/\bsun/currant bun/ig; $eng =~ s/\bsores/dudley moores/ig; $eng =~ s/\bsoup/loop the loop/ig; $eng =~ s/\bspanner/elsie tanner/ig; $eng =~ s/\bspine/lager and lime/ig; $eng =~ s/\bspuds/roy hudds/ig; $eng =~ s/\bspunk/harry monk/ig; $eng =~ s/\bstains/michael caines/ig; $eng =~ s/\bstairs/apple and pears/ig; $eng =~ s/\bstarving/hank marvin/ig; $eng =~ s/\bstate/two and eight/ig; $eng =~ s/\bsteak/kate/ig; $eng =~ s/\bstench/dame judy dench/ig; $eng =~ s/\bstink\b/pen and ink/ig; $eng =~ s/\bstinking/abraham lincoln/ig; $eng =~ s/\bstory/jackanory/ig; $eng =~ s/\bstrangers/queen's park rangers/ig; $eng =~ s/\bstrides/jeckyll and hyde's/ig; $eng =~ s/\bstrong/ping pong/ig; $eng =~ s/\b(?!p)sub/rubber dub/ig; # thanks to xaco for spotting thi +s $eng =~ s/\bsuit/whistle and flute/ig; $eng =~ s/\bsupper/tommy tucker/ig; $eng =~ s/\bsure/bobby/ig; $eng =~ s/\bsuspenders/no surrenders/ig; $eng =~ s/\btable\b/cain and abel/ig; $eng =~ s/\btablets/gary abblets/ig; $eng =~ s/\btan/charlie chan/ig; $eng =~ s/\btart/treacle/ig; $eng =~ s/\btax\b/candle wax/ig; $eng =~ s/\btaxi/joe baxi/ig; $eng =~ s/\btea/rosie lee/ig; $eng =~ s/\bteeth/hampstead heath/ig; $eng =~ s/\btelly/liza minelli/ig; $eng =~ s/\btenner/ayrton senna/ig; $eng =~ s/\bthank you/sandshoe/ig; $eng =~ s/\bthief/tea-leaf/ig; $eng =~ s/\bthirst/geoff hurst/ig; $eng =~ s/\bticket/wilson picket/ig; $eng =~ s/\btie/peckham rye/ig; $eng =~ s/\btime/bird/ig; $eng =~ s/\btits/thru'penny bits/ig; $eng =~ s/\btoast\b/holy ghost/ig; $eng =~ s/\btoaster/roller coaster/ig; $eng =~ s/\btoe/sebastian coe/ig; $eng =~ s/\btomato sauce/dead horse/ig; $eng =~ s/\btongue/brigham young/ig; $eng =~ s/\btools/crown jewels/ig; $eng =~ s/\btow\b/edgar allen poe/ig; $eng =~ s/\btowel/pete powell/ig; $eng =~ s/\btrain\b/john wayne/ig; $eng =~ s/\btrainers/claire raynors/ig; $eng =~ s/\btramp/paraffin lamp/ig; $eng =~ s/\btrouble/barney rubble/ig; $eng =~ s/\btrousers/round the houses/ig; $eng =~ s/\btrunks/chipmunks/ig; $eng =~ s/\btube/oxo cube/ig; $eng =~ s/\bturd/richard the third/ig; $eng =~ s/\bturkey/pinky and perky/ig; $eng =~ s/\bumbrella/auntie ella/ig; $eng =~ s/\bundies/reg grundies/ig; $eng =~ s/\bveg\b/uncle reg/ig; $eng =~ s/\bveggie/ronnie and reggie/ig; $eng =~ s/\bvicar/pie and liquor/ig; $eng =~ s/\bvomit/wallice and gromit/ig; $eng =~ s/\bwager/john major/ig; $eng =~ s/\bwages/cat and cages/ig; $eng =~ s/\bwalk/ball of chalk/ig; $eng =~ s/\bwank\b/j. arthur rank/ig; $eng =~ s/\bwanker/merchant banker/ig; $eng =~ s/\bwash/bob squash/ig; $eng =~ s/\bwatch/kettle/ig; $eng =~ s/\bwater/fisherman's daughter/ig; $eng =~ s/\bwebsite/wind and kite/ig; $eng =~ s/\bweed/harris tweed/ig; $eng =~ s/\bwench/monkey wrench/ig; $eng =~ s/\bwhore/roger moore/ig; $eng =~ s/\bwife/trouble and strife/ig; $eng =~ s/\bwig/syrup fig/ig; $eng =~ s/\bwindow/burnt cinder/ig; $eng =~ s/\bwindshield wiper/billie piper/ig; $eng =~ s/\bwindy/mork and mindy/ig; $eng =~ s/\bword/dicky bird/ig; $eng =~ s/\bworries/fred mcmurrays/ig; $eng =~ s/\bwrong/pete tong/ig; $eng =~ s/\byank/sherman tank/ig; print "\nYour sentence has been translated to Cockney Rhyming Slang : +'Ave A Nice Day Nah Won'tcha\n"; print "\n$eng\n"; # CSRC Copyright @2001 azatoth
UPDATED : as per tye's comments below. Thanks man.

Replies are listed 'Best First'.
(tye)Re: CRSC
by tye (Sage) on Feb 02, 2001 at 22:07 UTC
    $eng =~ s/you/ya/ig; $eng =~ s/aren't you/int'cha/ig;

    Note that the second line above will never do anything since "aren't you" will become "aren't ya" before the line is executed. Similarly, "army" will never be changed as it will become "arme" before the relavent regex gets run.

    That first error jumped out at me but looking closer it looks like you've accounted for most of those types of errors. Just a few minor bugs still left (ain't that always true). (:

            - tye (but my friends call me "Tye")
      Doesn't seem that much of a problem to me, couldn't you just switch the relevant regexen around? (Same applies to the "Pub - Nuclear sub" issue further down) Brother Ade
by daniell (Sexton) on Feb 09, 2001 at 00:43 UTC
    It's not a bad idea; but wouldn't it be better to:
    • Setup a hash with the input words to the output rhymes.
    • Split the input on breaks
    • lowercase it, and look it up in the hash?
    At least, that'd make editing the table, and working with a big table, simpler.

      I like this idea, but it has the major drawback that a hash dosen't preserve order, and in this case the order of application of those REs is important.

      I don't know of any elegant solution to this (I'm using mostly the same method when creating multi-page CGI scripts), so the thing I'm using is a hash of page handlers and an array as the sequence of pages (yes, it's the dreaded wizard-style interface). Pages (== hash keys) that are not found in the sequence array are then either flagged as an error (more stability) or silently appended to the end of the wizard (quick'n'dirty development).

      A sample :
      my @pageorder = ( "welcome", "address", "recipients", "preview", "done +" ); # Routines to create the pages my %pages = ( "welcome" => \&page_welcome, "address" => \&page_address, "recipients" => \&page_recipients, "preview" => \&page_preview, "done" => \&page_done, ); # Routines to validate user input for every page my %validators = ( "welcome" => undef, "address" => \&validate_address, "recipients" => \&validate_recipients, "preview" => undef, "done" => undef, );

      And the page handler works like this :

      # First, determine where we are, using a default of "welcome" on error + : my $page; if ($cgi->param("go_prev") and $cgi->param("prevpage")) { $page = $cgi->param("prevpage"); } else { $page = $cgi->param("nextpage"); }; if (! exists $pages{$page}) { $page = "welcome"; }; # Parameter validation ommitted, as it's simply a walk of the validati +on chain for every page ... # Execute the special code for this page, so all this searching had so +me sense : &{$pages{$page}};

        You could always use Tie::IxHash for this. You can also cheat and do what I find myself doing sometimes:

        my @pages = ( welcome => \&page_welcome, address => \&page_address, recipients => \&page_recipients, preview => \&page_preview, done => \&page_done, ); my %pages= @pages; @pages= do { my $key= 0; grep { $key= !$key } @pages };
        Since you have two hashes with shared keys, you might go a different route like:
        my( @pageorder, %pages, %validators ); for( ["welcome", \&page_welcome, undef], ["address", \&page_address, \&validate_address], ["recipients", \&page_recipients, \&validate_recipients], ["preview", \&page_preview, undef], ["done", \&page_done, undef], ) { push @pageorder, $_->[0]; $pages{$_->[0]}= $_->[1]; $validators{$_->[0]}= $_->[2]; }
        or perhaps:
        use mapcar; my( @pageorder, %pages, %validators ); BEGIN { my( $key, $page, $valid )= mapcar {[@_]} ["welcome", \&page_welcome, undef], ["address", \&page_address, \&validate_address], ["recipients", \&page_recipients, \&validate_recipients], ["preview", \&page_preview, undef], ["done", \&page_done, undef]; @pageorder= @$keys; @pages{@$keys}= @$page; @validators{@$keys}= @$valid; }
        Season to taste.

                - tye (but my friends call me "Tye")
by a (Friar) on Feb 03, 2001 at 10:44 UTC
    "fiver" => "lady godiva"???? Maybe you want ta' ha'f da' accent mangling happen after the rhyming munge? "lost it" => "kate mossed it"??? Yeesh, what have the Brits come to? ;->


by boo_radley (Parson) on Feb 06, 2001 at 20:46 UTC
    OK, this bit
    $eng =~ s/oro/oro/ig; # this has to be here atm
    has me puzzled. What gives?
      Aah, just ++ it and "shut yer face".

      Erm, the reason why that is in there is thus :

      I can't remember what it was, but there was a word with "oro" in it, but it didn't sound right becoming "awo".

      All right, all right, i'll fix it. Gimme a sec :) Thanks man

      <font color="#0000ff"<Azatoth a.k.a Captain Whiplash

      Get YOUR PerlMonks Stagename here!
      Want to speak like a Londoner?
by xaco (Initiate) on Feb 08, 2001 at 22:24 UTC
    It would be nice to have a -n or -p version of this that
    could be piped into similar to the Bork program that
    sometimes comes with various unices. Then you could
    cat files into it and have them translated rather than
    having to type them in one line at a time.

    Also, there's a bug for the word pub, which is translated to
    nuclear sub. The sub is then translated to rubber dub
    below, so pub becomes nuclear rubber dub.


      I don't think the "fix" used will work. The line is now:

      $eng =~ s/\b(?!p)sub/rubber dub/ig;  # thanks to xaco for spotting this

      This looks to me like "replace word/non-word boundary followed by something which is 's' and not 'p' followed by 'u' followed by 'b' by 'rubber dub'". This will still replace 'nuclear sub' with 'nuclear rubber dub'. The (?!p) is superfluous because the next character can never be a 'p' anyway, since you say it must match /s/i.

      Easiest is probably just to switch the order of the rules, since you can't say "replace the word 'sub' except it if used to be the word 'pub'" :)

by jepri (Parson) on Feb 06, 2001 at 07:36 UTC
    $eng =~ s/\bout of order/alan border/ig;

    $eng =~ s/\bout of order/Shane Warne/ig;


    I didn't believe in evil until I dated it.

by rfb (Sexton) on Feb 09, 2001 at 05:16 UTC
    applied this to the new generating script on our local development server, .. hehe, thanks for making my day a little more interesting.. -rfb
by grinder (Bishop) on Feb 27, 2001 at 20:22 UTC
    A little hacking to make it loop on STDIN and a sub crsc {...} and we get stuff like


    Netstat displays infawmation of the Linux netwawking rubber dubˇ system.
    (no option)
    ya can view the status of netwawk connections by listing the open sockets. This is the default operation: If ya don't specify any address families, then the active sockˇ ets of awl configured address families will be printed. Wiv -e ya get some additionaw infawmations (userid). Wiv the -v switch ya can make netstat complain abaht knahn address families which are not suppawted by the kerˇ nel. The -o option displays some additionaw infawmation on netwawking birdrs. Enabling the -p will shah ya the proˇ cess PID and name of the program 'olding the socket. -a print awl sockets, including the listening server sockets. The address family inet will display bale of straw, udp and tcp sockets.
by Cobblers (Novice) on May 11, 2001 at 21:27 UTC

    Great program -- I have one nitpicky change...

    $eng =~ s/\bballs/cobblers/ig;


    $eng =~ s/\bballs/cobblers' awls/ig;

    But only if you want to keep track of where it came from ;-) Did I mention that this was a great program? I enjoyed it immensely.

by feloniousMonk (Pilgrim) on Jun 14, 2001 at 20:11 UTC
    You've forgotten elephant n' castle, which means,
    um, well, /msg me and I'll tell you if you don't know