Why won't split() find \n?



I am writing a script to read the metadata from a bunch of mp4 flies
in a directory, then grab bits of info from the metatags. I am using
system("mdls $filename") to read the metadata.

The problem I am having is that I can't seem to split the metadata
into individual lines. I am using split(/\n/, $metadata) to split by
EOL characters, but it doesn't work.

I've tried replacing \n with other EOL characters: \lf, \cr, \nel,
\ff, \ls, ps -- but nothing seems to work. What am I doing wrong?

I've got a test print statement at the bottom that's supposed to ad
the text "EOL" at the end of each line. Here's my script so far:

#!/usr/bin/perl -w

###############
# Init Variables
$directory = "/Users/joe/Movies/Already Backed Up/";

###############
# Read the directory contents
opendir(DOCS, $directory); #opens the directory
@rawContents = readdir(DOCS);
foreach(@rawContents) {
if($_ !~ /^\./) { #Ignore files that start with a period.
push(@fileNames, $_); #Create a new array with just the live files
}
}

###############
# Convert filenames to unix paths
foreach(@fileNames) {
push(@filePath, $directory.$_); #Add the directory path to the file
names
}
foreach(@filePath) {
($_ =~ s/ /\\ /g);
push(@unixPaths, $_);
}

###############
# Get the metada
$metadata = system("mdls $unixPaths[0]"); #Run unix command mdls.
@metadataArray = split(/\n/, $metadata);

###############
# Test print

foreach(@metadataArray) {
print("$_ EOL\n");
}


For the record -- I'm a perl newbie using MacBook Pro OS 10.4.8. I'm
running perl scripts via terminal/bash.

.



Relevant Pages

  • Re: Those clever people in Redmond.
    ... "file" did whatever the metadata told it to do. ... So, when you double-clicked on a script file, did that launch an editor or ... If the script was in an application folder (one of these directory special ... Mind you, ...
    (uk.misc)
  • Safari/Metadata vulnerability
    ... When a Safari link is to a zip file with "safe" content (like a movie), ... OS X will open the file, but will run the script. ... This metadata manipulation reminds me of the old Windows trick of using ...
    (comp.sys.mac.apps)
  • Re: Silencing...Complete Post..Comments?
    ... metadata entry which I am always kind of behind the ball w/ on a form. ... As for your not entering metadata and letting the Cantar do ... many jobs, some even without benefit of a script, ...
    (rec.arts.movies.production.sound)
  • Re: Module::Install cant locate required modules
    ... # Define metadata (we read it from the script) ... the perlfunc man page about require and removing the quotes works like ... a charm ... ...
    (comp.lang.perl.misc)