|
Azhais posted:I'm too old to learn new syntax. Perl5 for life! I'll learn Perl 6 when there are Perl 6 jobs out there. So, probably never.
|
# ? Jan 13, 2016 01:52 |
|
|
# ? May 2, 2024 06:19 |
|
Any recommend tutorials or starting points for learning Object Oriented programming in Perl 5? Im starting from scratch, no prior OO knowledge. Just wanting to learn for hobby projects.
|
# ? Feb 4, 2016 21:00 |
|
This chapter explains bare-bones OO in Perl: http://web.archive.org/web/20120717215030/http://ofps.oreilly.com/titles/9781118013847/object_oriented_perl.html No need to really learn that, since much of it you won't be using anyhow. Good to know and skim though. The next chapter explains OO how it is used in production, with wrappers creating very efficient DSLs around the basic OO bits of Perl: http://web.archive.org/web/20120718083717/http://ofps.oreilly.com/titles/9781118013847/moose.html Note however that 99% of the time, you won't actually want to use Moose (which comes with a heavy startup time penalty), and instead use Moo, which is 99% compatible from the outside (it doesn't have ->meta, and thus is MUCH lighter on the inside). If you'd like something shorter, Modern Perl explains OO as well, and is reliable, though the notes from above apply as well: http://modernperlbooks.com/books/modern_perl_2016/07-object-oriented-perl.html#T2JqZWN0cw Additionally, you'll want to read the Moo docs as a sort of crash course to modern Perl OO: https://metacpan.org/pod/Moo And if you yearn for details, much of the Moose manual applies to Moo as well, but is a lot more verbose: https://metacpan.org/pod/Moose#New-to-Moose Edit, also, i forgot this excellent talk about Moo/se style OO which will help a lot in grasping the concepts behind it: https://rjbs.manxome.org/talks/moose/Moose.pdf Mithaldu fucked around with this message at 08:07 on Feb 5, 2016 |
# ? Feb 5, 2016 01:31 |
|
Mithaldu posted:This chapter explains bare-bones OO in Perl: Thanks for this. I asked this question in #perl IRC, and seemingly opened up a huge can of worms. Ended up being told to go learn OO in small talk or ruby. Hughmoris fucked around with this message at 02:47 on Feb 5, 2016 |
# ? Feb 5, 2016 02:41 |
|
Hughmoris posted:Thanks for this. Those are good suggestions if you're married to perl for whatever reason, but you might look elsewhere if you're looking for more general learning.
|
# ? Feb 5, 2016 02:59 |
|
Hughmoris posted:Thanks for this. They're also both not very aware of the actual state of Perl tutorials and teaching resources about OO, or they would've told you to go read these following slides i forgot to link in my earlier post. (They will help a lot in grasping the concepts behind Moo/se style OO.) https://rjbs.manxome.org/talks/moose/Moose.pdf Extortionist posted:Really if your goal is learning OO programming, you might be better off with another language. OO support is pretty hacked in in perl (see the recommendations above requiring the use of non-core libraries) and might not translate well to general OO practices across other languages. - for some insane reason you cannot use cpan; - to either learn it in an decidedly un-C-like language (i.e. to widen horizons forcibly); - to save yourself the frustration that's inevitable when you switch from Perl to another language and find that most other languages implement less OO features than Perl does (like a complete implementation of Roles or constructor/accessor DSL) (particular Ruby's OO is extremely barebones compared to Perl's) There's also no reason to call it "hacked", since most other languages implement OO similar to how Moo/se does it, just inside the interpreter, not outside it. Seriously, go compare Python's implementation with Moose's. To complain about the level at which OO is implemented is roughly as pointless as drawing a hard line between "scripting" languages and "programming" languages. (If you're not sure why that is pointless, go google it please.)
|
# ? Feb 5, 2016 08:21 |
|
You may also run into Mojolicious' classes if you do any web development, but they're a much thinner layer over top of the built-in OO than something like Moose (really just a base class with a few convenience methods and a nicer syntax for inheritance).
|
# ? Feb 5, 2016 16:45 |
|
Mithaldu posted:Entirely disagree. I really think someone new to OO programming would be better off learning its paradigms in a language where its paradigms are more commonly used and are more strictly enforced.
|
# ? Feb 6, 2016 12:06 |
|
You could learn classes in Perl 6... you would start with less preconception/habits you've developed in perl while still being trivial to jump back into p5 with Moose
|
# ? Feb 6, 2016 16:31 |
|
Extortionist posted:Really my objections come from personal experience maintaining ostensibly OO-code written by people who learned OO coding exclusively with perl. You can surely learn it and learn it well with perl, but perl's ethos also lets you learn it poorly and think you're learning it well, regardless of whatever atrocities you're committing. You're reflecting on the people involved, the learning resources they chose and your own lack of knowledge on quality OO Perl learning resources; not on anything inherent to Perl. In which case, yeah, i agree. If the person learning is generally lazy, and happy to start learning from the first google hit that presents to them, it's a good recommendation to go with a language that puts them in a straight-jacket. Otherwise Perl is fine to learn OO with, especially when sticking to the links i gave. However note that your first post explained none of that, and made the false assertion of the OO support being "hacked" and OO practices not "translating well to other languages". Mithaldu fucked around with this message at 16:37 on Feb 6, 2016 |
# ? Feb 6, 2016 16:35 |
|
"OO support in Perl" is this, not Moose.
|
# ? Feb 6, 2016 17:24 |
|
qntm posted:"OO support in Perl" is this, not Moose. Even the perl core docs recommend Moo/se: http://perldoc.perl.org/perlootut.html Unless you're trying to make a different kind of point, in which case you'll have to be more verbose.
|
# ? Feb 6, 2016 17:28 |
|
gently caress the mods posted:You could learn classes in Perl 6... you would start with less preconception/habits you've developed in perl while still being trivial to jump back into p5 with Moose I've poked around Perl 6 but the small about of docs/tutorials are a little hard for me to catch on to. I learn better by seeing lots of examples, and since there is an abundance of Perl 5 OO tutorials out there, I figured I'd learn P5 and try and translate some of the knowledge to P6.
|
# ? Feb 7, 2016 03:14 |
|
Mithaldu posted:You're reflecting on the people involved, the learning resources they chose and your own lack of knowledge on quality OO Perl learning resources; not on anything inherent to Perl. In which case, yeah, i agree. If the person learning is generally lazy, and happy to start learning from the first google hit that presents to them, it's a good recommendation to go with a language that puts them in a straight-jacket. Otherwise Perl is fine to learn OO with, especially when sticking to the links i gave. Perl's flexibility is a huge handicap against learning (yes, I am arguing that the issue here is something inherent to perl). I don't think it has much to do with the laziness you imply, so much as it has to do with the difficulty of learning various concepts and perl's willingness to let you put together something that entirely contradicts best practices but also solves the problem you're trying to solve (this is probably also one of perl's biggest strengths--just not so much when it comes to learning). I deal with the consequences of this too often in my daily work to assume that someone trying to learn something blindly in such a permissive language will magically fall into best practices. Surely someone can do it if they're smart and diligent enough--but probably they'd also have an easier time of it if the language didn't fool them about what they were doing. I will stand by my assertion that perl's OO support is hacked. The core language plainly isn't designed to properly support OO, and you can easily blow apart any OO code in perl intentionally or accidentally.
|
# ? Feb 8, 2016 12:35 |
|
Extortionist posted:Thanks for assuming I'm ignorant, though. Extortionist posted:I deal with the consequences of this too often in my daily work Extortionist posted:The core language plainly isn't designed to properly support OO, and you can easily blow apart any OO code in perl intentionally or accidentally.
|
# ? Feb 8, 2016 20:53 |
|
Mithaldu posted:(in particular Ruby's OO is extremely barebones compared to Perl's) code:
Extortionist posted:Perl's flexibility is a huge handicap against learning (yes, I am arguing that the issue here is something inherent to perl). I don't think it has much to do with the laziness you imply, so much as it has to do with the difficulty of learning various concepts and perl's willingness to let you put together something that entirely contradicts best practices but also solves the problem you're trying to solve (this is probably also one of perl's biggest strengths--just not so much when it comes to learning). I deal with the consequences of this too often in my daily work to assume that someone trying to learn something blindly in such a permissive language will magically fall into best practices. Surely someone can do it if they're smart and diligent enough--but probably they'd also have an easier time of it if the language didn't fool them about what they were doing. While I've coded in perl for about 17 years, it's not a good starter language. [edit] Perl 6 [edit2] Mithaldu, are you that "true perler" guy from a few months back? Ellie Crabcakes fucked around with this message at 08:17 on Feb 23, 2016 |
# ? Feb 23, 2016 08:01 |
|
John Big Booty posted:I have a few issues with ruby, but its OO being barebones isn't one of them. Can you do this in Ruby at all? code:
- the constructor expects named arguments for the attributes - setters/getters are created automatically, with the "is" arg ( ro/rw/rwp/lazy ) determining the exact set of them created - type checks of some sort can be declared quickly and are baked into the constructor - "required" status of attributes can be declared and are baked into the constructor - "default" values can be provided in the attribute declaration and baked into the constructor - the whole thing can be bundled up and re-used as one whole thing in many other classes - the exact specification of an attribute pulled in from somewhere else can be modified in the target class How many of these points can Ruby provide? John Big Booty posted:
a) The syntax? No, you need to implement at least some of that. (Although you could possibly hack that together by attaching things to UNIVERSAL.) b) The functionality those methods do? Absolutely, i could hack you a quick example if you like. c) The functionality applied on a string? No, strings are not objects in Perl (by default, but then we go back to b). John Big Booty posted:[edit2] Mithaldu, are you that "true perler" guy from a few months back? Mithaldu fucked around with this message at 11:37 on Feb 23, 2016 |
# ? Feb 23, 2016 11:29 |
|
Mithaldu posted:Particularly attribute and constructor declaration in Ruby are barely more detailed than those in core Perl. Because perl just can't do it off of a base install. If it could, Moo and Moose and Class::C3 and all of the other bolt-ons would be totally unnecessary. Now if you're not actually a ridiculous perl bigot, I apologize, but you kinda come off as one. Especially when you say a from-the-ground-up OO language is barebones compared to perl. Do you have any experience with any actual OO language?
|
# ? Feb 24, 2016 04:30 |
|
John Big Booty posted:Now if you're not actually a ridiculous perl bigot, I apologize, but you kinda come off as one. Especially when you say a from-the-ground-up OO language is barebones compared to perl. Mithaldu posted:And yeah, i don't care if you have to call in libraries or whatever, i just want to know if, in Ruby, you can have the syntax to declare attributes in a parametrized and compartmentalized manner, meaning: So, are you going to tell me which of the things i listed in the previous post Ruby can do? John Big Booty posted:Do you have any experience with any actual OO language? Edit: I only just now realized what you meant with this: John Big Booty posted:Perhaps I should have been more specific and said "without having to import a single class or module" One way to interpret it is: "Can this be implemented without CPAN?" In which case, yes, I can, right now, implement all the functionality and syntax that code does*, without using anything off CPAN, in pure Perl. Another way to interpret it would be "Are these methods available in the perl core distribution?" Then the answer is: No, perl core encourages using one via its documentation, but for various software engineering reasons does not include one yet. Another way to interpret it would be "Are these methods available in the perl CORE namespace?" Then the answer is: No, that merely provides the minimum set of functions necessary for all of this. In general however, even asking "can i do it without CPAN?" is a valid, but merely academic question, since in real world conditions almost nobody is restricted to *only* core perl, even if they have to copy in module files manually. (I have to do this with a client whose credit card security restrictions stipulate that any code used has to be vetted manually.) * except for the "do it on a raw string" bit, since i don't know yet how pure perl autoboxing works, though i could read up on that Mithaldu fucked around with this message at 18:31 on Feb 24, 2016 |
# ? Feb 24, 2016 13:55 |
|
"Well, there's six or seven different ways to interpret your question, only one of which casts Perl in a positive light, so let's creatively assume that that's the interpretation you intended." [beat] "I'm sick of people misinterpreting me!"
|
# ? Feb 25, 2016 00:03 |
|
Except that i stated what was unclear about his question to me, and when it didn't become more clear, laid out the possible interpretations i saw, including the unfavourable ones, and answered those truthfully. Additionally his misunderstanding was about a question *i* asked and not related to his question at all. Heck, the very first interpretation i had of his question was one i answered with "no". Why are you making up poo poo?
|
# ? Feb 25, 2016 01:07 |
|
Got tired of checking manually for new posts on threads, so i automated that bit with a little script and cron: https://github.com/wchristian/SomethingAwful-FreshBookmarks/blob/master/bookmarks.pl
|
# ? Mar 2, 2016 02:52 |
|
Mithaldu posted:Got tired of checking manually for new posts on threads, so i automated that bit with a little script and cron: https://github.com/wchristian/SomethingAwful-FreshBookmarks/blob/master/bookmarks.pl Pretty cool. You have a screenshot of what the typical output looks like?
|
# ? Mar 2, 2016 19:10 |
|
Hughmoris posted:Pretty cool. You have a screenshot of what the typical output looks like? For me it looks like this, since i use cron to send it via email.
|
# ? Mar 3, 2016 02:42 |
|
I would like a perl script that does the following: - Determines what version of docker server is running, and prints out 'DOCKERV#', depending on what version it is, e.g DOCKERV1 for v1.19, DOCKERV2, for v2.92, etc. The shell command for this prints the following: $ docker version Client: Version: 1.10.3 API version: 1.22 Go version: go1.5.3 Git commit: 20f81dd Built: Thu Mar 10 15:54:52 2016 OS/Arch: linux/amd64 Server: Version: 1.10.3 API version: 1.22 Go version: go1.5.3 Git commit: 20f81dd Built: Thu Mar 10 15:54:52 2016 OS/Arch: linux/amd64 Where do I begin?
|
# ? Mar 28, 2016 21:32 |
|
BoyBlunder posted:I would like a perl script that does the following: Well, you'd start by getting that output into your perl script, so you'd start with backticks. After that, you'd want a regex to grab the first digits after "Version: " and before the decimal: code:
code:
code:
|
# ? Mar 28, 2016 23:37 |
|
Luke Johnson posted:Well, you'd start by getting that output into your perl script, so you'd start with backticks. After that, you'd want a regex to grab the first digits after "Version: " and before the decimal: I fiddle with Perl and dabble in Linux. Throwing backticks in front of DOCKER VERSION will essentially run that command in the shell (?) and return its output to the Perl script? Learn something new every day.
|
# ? Mar 29, 2016 01:09 |
|
Hughmoris posted:I fiddle with Perl and dabble in Linux. Throwing backticks in front of DOCKER VERSION will essentially run that command in the shell (?) and return its output to the Perl script? Learn something new every day. Yeah, it's handy for simple things like this when you don't want to remember how open works with commands.
|
# ? Mar 29, 2016 05:09 |
|
I'm trying to create my first tangible programming project outside of puzzles and text parsing for work. I'd like to create a module to connect to the Twitter Streaming API, since the CPAN Net::Stream seems old and defunct now (doesn't use OAUTH). It doesn't need to be anything fancy or extremely polished, just a learning exercise. Since I don't have any colleagues or friends that program, I was hoping you all might be able to guide me along to figuring this out. To start with, here's some documentation for the Twitter Streaming API: Overview: https://dev.twitter.com/streaming/overview Connecting to a streaming endpoint: https://dev.twitter.com/streaming/overview/connecting Streaming API Request parameter: https://dev.twitter.com/streaming/overview/request-parameters I already have my Twitter app setup completed with all my needed authorization tokens and keys. I'm thinking the steps needed are 1. connect to stream using OAUTH -> create a connection that stays open and constantly receives data -> parse data into something readable. Does this sound like something reasonable for someone with no real programming experience and a beginner's grasp on Perl?
|
# ? Apr 20, 2016 04:53 |
|
Seems like a good learning project. I'd recommend AnyEvent for listening to the stream.
|
# ? Apr 20, 2016 05:49 |
|
My web knowledge is even weaker than my Perl. My script uses Mechanize to log into a website and retrieve a few pages. If I don't want to have to perform a new login every time I run the script, how do I go about it? Is it a cookie that I want to save, or session information of some sort? Sort of like the 'Remember Me' option you have when you use a browser to login.
|
# ? Apr 30, 2016 19:30 |
|
Hughmoris posted:My web knowledge is even weaker than my Perl. My script uses Mechanize to log into a website and retrieve a few pages. If I don't want to have to perform a new login every time I run the script, how do I go about it? Is it a cookie that I want to save, or session information of some sort? Sort of like the 'Remember Me' option you have when you use a browser to login. Session information is stored on the server, however the cookies usually contain the id of the session which is sent to the server to tell it which data to load for you from its database. To more directly answer your question: You want to save the cookie jar. Have a look at this code: https://github.com/wchristian/SomethingAwful-FreshBookmarks/blob/master/bookmarks.pl
|
# ? Apr 30, 2016 21:44 |
|
Mithaldu posted:Session information is stored on the server, however the cookies usually contain the id of the session which is sent to the server to tell it which data to load for you from its database. To more directly answer your question: You want to save the cookie jar. Thanks, I'll give this a look.
|
# ? May 1, 2016 05:12 |
|
Anyone at YAPC::NA right now?
|
# ? Jun 20, 2016 21:33 |
|
For anyone who hasn't seen it; there are livestreams of YAPC::NA on their YouTube channel.
|
# ? Jun 21, 2016 10:22 |
|
https://www.youtube.com/watch?v=gmmVGPdcItM
|
# ? Jul 2, 2016 21:39 |
|
Is there a good way (on Windows) for a Perl script to track the utilization of a specific application? For instance, if I want to track how often/long I have the Spotify process running each day. I typically turn my desktop on in the morning and shut it off at night. I'm thinking I can have the Perl script auto launch on startup but I'm not sure how to monitor for the launch of a specific app.
|
# ? Jul 11, 2016 13:31 |
|
I don't have a Windows box, so I don't have any way of testing it out, but it looks like you may be able to achieve what you're looking for through the use of WMI with the DBD::WMI module. The Win32_ProcessStartTrace and Win32_ProcessStopTrace classes/tables are probably going to have what you're looking for. Checking for starting processes should be as easy as a query like code:
code:
|
# ? Jul 17, 2016 19:55 |
|
Beardless Woman posted:I don't have a Windows box, so I don't have any way of testing it out, but it looks like you may be able to achieve what you're looking for through the use of WMI with the DBD::WMI module. Thanks for this, I'll give it a shot!
|
# ? Jul 19, 2016 02:02 |
|
|
# ? May 2, 2024 06:19 |
|
I'm trying to iterate through an alphabetized list and edit/remove entries based on particular criteria, but as I scale up the code I want to make sure I'm being as clean as possible, since I haven't touched this stuff in a while.code:
code:
FreshFeesh fucked around with this message at 12:06 on Jul 24, 2016 |
# ? Jul 24, 2016 11:57 |