Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Challenge from my Fridge

by Snowman (Acolyte)
on Mar 10, 2003 at 16:08 UTC ( #241753=perlquestion: print w/replies, xml ) Need Help??

Snowman has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

My fridge door is littered with perl... and my friends, who are decidly non-perl users came up with the phrase...

chomp the flock

They subsequently challanged me to actually have the line of code in a perl script... So I thought I'd throw this out to the greater perl masses for consideration.

Successful completion of this challange will raise 10 of my English pounds for Charity...

--
The Snowman
snowman@notreally.co.uk

update (broquaint): $title =~ s{^Challange}{Challenge}

Replies are listed 'Best First'.
Re: Challenge from my Fridge
by xmath (Hermit) on Mar 10, 2003 at 16:20 UTC
    sub the : lvalue { my $var = "Foo" } chomp the flock ( Code, "4 Snowman" )

    I initially started out with the attempt to also make it poetry but I gave up on that.. I'm not much of a poet :-)

    (It doesn't do anything useful.. that's not a problem is it?)

      Ah... It was the 'the' that I was finding hard. Why it's in the perl fridge magentic I'm not sure, I suppose I could overload all the functions and have it do what ever I liked....

      --
      The Snowman
      snowman@notreally.co.uk

Re: Challenge from my Fridge
by robartes (Priest) on Mar 10, 2003 at 16:50 UTC
    Or, if you want it on a line by itself, override flock():
    #!/usr/local/bin/perl -w use strict; use subs qw(flock); sub the : lvalue {my $v="A flock"}; sub flock () {'of sheep'}; chomp the flock;
    It compiles. Not to anything useful, but it compiles. It even runs. A bit like a flock of sheep, actually ;)

    CU
    Robartes-

      Ok, so once again I find myself killing a few minutes working with someone else's code. *Smiles*

      I went ahead and overrode chomp to make it chomp the flock.

      #!/usr/bin/perl -w use strict; use subs qw(chomp flock); my @gFlock=(1..10); sub chomp { pop @gFlock; } sub the { 'My flock is: ',shift,"\n"; } sub flock { join(' ',@gFlock); } while (flock) { print the flock; chomp the flock; }
Re: Challenge from my Fridge
by DarknessX (Scribe) on Mar 11, 2003 at 03:43 UTC
    After asking around in the chatterbox, we decided there was no easy way to do this, but I decided to post anyway.. good poetry doesn't have to make sense, so in a twisted sort of way, perl doesn't have to compile.. I think. Plus, your friends challenged you to have it in a perl script, there's nothing about it working. With that in mind, here goes:
    #!/usr/bin/perl -w use strict; use constant flock => "goose "x50; sub the { my $geese=flock; return $geese; } chomp the flock; #there's the problem: chomp is operating on flock, n +ot on the returned value of the()

    any ideas, suggestions, comments, at all, are desired.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://241753]
Approved by Tomte
Front-paged by Aristotle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2019-11-19 00:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (93 votes). Check out past polls.

    Notices?