#!/usr/bin/perl
#
# urlopen v0.0.3 - opens URL in a new tab in the current mozilla/firefox session
# Copyright (C) 2004, 2005 Stian Skjæveland
#
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#

use strict;

my $mozua="firefox"; # you may change this path to whatever fits your system

if (!($ARGV[0])) {
  &usage();
} elsif ($ARGV[0]=~/(http|www)/) {
  if (!($ARGV[0]=~/http/)) {
    $ARGV[0]="http://$ARGV[0]";
    print "$0: now opening $ARGV[0]\n";
  }     
} else {
  &usage();
}
system("$mozua -remote 'openURL($ARGV[0],new-tab)'");

sub usage() {
  die("Usage: $0 <URL>\n");
}
