Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

The premise

Your job at has taken a turn for the worse. All of the venture capital has dried out, subscriptions are down, and the pop-up ad revenue isn't paying the bills anymore. In order to keep the lights on for one more month, your boss decides to make a testimonial page, where toons can present their happy stories of new-found love, all thanks to

After querying the database, you find you've got just 5 paying couples who met through, and you've already stored their names in a hash :
%couples = ( Fred=>"Wilma", Barney=>"Betty", George=>"Jane", Homer=>"Marge", Peter=>"Lois" );

Unfortunately, your company is so low on funding, that they can't pay for more than 80 characters of coding. Not only that, somebody's stolen your remaining supply of newlines, slashes, backslashes and semi-colons, and grabbed all but 2 doublequotes!

Your goal is to produce a small alphabetically listed snippet of text which will be passed onto an p2b end-to-end hyper-business server for use in a larger HTML file, which should hopefully attract new subscribers.

this file should look like :
Barney is married to Betty
Fred is married to Wilma
George is married to Jane
and so on, for each of the couples.

The goal

print out the couple's information as formatted above to STDOUT. Do it in one line of code, using no more than 80 characters. You have only 2 '"' (doublequotes), and you can't use the characters ';', '\' or '/'.

You can assume a shebang line properly formatted for your system,a newline, the %couples hash as specified above, and one final newline. This means that your solution should be 9 lines long. Can you save
This is a relatively easy challenge, suitable for those who are starting to get comfortable with perl. If you say "that's easy!" or have written one or more books on perl, consider skipping this node :)

The reference answer

#! perl -l %couples = ( Fred=>"Wilma", Barney=>"Betty", George=>"Jane", Homer=>"Marge", Peter=>"Lois" ); print foreach sort map {"$_ is married to $couples{$_}"} keys %couples


the 2 entries below are close, but using "\n" disqualifies them. What options in perl could take the place of a newline? (or is this a trick?)
An annoyed saint notes : "in your perl puzzle you should note that people *can* adjust command-line options.. we've been resorting to slurping `cat $0` and doing substitutions to get it to work" and 'maybe say "You can assume a shebang line of your choice, ...'

In reply to perl puzzle - cartoon couple registry (beginner, semi-golf) by boo_radley

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2023-03-26 09:10 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (63 votes). Check out past polls.