All pastes #26255 Raw Edit

Someone

public text v1 · immutable
#26255 ·published 2005-10-22 08:37 UTC
rendered paste body
kaitlyn@rogue ~/perl $ cat addressbook
#!/usr/bin/perl

use strict;
use warnings;
sub get_prompt {
        my $prompt = shift;
        print $prompt . ": ";
        my $input = <STDIN>;
        chomp $input;
        return $input;
}

if ( ! @ARGV ) {
        print "Please give me something to do!\n";
        exit 1;
}


my $command = shift @ARGV;

if ( $command eq "add" ) {

        my $name = get_prompt "Full Name";
        my $email = get_prompt "Email Address";
        my $phone = get_prompt "Phone Number";

        open my $savefile, ">>", "addressbook.db";
        print $savefile $name . " %: " . $phone . " %: " . $email . "\n";
        close $savefile
}
else {
print "Tell me to do something!\n";
exit 1
}