Unnamed Repository Project (URP)

Zeno

Student
Joined
Apr 16, 2005
Messages
32
This is a small program I wrote to compile web resources I have read in the past. Feel free to add on and improve it any way you desire as long as you repost it. You can ask me questions about it as well because I don't comment my programming.

Please don't be too rude about my programming. I have taken two programming classes in C++ and that is about it. This is written in Perl.

Code:
#!/usr/bin/perl -w
use warnings;
use strict;


sub writeURL{  
    my $key=shift()."@@@".time();
    my $url=shift();
    dbmopen(my %db,"urp",0644)||die"Cannot open DBM: urp $!\n";
    $db{$key}=$url;
    my($printkey,$timerunoff)=split(/@@@/,$key);
    print $url . " added to " . $printkey . "\n";
    dbmclose(%db);
}

sub readURL{
    my $key=shift();
    dbmopen(my %db,"urp",0644)||die"Cannot open DBM: urp $!\n";
    while(my($dbkey,$dburl)=each %db){
	my($tskey,$tstime)=split(/@@@/,$dbkey);
	if($tskey eq $key){
	    print $dburl . "\n";
	}
    }
    dbmclose(%db);
}

sub removeURL{
    my $key=shift();
    my $url=shift();
    my $tog;
    dbmopen(my %db,"urp",0644)||die"Cannot open DBM: urp $!";
    while(my($dbkey,$dburl)=each %db){
	my($tskey,$tstime)=split(/@@@/,$dbkey);
	if($tskey eq $key){
	    my $tsurl = $db{$dbkey};
	    if($tsurl eq $url){
		delete($db{$dbkey});
		print $url . " has been deleted.\n";
		$tog=1;
	    }
	}
    }
    if($tog==0){
	print $url . " was not found.\n";
    }
}

my $usr = shift;
my $key = shift;

if($usr eq "-a"){
    writeURL($key,shift());
}

if($usr eq "-w"){
    readURL($key);
}

if($usr eq "-r"){
    removeURL($key,shift());
}
 
Are you sure you posted this to the right forum?

There are few computer programming examiners here. I am one of them, but I don't deal with Perl. Sorry.

I'm really only replying out of sympathy. I recently posted a thread about Tablets that no one responded to. :(

If you've got anything interesting to say on scientific or skeptical topics, though, I'm sure you'll get more feedback.
 
This is a small program I wrote to compile web resources I have read in the past. Feel free to add on and improve it any way you desire as long as you repost it. You can ask me questions about it as well because I don't comment my programming.

Please don't be too rude about my programming. I have taken two programming classes in C++ and that is about it. This is written in Perl.

Code:
#!/usr/bin/perl -w
use warnings;
use strict;
 
 
sub writeURL{  
    my $key=shift()."@@@".time();
    my $url=shift();
    dbmopen(my %db,"urp",0644)||die"Cannot open DBM: urp $!\n";
    $db{$key}=$url;
    my($printkey,$timerunoff)=split(/@@@/,$key);
    print $url . " added to " . $printkey . "\n";
    dbmclose(%db);
}
 
sub readURL{
    my $key=shift();
    dbmopen(my %db,"urp",0644)||die"Cannot open DBM: urp $!\n";
    while(my($dbkey,$dburl)=each %db){
    my($tskey,$tstime)=split(/@@@/,$dbkey);
    if($tskey eq $key){
        print $dburl . "\n";
    }
    }
    dbmclose(%db);
}
 
sub removeURL{
    my $key=shift();
    my $url=shift();
    my $tog;
    dbmopen(my %db,"urp",0644)||die"Cannot open DBM: urp $!";
    while(my($dbkey,$dburl)=each %db){
    my($tskey,$tstime)=split(/@@@/,$dbkey);
    if($tskey eq $key){
        my $tsurl = $db{$dbkey};
        if($tsurl eq $url){
        delete($db{$dbkey});
        print $url . " has been deleted.\n";
        $tog=1;
        }
    }
    }
    if($tog==0){
    print $url . " was not found.\n";
    }
}
 
my $usr = shift;
my $key = shift;
 
if($usr eq "-a"){
    writeURL($key,shift());
}
 
if($usr eq "-w"){
    readURL($key);
}
 
if($usr eq "-r"){
    removeURL($key,shift());
}


Seems to me that ure trying to make a additional "choice tab link" for your browser? I can envision your program in my head. The picture Im getting is... It would show up like a box, with command links inside the box and each link that you click would have direct command, either to add a url, remove a url, or read a url. Am I correct?

It would be great if you are using it to read your history files in the browser. Sounds like a good idea.
 

Back
Top Bottom