|
Yeah, I get that, but:Mithaldu posted:that means don't loving disconnect, get a bouncer/shell if you don't have a useful machine is hostile and this kind of treatment is probably a large part of why Perl doesn't attract newbies.
|
# ? Jul 7, 2014 18:41 |
|
|
# ? Jun 8, 2024 01:30 |
|
Otto Skorzeny posted:It's really frustrating to both asker and answerer if a lengthy and thoughtful reply to your question gets lost because you were disconnected when someone who had the ability and time to answer got around to it. I don't recall if the bot that hangs around in the perl channels has a !tell command to get around this problem. I don't want to encourage a derail but isn't IRC for immediate answers while both people are online at the same time? Asking a question and getting an answer sometime later is for forums & message lists.
|
# ? Jul 7, 2014 19:17 |
|
Filburt Shellbach posted:Yeah, I get that, but: Filburt Shellbach posted:this kind of treatment is probably a large part of why Perl doesn't attract newbies. PlesantDilemma posted:I don't want to encourage a derail but isn't IRC for immediate answers while both people are online at the same time? Asking a question and getting an answer sometime later is for forums & message lists. Forums and message lists are good for some stuff, but discussing topics that require a lot of back-and-forth does not fall into that scope. Similarly difficult is also the attempt to set up realtime conversation via those, because again, back-and-forth is needed for the synchronization process. ------ Cheers. vvvv Mithaldu fucked around with this message at 20:25 on Jul 7, 2014 |
# ? Jul 7, 2014 20:19 |
|
I wasn't offended, for what it's worth.
|
# ? Jul 7, 2014 20:23 |
|
I have a relatively obsure lib I need from CPAN (Thrift/XS) and all the mirrors for it are dead. I know nothing about CPAN other than how to install packages. Any tips on finding this lib? I can pull it from another box if need be, but I'm not sure that's the best way to go about it.
|
# ? Jul 11, 2014 22:32 |
|
revmoo posted:I have a relatively obsure lib I need from CPAN (Thrift/XS) and all the mirrors for it are dead. I know nothing about CPAN other than how to install packages. Any tips on finding this lib? I can pull it from another box if need be, but I'm not sure that's the best way to go about it. The download links seem to work fine? https://metacpan.org/pod/Thrift::XS http://search.cpan.org/~agrundma/Thrift-XS-1.04/
|
# ? Jul 12, 2014 01:39 |
|
Mithaldu posted:The download links seem to work fine? Interesting. Well nevermind then! Not sure why the mirrors were failing.
|
# ? Jul 12, 2014 01:52 |
|
cpan was down for like 10 minutes yesterday and metacpan was returning the same error. Kind of a silly thing to have happen
|
# ? Jul 12, 2014 16:18 |
|
uG posted:cpan was down for like 10 minutes yesterday and metacpan was returning the same error. Kind of a silly thing to have happen I was installing other packages at the time so I'm not sure if that it or not. I'll find out after the weekend I guess because
|
# ? Jul 12, 2014 16:42 |
|
So the mirrors for Thrift/XS are still broke but I was able to successfully compile it from that site, so that's cool.
revmoo fucked around with this message at 14:07 on Jul 14, 2014 |
# ? Jul 14, 2014 13:31 |
|
BTW, use cpanminus if you're not already, it makes things much simpler (and easier). It supports lots of super-cool features like installing from an arbitary local path/URL/git repo.
|
# ? Jul 14, 2014 23:28 |
|
code:
The purpose of this is to create perl ranges, even if the input is invalid (32..30..29..27 to 27..32 for instance)
|
# ? Oct 6, 2014 06:57 |
|
Firstly, here's the fix:Perl code:
I managed to boil the puzzling behaviour down to: Perl code:
qntm fucked around with this message at 12:14 on Oct 6, 2014 |
# ? Oct 6, 2014 12:03 |
|
Okay, so the answer is that Perl is complete garbage:quote:NOTE: The behaviour of a my, state, or our modified with a statement modifier conditional or loop construct (for example, my $x if ... ) is undefined. The value of the my variable may be undef, any previously assigned value, or possibly anything else. Don't rely on it. Future versions of perl might do something different from the version of perl you try it out on. Here be dragons. Yes, here, in a simple foreach loop, there be dragons.
|
# ? Oct 6, 2014 13:52 |
|
I'm surely not as savvy on perl as many others here, but isn't this just a case of the fact that since you're declaring it with my, your $words variable is local to that foreach loop? I mean saying Perl code:
Perl code:
toadee fucked around with this message at 14:14 on Oct 6, 2014 |
# ? Oct 6, 2014 14:02 |
|
If that were the case, the script would not even compile, because the $word at the final line doesn't exist, and I have strict and warnings turned on.
|
# ? Oct 6, 2014 15:51 |
|
Yeah, the problem is that Perl, for some reason, intentionally does not flag that as an error.
|
# ? Oct 6, 2014 18:59 |
|
qntm posted:If that were the case, the script would not even compile, because the $word at the final line doesn't exist, and I have strict and warnings turned on. code:
|
# ? Oct 7, 2014 08:37 |
|
So, I ran into this module. Here is the full extent of the example code for this module:Perl code:
|
# ? Dec 30, 2014 00:44 |
|
I'm a little amused that you'd have trouble reading that, given that you wrote a guide on Perl. The whole thing expects you to know how Plack middlewares and the Plack::Builder DSL work Here's the same code in a slightly more verbose manner: Perl code:
|
# ? Dec 30, 2014 01:08 |
|
Hello all. I'm pretty sure this is a fairly simple question but I know literally nothing about Perl and this is yet another project I'm taking over from an employee that no longer works here. I have a fairly simple (from what I can tell) Perl script that essentially copies data from a file and parses it into another file. This script runs once a day. It has the line code:
I need to be able to change that behavior so that I can choose a range of dates so the script can process multiple files for multiple dates rather than having it run once daily. What's the easiest way to go about this? If I have to post the full script just let me know. Thanks for any help in advance! TheEffect fucked around with this message at 18:09 on Jan 9, 2015 |
# ? Jan 9, 2015 18:03 |
|
https://stackoverflow.com/questions/6622818/what-is-the-optimal-way-to-loop-between-two-dates-in-perlcode:
code:
|
# ? Jan 9, 2015 18:34 |
|
If you don't want to deal with dependencies, you can probably also do this, for example, to get the past 7 days:code:
|
# ? Jan 9, 2015 18:43 |
|
Thanks guys. Trying Ug's solution first, but I'm getting stuck when installing the dependencies. Any idea what this is about?
|
# ? Jan 9, 2015 19:08 |
|
TheEffect posted:Thanks guys. Trying Ug's solution first, but I'm getting stuck when installing the dependencies. Any idea what this is about? It sounds like it can't figure out the dependency chain. Either you need to upgrade your CPAN.pm, or snd drolsky a mail to see if he messed up.
|
# ? Jan 9, 2015 19:13 |
|
TheEffect posted:Thanks guys. Trying Ug's solution first, but I'm getting stuck when installing the dependencies. Any idea what this is about? I see Windows. Do you know if you're using Activeperl or Strawberry perl or something else? If Activeperl is an option, it's generally much easier to install modules that need compiled code.
|
# ? Jan 9, 2015 19:22 |
|
Thanks everyone. I wasn't able to figure out the dependency issue as I'm a bit pressed for time on this (love when I get assigned to a project I have no idea about that's due the same day) but I was able to come up with a solution to my script based on Mithaldu's suggestion. Really appreciate all the help and responses. Thanks again.
|
# ? Jan 9, 2015 20:25 |
|
I have a CSV file in UTF-8 that has a lot of garbage data in it (weird ASCII characters, HTML remnants, etc An example would be source file: code:
code:
code:
Is there an easy way to do this in Perl?
|
# ? Feb 13, 2015 21:12 |
|
Make a hash with your replacements:Perl code:
Perl code:
Keep in mind the order of your replacements, since previous replacements may affect further ones; i.e. if you want to replace HTML characters (() and ampersands (&), replace the HTML characters first, then replace ampersands, otherwise one will conflict with the other. It's a quick and easy way to do it, and there may be better ways, but that'll do the job. Rohaq fucked around with this message at 21:41 on Feb 13, 2015 |
# ? Feb 13, 2015 21:25 |
|
Rohaq posted:Make a hash with your replacements: This is EXACTLY what I am looking for! Thank you so much! raej fucked around with this message at 22:07 on Feb 13, 2015 |
# ? Feb 13, 2015 21:39 |
|
raej posted:This is EXACTLY what I am looking for! Thank you so much! By the by, if you want to decode HTML entities all in one go, install HTML::Entities from CPAN and use it as follows: Perl code:
Rohaq fucked around with this message at 21:46 on Feb 13, 2015 |
# ? Feb 13, 2015 21:42 |
|
One more thing,g how would I modify this to read/modify a file?
|
# ? Feb 13, 2015 22:07 |
|
Depends: How big's the file? If it's a fairly small file, check out this tutorial: You can load it into memory, make changes line by line, and output it again, overwriting the file. If it's a really big file, you probably don't want to load it all into memory, because you've only got so much memory available. You need to look into using the Tie::File module, which can tie an array to a file, then you can loop over the array loading each line one by one, and edit lines one at a time. This is going to be slower than loading a file into memory, but it avoids your file from filling a ton of memory at any one time. Again, take a backup of the original file first, last thing you want to do is mess up your original data. Details on Tie::File can be found here: http://perldoc.perl.org/Tie/File.html Rohaq fucked around with this message at 02:36 on Feb 14, 2015 |
# ? Feb 13, 2015 23:01 |
|
Couldn't you just use sed or awk for this? This is what they do really well.
|
# ? Feb 13, 2015 23:52 |
|
It's about a 5mb text file, so....small?
|
# ? Feb 14, 2015 18:29 |
|
raej posted:It's about a 5mb text file, so....small? It only becomes problematic once you have gigantic log files. Back when I was a newbie and didn't know about Tie::File, I ended up with a 1.7GB perl process running, on a machine with only 2GB of RAM.
|
# ? Feb 14, 2015 20:59 |
|
Rohaq posted:No problem! Is there something like this for unicode? It seems like my data has a stupid amount of unicode characters like '\u00E8' which would result in 'è' However, trying encode_entities on that would remove only the '\u' portion and leave the '00E8' EDIT: Using the Replacements method above will convert everything after the '\' but keeps the '\' intact Perl code:
raej fucked around with this message at 18:23 on Feb 16, 2015 |
# ? Feb 16, 2015 18:16 |
|
raej posted:Is there something like this for unicode? It seems like my data has a stupid amount of unicode characters like '\u00E8' which would result in 'è' This is the easiest really: code:
|
# ? Feb 16, 2015 18:23 |
|
Mithaldu posted:This is the easiest really: on the second line, am I putting that on the open part? Here's my messy code: Perl code:
|
# ? Feb 16, 2015 18:26 |
|
|
# ? Jun 8, 2024 01:30 |
|
raej posted:on the second line, am I putting that on the open part? It completely replaces open/close etc by wrapping the filehandle in an object that does all the sanity-checks and automatically closes the FH when the object is destroyed at the end of a function. Here's code of either streaming or slurping that should do what you need: Perl code:
|
# ? Feb 17, 2015 06:29 |