Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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:


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

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

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 ;)


      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?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2019-12-14 01:47 GMT
Find Nodes?
    Voting Booth?

    No recent polls found