I'm rather new to Perl, and I'm having trouble with some simple code:
[php]
$file = 'file_list.txt';
open(INFO, $file);
@files = <INFO>;
close(INFO);
foreach $old_name (@files)
{
print $old_name;
@old_pieces = split(/-/, $old_name);
foreach $piece ($old_pieces)
{
print $piece;
print " ";
# do something useful here...
}
}
[/php]
file_list.txt contains a bunch of file names, like such:
001001-01a-copy_of.dwg
001001-01b-copy_of.dwg
001001-01d-copy_of.dwg
001001-01e-copy_of.dwg
001005-01-copy_of.dwg
What I'm trying to do is split each filename into elements of the array $old_pieces using the dash in the name.
For some reason though, my regex statement doesn't seem to want to match anything in those lines....any ideas? The dash above (/-/) is actually escaped, even though it doesn't show up in the forum- I tried it without too and still no luck.
Thanks