#!/usr/bin/perl -w

use 5.034;

my $user = `whoami`;
$user =~ s/\n//g;

my $filename = "/home/$user/rem.log";

if (@ARGV){
    my $args = " ";
    $args .= join " ", @ARGV;
    $args =~ s/\|+//g;
    $args =~ s/\>+//g;
    $args =~ s/\<+//g;
    
    
    if ($args =~ / -(\d+) /){
	my $num = $1;
	say `tail -$num $filename`;
    }elsif ($args =~ / \+(\d+) /){
	my $num = $1;
        say `head +$num $filename`;
    }else{
	system "echo $args >> $filename";
	say "$0 OK";
    }
    
    # huh?
}else{
    if (-e $filename){
	system "cat $filename";
    }else{
	say "";
	say "Usage: $0     -> gives you the previous reminders";
	say "       $0 this that -> store 'this that' in the location $filename";
	say "       $0 blah -2 -> gives you the last 2 entries of $filename";
	say "       $0 pong +3 -> gives the three first entries of $filename";
	say "";
    }
}

exit 3;

