Created
December 1, 2009 22:02
-
-
Save rsayers/246697 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
package GopherScript; | |
sub new | |
{ | |
my $class = shift; | |
my $self = { | |
hostname => shift, | |
port => shift, | |
mode => "dir", | |
args => {} | |
}; | |
bless $self,$class; | |
$self->{args}=$self->parseArgs(); | |
return $self; | |
} | |
sub parseArgs | |
{ | |
my %args = (); | |
@tmp = split ('&',$ARGV[0]); | |
foreach (@tmp) { | |
($k,$v)=split '='; | |
$args{$k}=$v; | |
} | |
return \%args; | |
} | |
sub setMode | |
{ | |
my ($self,$mode)=@_; | |
$self->{mode}=$mode; | |
return $self; | |
} | |
sub getMode | |
{ | |
my ($self) = @_; | |
return $self->{mode}; | |
} | |
sub print | |
{ | |
my ($self,$str) = @_; | |
if ($self->{mode} eq "dir"){ | |
print "i$str\t\t\t\n"; | |
}else{ | |
print "$str"; | |
} | |
} | |
sub link | |
{ | |
my ($self, $type, $linkStr, $fileName, $hostname, $port) = @_; | |
$hostname = $self->{hostname} if !defined($hostname); | |
$port = $self->{port} if !defined($port); | |
print "$type$linkStr\t$fileName\t$hostname\t$port\n"; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment