1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#!/usr/bin/perl -w
# $Id: workman,v 1.3 2013/07/14 21:24:13 tom Exp $
#
# Initialize Cdk.
#
use strict;
use Cdk;
Cdk::init();
# Pop up the opening label.
popupLabel(
[
"<C></16/B>Workman Database Editor.",
"",
"<C></24/B>Written By Mike Glover"
]
);
# Set a default name for the workman database.
my $workmandb = $ENV{'HOME'} . "/.workmandb";
# Open up the database and read in the contents.
my @cdList = readWorkmanDatabase($workmandb);
# Let the user play with the given information.
playWithWorkManDatabase(@cdList);
#
# This allows the user to manipulate the workman database.
#
sub playWithWorkManDatabase {
}
#
# This reads in the current contents of the workman database.
#
sub readWorkmanDatabase {
my $filename = shift;
my @contents = ();
my $count = 0;
my $x = 0;
# Return if we can't open the file.
return if !( open( FILE, $filename ) );
# Slurp in the file.
my @workmandb = <FILE>;
chomp @workmandb;
# Strip out the contents of the database.
for ( $x = 0 ; $x < $#workmandb ; $x++ ) {
# Remove comments and empty lines.
next if $workmandb[$x] =~ /^#/;
next if $workmandb[$x] =~ /^$/;
# Is this a start of a CD listing.
if ( $workmandb[$x] =~ /^tracks (\d*)/ ) {
my $trackCount = $1;
my $trackLine = $workmandb[ $x++ ];
my $cdName = $workmandb[ $x++ ];
my $artist = $workmandb[ $x++ ];
my @tracks = ();
my $current = 0;
# Get each track from the database.
for ( $current = 0 ; $current < $trackCount ; $current++ ) {
push( @tracks, $workmandb[ $x++ ] );
}
$x--;
# Create the database object and put it onto the stack.
my $object =
new WorkManData( $trackLine, $cdName, $artist, @tracks );
# Put it onto the stack.
push( @contents, $object );
}
}
return @contents;
}
#
# This writes out a workman database.
#
sub writeWorkManData {
}
#########################################
package WorkManData;
#
# This creates a new object.
#
sub new {
my ( $type, $trackLine, $cdName, $artist, @tracks ) = @_;
my @trackInfo = ();
my @indexInfo = ();
my $self = {};
# Split the trackline apart.
my ( $junk, $trackCount, @index ) = split( /\s+/, $trackLine );
# Clean off the garbage from the track lines.
for ( my $x = 0 ; $x <= $#tracks ; $x++ ) {
# Strip out the track name.
my $trackName = $1 if $tracks[$x] =~ /^track\s+(.*)/;
# If there is no track name, then provide a default answer.
if ( $trackName ne "" ) {
push( @trackInfo, $trackName );
}
else {
push( @trackInfo, "No Track Name Given" );
}
}
# Store the info in the object.
( $self->{'Artist'} = $1 ) if $artist =~ /^artist\s+(.*)/;
( $self->{'CDName'} = $1 ) if $cdName =~ /^cdname\s+(.*)/;
$self->{'Tracks'} = \@trackInfo;
$self->{'Index'} = \@indexInfo;
return bless $self;
}
|