[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


Is Perl still used in DevOps? Should I learn it?
>>
>>109571375
>Is Perl still used
no
>>
>>109571375
it's not used
it was killed by a mix of eternal september + mod_php + ppl moving to Linux
for Web it was killed by mod_php
for administration tasks it was killed by lots of admins moving to Linux starting early 2000s. remember itss first commit was 'a replacement for sed and awk'. bash itself got built-in support for extended posix regex since v3. arrays since v4. so you can read a program in memory, parse it, map it to an array just like you would in any other language
for a devops career you need bash and python. python because unfortunately we're currently living in a beginner-intermediate situation
>>
>>109571375
i think it's neat that perl is ubiquitous across unix and unix-like operating systems by default. that said i wouldn't spend too much time learning it; bash is sufficient most of the time.
>>
>>109571375
When was Perl used in Devops?
>>
>>109571375
no and no
>>109571670
sysadmins used it in the 90s and early 2000s
>>
Is Perl actually that bad? I've heard random anecdotes over the years about someone having a nightmare of a time replacing some ancient Perl script
>>
>>109571716
it's not too bad, but the sigils are a weird. @ is for arrays and $ is for scalars for example;
my @names = ['alice', 'bob', 'charlie'];
my $first_name = $names[0];
my $first_name2 = shift @names;


then you also have references, which is like a pointer. Since that's only one value (the address), the reference to an array is a scalar
my $name_ref = \@names;

then if you want the first name off that referenced array, you have to use the arrow to dereference
my $first_name_from_ref = $names_ref->[0]


in practice, everyone uses references for everything and you get used to it, just a bit confusing at first

I guess the other thing is some special variables like $_. For example if you're doing a foreach loop you don't even have to say what you want your looping variable to be, you can just say foreach ( @numbers ) { .. } and refer to $_ inside - it's automatic.
>>
>>109571849
If I still remember this shit well, you can also use
my $anon_array = [ 'one', 'two', 'three' ];


or my favorite feature, the quotes

my $arr = [ qw( one two three ) ]
>>
>>109571375
I saw one job ad that used it in what, 5 years? Old scripts. Replaced - I would say - by Python, but I won't gainsay anyone else in the thread. I'd rather do serious scripting in Perl than bash, but, Perl won't get you a job.

Interestingly to me, I had a problem at work and at first I tried to do it with awk, then with Python, and finally fell back onto Perl - easy, close integration with the shell is what made the difference with more 'programmability' than awk. But that was in 2010.
>>
>>109571375
I pirated ActiveState Perl back in the late 2010s just to print “Hello, World!”
>>
>>109571716
it is, the design of perl is really bad
it's as if the author of perl never studied computer science
I'm glad it died
>>
>>109571849
>it's not too bad, but the sigils are a weird. @ is for arrays and $ is for scalars for example;
they're not that weird. @ means those/those. $ means, $ means the/a.

>I guess the other thing is some special variables like $_.
yeah. $_ means "it".

that's pretty awesome and akin to holding a conversation with the language.
>>
>>109572553
>>109572140
Larry Wall was a linguist.
>>
>>109571849
> $sigils are weird
Basic & visual basic had them. Not weird at all.
>>
>>109571949
oh yeah, actually I fucked up.
my @names = ['alice', 'bob', 'charlie']; ### <-- WRONG

actually you need
my @names = ('alice', 'bob', 'charlie');
my $names_ref = ['alice', 'bob', 'charlie'];
print $names[0];
print $names_ref->[0];

>>109573164
What I found weird is that the way the sigil can change when using the same variable. So you have @names the array but to access the first element you use $names[0];
>>
>>109571459
I’ve been using perl for many years, it’s true that I don’t use it much anymore… if at all.
It remains among the most productive languages to get shit done, however, so I still use it to hack/parse data files from time to time.
PHP is in a worse position… it was a less-well-designed version of Perl and even the creator of PHP shits on it. If PHP is on your resume, remove that embarrassment.
For production work I now always use the simplest tool that achieves the goal.
First bourne shell, then sed, maybe awk for a larger program.
Never bash. No experienced unix weenie would write something in bash. I worked with this one retard that took random bashisms from the internet and littered his scripts with them. Moved them to production where they promptly failed to run, so he convinced IT to swich the main shell to bash by copying over the sh binary (which was dash on linux systems). Anyway, that was the end of our company (we were under one big contract).
Perl6/Raku probably the most productive language of them all, but it suffers from a bit of a learning curve and it has abysmal performance. But, if you want to get shit done, that’s the one.
>>
File: magic.png (14 KB, 363x287)
14 KB PNG
>>109571849
>>109573194

Perl is free magical and we shouldn't be strict.
Maybe it was the preferences of the writer?
>>
>>109573620
I was referring to using [ ] vs ( ). With @example it has to be ( ) and with $example_ref it has to be [ ]. @example with [ ] will not get you want you want
>>
>>109573620
oh, I see what you're saying now. I was probably thinking of an old-school thing that was later fixed, if I had to guess.. sorry for the spam
>>
>>109571375
Most devopses I've met in recent years have surface level linux skills. They don't even know bash nor linux that well. They are just yaml janitors for kubernetes. Perl is OG tinkerer language, these people are not that type. They went there for money, not because they genuinely love scripting and doing thing with linux. Perl was replaced consecutively by other languages and tools, from python (because of skill issue) to ansible/puppet/chef, to docker and finally to kubernetes. What used to be scripts became manifests. It's not the same type of job, they don't script anymore, they just write glorified config files.

>>109573194
it's just that perl is like natural language. The sigil changes context of the variable. It's like using cases in language to get a particular function/usage. What might look weird at first makes perfect sense. You might think you put a sigil to the variable, but you actually describe the intent, not the type. If you use $arr[index] you get a scalar, when you use @arr[index] you get a slice of a list of one element. Also if used with assignment, the assignment itself dictates the intent so:

my @list = ('a', 'b', 'c');

my $foo_s = $list[0]; // RHS scalar (first element) to LHS scalar
my $bar_s = @list[0]; // RHS list (slice of 1st element) to LHS scalar
my $baz_s = @list; // RHS list to LHS scalar (length of list), can be used for conditional if list is non-empty
my $quux_s = @list[0, 1]; // RHS list (slice of more element) to LHS scalar (length of slice)

my @foo_l = $list[0]; // RHS scalar to LHS list (list of first element)
my @bar_l = @list[0]; // RHS list (slice of first element) to LHS list (copy slice)
my @baz = @list; // RHS list to LHS list (copy list)
>>
>>109573638
>>109573649
Well I guess wasn't reading either.

You are not wrong, in perl you can't freely interchange arrays and references.
So () and [] will not give you the same behavior
>>
>>109571375
i wrote a CGI script in perl recently because python was too slow
Its very nice, I like that nested lists are automatically flattened and that most functions are variadic so you can just spew all your data into a function and it will automatically spew it all back.
I dont like references it gets too confusing tracking whats a reference to a list or what is an actual list.
They should have their own sigil everywhere and not be shoved into scalars
I actually prefer perl over python because theres almost no boilerplate and it feels "smarter" and more put together than pythons "lets glue a thousands things together"
But I wouldnt want to write a large program in it.
>>
>>109573710
> They are just yaml janitors for kubernetes
That’s funny.
Kubernetes is *native* JSON and every yaml file is converted to json by a yaml-> json converter internally.
The originators of Kubernetes knew about the problem: it was a hit-and-run single check-in by a one-time contributor yaml zealot when they weren't paying attention.
>>
>>109571375
>Is Perl still used in DevOps?
No
>Should I learn it?
No. Learn python instead.
>>
>>109571375
>Is Perl still used in DevOps?
No
>Should I learn it?
Only if you really want to for yourself.
The Perl 5->6 change was really badly fumbled; they produced a pile of confusing dreck, didn't bring any of their community along, split dev effort awfully, and didn't fix any of the actual problems with the language. I guess they could have gotten away with it if they made things much faster, but they didn't, at least for most code.
Python's a truly terrible language, but it's a better choice for DevOps in this day and age, and is quite a bit easier to write secure code in. It's also usually a lot easier to read someone else's Python code than someone else's Perl code.
>>
>>109574879
> Perl5->6 disaster.
At least they were smart enough to eventually split the whole thing off.

The Python 2 -> 3 was a bigger disaster
Van rossum himself worked at dropbox and in his entire tenure there he never used Python 3 since they were so locked into 2. Literal IRL satire.
No wonder he quit his own language. To his credit, at least he knew when to throw in the towel. Now maintained by hyper-religious python zealots.

Even more credit to the guy that invented groovy.
He quit before it was released!
>>
>>109574879
> better choice for DevOps in this day and age
Lol, no. We have .. and need .. 6 (six) versions of python on one linux box to keep our build flow shit running (controlling windows VMs). Nobody even wants to look at it or touch it because they’ll be nominated the “resident expert” and subsequently blamed for this steaming pile.
>>
what useful perl programs remain?
parallel, exiftool, anything else?
>>
>>109571375
Learn it to make HexChat addons.
>>
File: 1760414978157.png (320 KB, 925x508)
320 KB PNG
>>109571375
as python alternative
>>
>>109571375
The good thing about it is that it's available nearly everywhere. Maybe not in the most minimal docker image but otherwise, yeah.
For scripts, it's way better than bash. Has things like awk, sed and grep practically built in.

The syntax is fucking arcane, though. If you got the choice, you'd rather use Python 3. But if that's not available, Perl is at least better than Bash.
>>
>>109576965
>>
>>109575292
>he never used Python 3 since they were so locked into 2
How does this even happen? You would have to write god awful Python code to be stuck to Python 2.
>>
>>109575357
Tons of helper utilities in Linux are still written in Perl. Try running this:
grep -m1 -s 'bin/perl' /usr/bin/* /usr/sbin/*
>>
>>109579535
ah yeah, I somehow missed autotools. fucking hate that thing though.
other scripts don't seem very notable.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.