in reply to Re^3: I need help with opening a directory and reading files in that directory.
in thread I need help with opening a directory and reading files in that directory.
Shadowsong, here is the output of my directory. I know that music files don't consist of .txt extensions, but this is what I was asked to do for the assignment. So, I made these files names up and went with this type. Inside the files there is supposed to one line that contains the album, minutes, seconds, and genre each separate by ":". The Sun and the Moon:3:47:Alternative
OUTPUT of DIRECTORY:<\p>
The Bravery-Believe.txt
output for file: The Bravery-Believe.txt
The Bouncing Souls-True Believers.txt
output for file: The Bouncing Souls-True Believers.txt
The Kickdrums-Atonement.txt
output for file: The Kickdrums-Atonement.txt
I'm assuming that this:
if ($_ =~ /\.txt/){ chomp $_; my ($artist, $song_title) = split '-', $_, 3; $length{$artist}{$artist} = $artist; $length{$artist}{$song_title} = $song_title; print "$_"; # print this file/directory's name
Could be part of this:
open FH, "<$_" or die $!; print "output for file: $_\n"; while (my $line = <FH>) { print $line; chomp $line; if ($line =~ /\.txt/){ my $artist; my ($album, $minutes, $seconds, $genre) = split ':', $line, 4; $length{$artist}{album} = $album; $length{$artist}{minutes} = $minutes; $length{$artist}{seconds} = $seconds; $length{$artist}{genre} = $genre; print $album, "\n"; }
So, I'm still trying to open the FH of the .txt file and read the contents to get the total amount of the song length for each line and print it out. "Saying this Artist has a total amount of Music". I really appreciate your guidance and patience with me. I know I am a newby at this, but I'm willing to put the time in to learn and get the most out of this language. Thanks, Brandon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: I need help with opening a directory and reading files in that directory.
by shadowsong (Pilgrim) on Sep 09, 2015 at 09:37 UTC | |
by brawal128 (Novice) on Sep 09, 2015 at 14:46 UTC | |
by shadowsong (Pilgrim) on Sep 09, 2015 at 22:51 UTC | |
by brawal128 (Novice) on Sep 10, 2015 at 21:20 UTC | |
by shadowsong (Pilgrim) on Sep 10, 2015 at 21:42 UTC |