On 1/18/07, Mathew <[EMAIL PROTECTED]> wrote:

open FILE, "H:\My Music\folderlist.txt";

Use forward slashes instead of backslashes in filename strings, even
on Windows. (Or, if you mean a true backslash, use two of them; a
single backslash is always magical in Perl.) And check the return
value from open, so you'll know when it fails. (Which it did.)

   open FILE, "H:/My Music/folderlist.txt"
     or die "Can't open 'H:/My Music/folderlist.txt': $!";

foreach my $line (readline FILE) {
        $line =~ s/^.*\s//g;

That looks as if it will replace the entire $line with an empty
string, then try to do that again (the /g option). That doesn't seem
likely to be useful. I'm not sure what you were trying to do there.
Perhaps you'd like to use a pattern match with memory parentheses?
That would let you non-destructively extract data from the line.

        open FILE2, "H:\My Music\artists.txt";
        print FILE2 $line . "\n";
        close FILE2;
}

Since this is inside the loop, you're repeatedly opening and closing
the same file. Why? If you had turned on warnings, Perl would have
told you that you didn't open FILE2 for output anyway.

I recommend that you "use strict" and "use warnings". But you can also
step through a troublesome program in the Perl debugger.

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to