|
Twlight posted:This is what I have so far, it cut down a lot of the txt that I didn't need. now each line has this format code:
Nevergirls fucked around with this message at 09:35 on Oct 31, 2007 |
# ¿ Oct 31, 2007 09:29 |
|
|
# ¿ May 1, 2024 00:12 |
|
Triple Tech posted:A better, "more right", more complicated way would be to have a script interpret and parse the entire conf file, modify the Perl object that represents it, and then serialize it again... That would be the most flawless way. The Perl way is to have someone else do the heavy lifting for you.
|
# ¿ Dec 21, 2007 06:33 |
|
I have to recommend IPC::System::Simple's systemx and capturex, because they do everything I can't be bothered to think about.
|
# ¿ Dec 4, 2008 01:31 |
|
Tatsuhiko Miyagawa is the best thing to happen to Perl in a decade. First, he wrote Plack. Then he found that CPAN.pm was swapping on his VPS, so he wrote cpanminus, which is tiny, does the right things with no configuration, and covers enough to almost entirely replace CPAN(PLUS).
|
# ¿ Feb 24, 2010 21:45 |
|
JawnV6 posted:The pattern I always use is this: I prefer abusing list context: code:
|
# ¿ Jul 8, 2010 03:58 |
|
Your two-column table looks suspiciously like a hash:code:
|
# ¿ Oct 28, 2010 07:54 |
|
Clanpot Shake posted:I'd like to write a perl script that calls several executable jar files in sequence and appends all of their output (standard and err) to a log file. Try IPC::Run, specifically something like code:
Backticks are of the Devil. Avoid them at every opportunity.
|
# ¿ Jan 8, 2011 08:32 |
|
syphon posted:Why? I use them extensively to call external programs in Win32 platforms (where it's much more useful to parse the output than it is to catch the return code). I've never really run into a problem with them... but that certainly doesn't mean that one doesn't exist! As soon as you do it, you've stopped writing perl and started writing shell. (Admittedly, this may not be as much of a concern on Windows.) On top of being inflexible, it introduces things you shouldn't have to think about. E.g., to capture stderr, you have to do something like code:
Modules like IPC::Run or IPC::System::Simple are easier to use and more secure than deferring to the shell. I mean, there's a reason why you're doing this in perl in the first place, right?
|
# ¿ Jan 8, 2011 20:35 |
|
Rohaq posted:Quick question, I'm using while(<>) to iterate through a file line by line at the moment, is there a quick way to remove the line being processed from the file at the end of the loop, without messing up the while loop? I'd like to process a line, then remove it from the file after it's done. You can turn on in-place edit mode in the file, just like using -i on the command line: code:
|
# ¿ Dec 16, 2011 17:06 |
|
syphon posted:I keep trying to get into Catalyst or Plack You say this like Catalyst and Plack are conceptually close. They are not. Plack is a web server interface. You have a web application that talks Plack, and it can run on any server that understands Plack. It makes deploying web applications dead easy. This is similar to (and named after) Rack in the ruby world. Catalyst is a web framework. It gives you tools to write web applications. (So does CGI.pm, albeit tools that were crummy by even 1998 standards.) Catalyst talks Plack, so you can deploy it on any server that understands it. Stuck in a CGI-only environment? Plack::Handler::CGI to the rescue. Yes, even you can run complex web applications with the breathtaking speed afforded by CGI.
|
# ¿ Jan 19, 2012 05:35 |
|
Sizzler Manager posted:As I understand it, if you use .. inside an if like this, it starts returning true as soon as the left hand side matches, and it stays true over multiple lines until the right side matches. That's roughly correct; it's a language feature borrowed from sed and awk. Its behavior is determined by list/scalar context. And it gets a little crazy. http://perldoc.perl.org/perlop.html#Range-Operators
|
# ¿ Jul 17, 2012 04:18 |
|
uG posted:if I do print "$away | $away" it might print " | NEVV" (instead of "NEV | NEV"). which can be useful: perl -CS -Mutf8 -e'while(++$|){for(qw(✭ ✮ ★ ✯ ✫ ☆ ✩)){print"\r$_ throbbing, please wait… $_ ";select$u,$u,$u,0.1}}'
|
# ¿ Aug 16, 2012 04:16 |
|
|
# ¿ May 1, 2024 00:12 |
|
Rohaq posted:I should have probably said; my regex contained no quote marks, I just put them in quote marks in my post. Regexp::Debugger, like any good DCONWAY module, is insane. It's brand new and I've only used it a couple times when my lovely one-liner isn't working (via rxrx). It allows you to step through what the engine is doing, not just get a match/non-match. Here's a screencast from YAPC::NA: https://www.youtube.com/watch?v=zcSFIUiMgAs
|
# ¿ Oct 22, 2012 01:13 |