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
leedo
Nov 28, 2000

Anyone else going to YAPC this year? I met a few of you last year and had a pretty good time (apart from getting sick after the big dinner.)

Adbot
ADBOT LOVES YOU

leedo
Nov 28, 2000

Otto Skorzeny posted:

Sartak/Filburt Shellback mentioned he's giving a talk again

I'm broke and thus working 10x6 for the summer so I can't be there :(

Bummer, I managed to get my employer to send me again (yay!) I am definitely going to be checking out Sartak's "Nonhierarchical OOP‎" talk since I still have trouble recognizing good uses for roles.

leedo
Nov 28, 2000

Mithaldu posted:

Is there an online version of that somewhere? Or a book or whatever?

http://yapc2010.com/yn2010/talk/2634

Not sure that slides exist yet since it is still more than a month off.

This looks like a pretty comprehensive collection of links on the topic. Chromatic also wrote a big series of posts about it.

leedo
Nov 28, 2000

Has anyone ever encountered code where a hashref is preceded by a +? I have seen this a few times and have not been able to figure out why it is being done. I assume it forces some sort of context... but I have never been able to find a case where it actually did anything.

e.g.
code:
+{
    'DBI' => [
        'dbi:SQLite:dbname=development.db',
        '',
        '',
        +{
            sqlite_unicode => 1,
        }
    ],
    'Text::Xslate' => +{
    },
};
edit: and a quick google search later clears it up. It is meant to disambiguate a hashref from a code block.

leedo fucked around with this message at 23:12 on Mar 8, 2011

leedo
Nov 28, 2000

code:
use List::MoreUtils qw/uniq/;
sort uniq @raw;
!!!!

leedo
Nov 28, 2000

I've been using Web::Scraper recently too for writing a generic content embedding service, similar to what twitter does for certain links in tweets. Here is an example that scrapes the title and introduction to wikipedia articles.

leedo
Nov 28, 2000

File::HomeDir (does this still pull in a ton of awful Carbon modules) + serializer of choice?

leedo
Nov 28, 2000

Anaconda Rifle posted:

It's not just an efficiency thing. /"(.+?)",/ and /"([^"]+)",/ can get different results. It's subtle, but extremely important.

I changed your example intentionally to make a point.

[^"] matches newlines by default whereas . doesn't? Took me a while of staring to even come up with a guess.

leedo
Nov 28, 2000

As another option there is Web::Scraper
code:
use v5.14;
use Web::Scraper;
use URI;

my $scraper = scraper {
  process 'a[href^="/browsebrewers"]', 'links[]' => '@href';
};

my $data = $scraper->scrape(URI->new("http://www.ratebeer.com/BrowseBrewers.asp"));
say join ", ", @{$data->{links}};

leedo
Nov 28, 2000

Too many ways to do it, I'm switching to python!

leedo
Nov 28, 2000

het posted:

There are other benefits, like transparently passing an array by reference so you can change it a la push(), but you can be virtually guaranteed that anyone who uses perl function prototypes constantly has no idea what they're for and shouldn't be using them.

One cool use for prototypes is passing blocks in without the need for sub.

e.g.

code:
#!/usr/bin/env perl

use v5.14;

sub mapp(&@) {
  my ($f, @a) = @_;
  my @col;
  for (@a) {
    push @col, $f->($_);
  }
  return @col;
}

my @plus_one = mapp { $_ + 1} (0,1,2);

say join ", ", @plus_one;

Adbot
ADBOT LOVES YOU

leedo
Nov 28, 2000

I'm a big fan of Web::Scraper

  • Locked thread