Chovy’s Blog

Finding an Intersection Between Arrays in Perl

Thu, May 17, 2007 — Category: Perl

Short recipe for grabbing an intersection between two arrays in Perl.

As explained on perl monks and Pete Kruckenberg’s post…I needed a similar function that returns an intersection between two arrays in Perl.


#!/usr/bin/perl -w

use strict;
use Data::Dumper;

my @array1 = (1, 2, 3);
my @array2 = (2, 3, 4);
my %original = ();
my @isect = ();

map { $original{$_} => 1 } @array1;
@isect = grep { $original{$_} } @array2;

print Dumper(@isect);

#outputs
#$VAR1 = 2;
#$VAR2 = 3;

The above code works with duplicates, meaning that duplicates in @array2 will be added as individual elements in the array @isect.

  • Post Finding an Intersection Between Arrays in Perl to del.icio.us
  • Post Finding an Intersection Between Arrays in Perl to digg
  • Post Finding an Intersection Between Arrays in Perl to Furl
  • Add Finding an Intersection Between Arrays in Perl to YahooMyWeb
  • Simpify!
  • Post Finding an Intersection Between Arrays in Perl to shadows
  • Post Finding an Intersection Between Arrays in Perl to Spurl
  • Post Finding an Intersection Between Arrays in Perl to BuddyMarks
  • Submit Finding an Intersection Between Arrays in Perl to Slashdot

Correctly submitting a blog post with a trackback url

Tue, May 15, 2007 — Category: Marketing

Testing a trackback with wordpress postings.

This post references Paid Links and the Effect on Google and should show up as a trackback in the original posts comment section.

  • Post Correctly submitting a blog post with a trackback url to del.icio.us
  • Post Correctly submitting a blog post with a trackback url to digg
  • Post Correctly submitting a blog post with a trackback url to Furl
  • Add Correctly submitting a blog post with a trackback url to YahooMyWeb
  • Simpify!
  • Post Correctly submitting a blog post with a trackback url to shadows
  • Post Correctly submitting a blog post with a trackback url to Spurl
  • Post Correctly submitting a blog post with a trackback url to BuddyMarks
  • Submit Correctly submitting a blog post with a trackback url to Slashdot

Renaming JavaScript Objects

Fri, May 4, 2007 — Category: JavaScript

A brief explanation of testing object properties and how those objects are copied in JavaScript.

javascript:var foo = {baz: 'bizzer'};
var bar = foo;
bar.baz = 'bazzer';
alert(foo.baz + ' == ' + bar.baz);

As you can see the object’s property of ‘baz’ is updated in both foo object and bar object (a copy or reference to foo).

  • Post Renaming JavaScript Objects to del.icio.us
  • Post Renaming JavaScript Objects to digg
  • Post Renaming JavaScript Objects to Furl
  • Add Renaming JavaScript Objects to YahooMyWeb
  • Simpify!
  • Post Renaming JavaScript Objects to shadows
  • Post Renaming JavaScript Objects to Spurl
  • Post Renaming JavaScript Objects to BuddyMarks
  • Submit Renaming JavaScript Objects to Slashdot
Next Page »
 
Keyword Advertisers:
SEO Directory SEO Links Free Link Directory Shopping Submission Directory Gardening Tips Political Forum Search Engine Optimization Search Engine Marketing Audio Video Directory SEO Forum Web Development Blog Organic SEO Wiki Web Development Consulting

Learn more about purchasing keyword text link ads on this site.