Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Hughmoris posted:

code:
my @punchlines = {
	"None. Change it once, and its the same everywhere...",
	"One, he just stands below...",
	"A millon, one to change it...",
	'CHANGE?!!"'
};

You want parentheses not braces.

Adbot
ADBOT LOVES YOU

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Pretty good post describing the project's history http://use.perl.org/~masak/journal/40451

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

pmichaud posted:

Rakudo Star releases are created on a monthly cycle or as needed in response to important bug fixes or improvements. The next planned release of Rakudo Star will be on August 24, 2010.

This is the first I've heard of Rakudo Star being a regular thing. I thought it was a one-shot release, hyped up as something usable to encourage people to finally try Perl 6.

Cool, either way, though I wonder how it'll interact with existing monthly releases.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Otto Skorzeny posted:

The id didn't get recognized by rt.cpan.org immediately]

rt.cpan only syncs new accounts a couple times (maybe only once?) a day

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Otto Skorzeny posted:

typester is alive :woop:

Wait, this typester? http://twitter.com/typester

What made you think otherwise?

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

qntm posted:

Perhaps I haven't looked far enough, but I've never found a command line shell which provides the simple ability to safely escape-and-quote an arbitrary string.

I think fish does? I should switch to it because I hate every shell including the one I use, zsh. Any shell that makes me type '"'"' instead of \' is a bastard.

To bring this back to Perl a bit, there's a module that should be in your toolbox: String::ShellQuote.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Winkle-Daddy posted:

All I can think of is that it's used to test a function that you eventually want to make a loop out of it, but just need it to temporarily run once for testing.

What the gently caress. Just do for (1) or do if that's what you need. If multiple people need to run a code snippet to figure out what it does, it probably doesn't belong in real code.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Cock Democracy posted:

What I want to know is, if you're already a perl guy, why the hell aren't you using Request Tracker for your ticketing system? Knowing some perl you can make it to do all kinds of awesome stuff.

What kind of awesome stuff have you made it do? (disclaimer: I work for the company that makes it, hence Anaconda's question)

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Glad to see you're making good use of RT!

Lifecycles are the coolest new feature in 4.0. You can define your set of ticket statuses and transitions between them at the queue level. There's also full-text search that doesn't suck, and lots of good UI improvements like quote folding.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

qntm posted:

Where, and why, is a hash named %} declared? It's not me, and it's not mentioned in perlvar as a built-in variable. Obviously, it's straightforward to populate it with stuff, but what is it supposed to be for? Very strange.

In general, special variables like $_ and @ARGV are "superglobal" because package scope does not apply to them. This means you can use them in any package and they have the same value. The way this is implemented internally is (I presume) marking the globs *_ and *ARGV as superglobal. This has a side-effect of making @_ %_ $ARGV and %ARGV superglobal as well. @_ is even specialer so ignore it for now.

%ARGV is populated by modules like Getopt::Whatever and is generally useful.

Jifty abuses sub _ { ... } to get a superglobal function for localizing text. Functions are in stored in typeglobs too.

$} is not a special variable so I don't know why it follows this pattern. Maybe an oversight, or maybe it's just because it's a punctuation variable.

summary: gently caress symbol tables and gently caress type globs

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Call localtime in list context and it gives you the breakdown. From there all you need to do is subtract each element in a loop (or if you're feeling wizardly, use List::MoreUtils's pairwise).

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Web::Scraper is the poo poo. You can extract HTML using CSS selectors or XPath.

I used it recently to scrape the translation status of our project from a site that uses fixed-width images as progress bars.

code:
my $scraper = scraper {
    process '#languagestats tr.stats', 'languages[]' => scraper {
        process 'td > a',
            name => 'TEXT',
            link => '@href';

        process 'td > img',
            translated => '@width';
    };
};

my $results = $scraper->scrape(URI->new('https://...'));

__END__
$results = {
    languages => [
       {
         link       => URI->new('https://...'),
         name       => 'Arabic',
         translated => 17.0118343195
       },
       {
         link       => URI->new('https://...'),
         name       => 'Armenian',
         translated => 1.18343195266
       },
       {
         link       => URI->new('https://...'),
         name       => 'Brazilian Portuguese',
         translated => 81.3609467456
       },
       .
       .
       .
    ]
}

Filburt Shellbach fucked around with this message at 20:23 on May 24, 2011

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
You're the first person I've seen who uses pQuery. Do you like it?

Selenium is worth trying, definitely. Alien::Selenium may or may not make your life easier.

PhantomJS is an up-and-comer too. It's a headless webkit. It's not as entrenched as Selenium but the idea is pretty neat.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
The word you want for that is ReadLine, which emulates a shell-like environment. Term::ReadLine is the standard there, but it's not great. Term::ReadLine::Gnu can sometimes make it better.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Mario Incandenza posted:

Devel::REPL has a bunch of tab completion plugins, I can't imagine it would be difficult to hack something up for that.

I hope it's not. I did write all of Devel::REPL's tab completion functionality. :cool:

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
more like ebcdic

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Mithaldu posted:

I think this deserves a mention here too: If you use catalyst and Template::Toolkit you can fix XSS issues globally now: http://blogs.perl.org/users/mithaldu/2011/07/fixing-xss-in-catalyst-with-a-really-big-hammer.html

Wow! I didn't know TT did no escaping by default. This makes me glad to be a Mason user, since it assumes HTML escaping unless otherwise specified.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
My go-to is utf8::all. Install that from CPAN and add -Mutf8::all to that perl invocation.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Instead of absurd values I just leverage undef. Makes the comparisons a tiny bit more complicated but at least it works around having bizarre constants which, apparently!, confuse people.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Mithaldu posted:

You want grep. :)

Also, head over to http://perl-tutorial.org and get a more current tutorial. Barewords for filehandles are a pretty bad idea and doing it like this is much safer:

code:
open my $DICTIONARY, "dictionary.txt";

Three-arg open is a lot safer than lexical filehandles dude.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Getopt::Whatever. I use it all the time for very short scripts that I don't expect anyone else to use.

There's also Getopt::Casual.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

qntm posted:

It surprises me that "just give me all of the command line options in hash; I'll deal with them myself" is an unusual request.

It's not.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Why are you touting Web::Simple instead of a real framework that has both users and developers?

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
pre:
$name =~ s/[^A-Za-z0-9.-_]/-/g

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Acme::State is exactly the solution to everyone's problems.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
HTML::LinkExtor

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

gently caress this noise.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Mario Incandenza posted:

5.18.0 is out, some cool new things there

I added the three new DTrace probes :smug:

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Jifty used sub _ for localization, which is exposed globally thanks to $_ and @_ and the magic of typeglobs.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Mithaldu posted:

(that means don't loving disconnect, get a bouncer/shell if you don't have a useful machine)

Why is this such a big deal? I thought you were all about lowering the barrier to entry.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
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.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Yeah, the problem is that Perl, for some reason, intentionally does not flag that as an error.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
code:
my $ssn = "###-##-####" =~ s/#/int rand 10/ger;

Adbot
ADBOT LOVES YOU

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Put another way, "more letters" doesn't mean "more explicit".

  • Locked thread