Chat about Perl fun

__ OFF TOPIC __

Learned something and that is always priceless :grinning:

In Perl you can pass an argument to a function in the call without specifying this in the declaration of this function. Something unthinkable in c(pp), the language I kind of need to deal with.

void set_led_state(enum LedState new_state)
{
    do stuff
}

Note the enum just to be sure to be type save…

enum LedState
{
    LedInit,
    LedForceOff,
    LedOff,
    LedOn,
    LedBright,
    LedToggle01,
    LedToggle23,
    LedToggle45
};

In a future chat going to ask if the argument is passed by reference in perl :thinking:

Perl is the most beautiful language of the earth, Larry has built the universe

2 Likes

@stephdl
@mark_nl

Perl is one of the first languages which had “lazy programming”, even as a compiler one of the fastest when it comes to ripping strings apart and allocating the segments to a Variable “On the fly”.
Perl is also one of the most powerful languages due to that fact - anything to do with databases can be reduced to string handling - and Perl does that best!

Regexps? See string handling above!

No declaring variables, just use one, it’s there. Such stuff is cool, when you know what you’re doing! And there’s lots more…

And I do not consider myself a coder! But Perl is truly the swiss army knife in coding. It can do anything, and quite fast!

Also good to know: Perl can be compiled!

Updating your code base with your codebase? Unthinkable in very many languages. Perl has CPAN! (Yes it can do it!).

And - Larry Wall dreams this stuff! :slight_smile:

My 2 cents
Andy

1 Like

variables :question: Do you mean Scalars, Arrays or Hashes…

Just kidding, although one of the aspects understanding PERL is hard for me :hushed:
It has those wicked names/definitions which can confuse me.

1 Like

That’s all part of what makes it so powerful, especially when handling strings…
Like taking a live stock ticker flow, and feeding the key data into an array - so simple and straightforward… :slight_smile:

1 Like

one best things for me about perl is $_

my @array = ('a','b','c');
foreach (@array) {
    print $_;
}

a good shorter

1 Like

@mark_nl

Ever tried using CPAN? Almost like “yum” or “apt” built in a programming language… :slight_smile:

No, will do so…

my… the array only lives in the current scope.
does that mean it cannot be passed to a function?
If this is possible is it by reference or is it a copy of the array ?
If it is by reference why use my ?

That is some he stuff hard to understand :woozy_face:

1 Like

scope of a vars…that’s always give me some headache :smiley:

do not ever forget to print the values of vars when you debug; you can see in logs or in the CLI

aways use my because you have to use in perl script

use strict;
use warnings;
1 Like

@mark_nl

Some simple examples:

Updating PERL - from inside PERL!

perl -MCPAN -eshell
**(Lots of things happen here - just accept the defaults unless you know differntly!!)
cpan> install Bundle::CPAN
cpan> reload cpan

or stuff like this:

cpan> install MD5
cpan> install Storable
cpan> install DBI

Around 2000 SSL wasn’t yet in broad usage, yet I needed it for systems management. The ssleay library, used in perl for SSL stuff, wasn’t included in a lot of Linux distros. Either look around for a RPM (Dag Wiers), or compile it yourself directly from CPAN - using perl! :slight_smile:

Really powerful stuff!

My 2 cents
Andy

Yes it is :slight_smile: not bashing PERL it is a beautiful powerful programming langue.
Just hard to read and understand by me . :blush:

@mark_nl
@stephdl

You’ve obiviosly never seen the “obscure perl coding contests” around 2000 :slight_smile:
See eg here:

I love Perl because you can be a one liner developer

Just because you can :smiley:

I recall the first time I opened some files in SME Server, it was like an orgy…2000 lines