Perl vs. perl

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

this is for T. do you know the difference between Perl (the language)
and perl (the program)? let's hear you explain the difference.


Re: Perl vs. perl

On 08/13/2015 08:07 PM, Uri Guttman wrote:
Quoted text here. Click to load it

Hi Uri,

Homework!  Homework!  Why!  Why!  Why!   K-I-D-S T-H-E-S-E

Wait!  This is a test!

Test!  Test!  I didn't know there was going to be a test!
I over slept!  My dog ate my paper!  I went to Publik skool!

Okay, I am up to this.  I will take a whack at this.  The
only letter that is different is the "p" and the "P".

     p=80= 0x50=0101 0000
     P=112=0x70=0111 0000

So the only difference is one bit.

What?  Heard that joke before?  Don't like the
quality of my jokes?  Remember what you paid
to read it!

What?  You want a better answer?  Okay, try this one:


use strict;
use warnings;
use diagnostics;

use constant tab => chr ("9");

my @homework = qx ( perldoc perlfaq1 | col -b );
my $eof=scalar @homework;
my $line=0;
my $start=(-100);
my @answer;
my $AnswerLine = 0;

if ( index ( $^O, "linux" ) == (-1) ) {
     die "This bit of tomfoolery only works in Linux\n",
           "Cowardly exiting.  Bummer Dude!\n\n";

until ($line == $eof ) {
    if ( index ( $homework[$line], "the difference between") > 0) {  
$start = $line };

    # if ( $start > 0) { print $homework[ $line ] };
    if ( $start > 0) {
       $FixMe = "$homework[ $line ]";
       $FixMe =~ s{ }g;
       $answer [ $AnswerLine ] = "$FixMe";
       $AnswerLine += 1;

    $line +=1;
    if ($line == $start +5)

print "\nI am gratified to be able to answer promptly.  The answer is:\n\n";
print "@answer";
print "\n";


How'd I do?  Do I get a gold star?

--Mr. T

Re: Perl vs. perl

On 08/14/2015 09:12 PM, T wrote:
Quoted text here. Click to load it

For those of you not willing to run the script to
read the tomfoolery, this is the output:


I am gratified to be able to answer promptly.  The answer is:

    What’s the difference between "perl" and "Perl"?
         One bit.  Oh, you weren’t talking ASCII? :-) Larry now uses  
"Perl" to
         signify the language proper and "perl" the implementation of  
it, i.e.
         the current interpreter.  Hence Tom’s quip that "Nothing but  
perl can
         parse Perl."

--Mr. T

I think a gold start is in order, don't you?  :-)

Re: Perl vs. perl

Quoted text here. Click to load it

use strict; use warnings;

map { s/^\s*//, print $_ if /difference between/ ... /^\s*$/ }  
qx/perldoc perlfaq1/

Re: Perl vs. perl

On Saturday, 15 August 2015 09:42:45 UTC+5:30, T  wrote:
Quoted text here. Click to load it

Note that the main part is very small, the while-loop+qx<> setup.
Rest is just boilerplate & sort of parameter configuration setup.
You should notice that there is an aversion to using array indices;
this makes for a simpler looking code and more in the Perl spirit.

N.B.: I don't particularly relish the use of named constants using the module due in fact to the awkward syntax they engender
when the time comes to use them in expressions. But since you are hard
to sway in using Readonly, or for that matter, anything, I made use of
the ;-)


use strict;
use warnings;
use diagnostics qw( -verbose );

use constant EMPTY_STRING =>     q{};
use constant NL           =>  qq;
use constant TAB          =>  qq;
use constant SPC          =>    q{ };

use constant NOMATCH      =>   -1;

use constant OS_GOLDEN    =>  lc q;

use constant COLOR_CODE   =>  qr;
use constant EMPTY_LINE   =>  qr{^ \s* $}x;
use constant FAQ_HEADING  =>  qr{\s the \s+ difference \s+ between \s}x;

use constant ERR_MSG      => join($, (
   qq{This bit of tomfoolery only works in $.\n},
   qq{Cowardly exiting.  Bummer Dude!\n\n},

die $
   if index( lc($^O), OS_GOLDEN ) == NOMATCH;

chomp( my @homework_FAQs = qx< perldoc perlfaq1 > );

local $\ = NL; # auto-print newlines

while ( defined(local $_ = shift @homework_FAQs) ) {
   next LINE unless /$/x .. /$/x;

    [$]g;            # change all TABs to spaces

    [$]g;   # remove all color coding characters


system(qq<perldoc $0>);

=head1 One-liner version:
The one-liner command below performs similary
as the perl program you just ran.

=head2 perl -e '

    print for
      grep /\sthe\s+difference\s+between/ .. /^\s*$/,
        qx(perldoc perlfaq1);



Site Timeline