Skip to content

Instantly share code, notes, and snippets.

@petdance
Last active July 21, 2016 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petdance/4ddc8fd4e2b1eb0d12ba04516f222e8b to your computer and use it in GitHub Desktop.
Save petdance/4ddc8fd4e2b1eb0d12ba04516f222e8b to your computer and use it in GitHub Desktop.
I have tons of data where I have setups like this:
my %expected = ( country => ‘US’, state => ‘IL’, province => undef );
my %expected = ( country => ‘CA’, state => undef, province => ‘ON’ );
And then loop through and scrape them
if ( defined($value) ) {
$mech->scraped_id_is( $id, $value );
} else {
$mech->lacks_id( $id );
}
I need a wrapper function that wraps up that functionality.
sub some_method {
my ($id,$value) = @_;
if ( defined($value) ) {
return $mech->scraped_id_is( $id, $value );
} else {
return $mech->lacks_id( $id );
}
}
What do I call it?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment