(view source code of midititl.pl as plain text)
#! perl
# Store help text in a variable
$syntax = "\nMidiTitl.pl, Version 0.50 BETA\n";
$syntax = $syntax."Display titles of specified MIDI file(s)\n\n";
$syntax = $syntax."Usage: MIDITITL.PL filespec.mid\n\n";
$syntax = $syntax."Where: filespec.mid is a (list of) MIDI file(s);\n";
$syntax = $syntax." (wildcards allowed)\n\n";
$syntax = $syntax."Written by Rob van der Woude\nhttp://www.robvanderwoude.com\n";
# Check command line argument(s), open specified MIDI file
if ( !@ARGV[0] or @ARGV[1] ) {
die( $syntax );
} else {
$midi = @ARGV[0];
open( STDIN, "< $midi" ) or die "\nCannot open file $midi\n $!\n $^E\n\n$syntax";
}
# Read MIDI file
$line = "";
while ( <STDIN> ) {
$line = "$line $_";
}
# Close MIDI file
close STDIN;
# Remove excess white space
$line =~ s/\s\s/ /g;
# Filter relevant output
$string = "";
$count = 0;
while ( $line ) {
$count = $count + 1;
if ( $line =~ m/([-_A-Z0-9\/\.,\s\(\)]{5,})(.*)$/i ) {
chomp( $string = "$string $1" );
$line = $2;
}
# Abort after 1000 iterations
if ( $count > 1000 ) {
$line = undef;
}
}
# Remove everything before first tab
if ( $string =~ m/\t(.*)/ ) {
$string = $1;
}
# Display output
print "\n$string\n";
page last modified: 2024-04-16; loaded in 0.0066 seconds