I have a script that runs the iwcmp command and scans all the directories in a workarea for files that are modified. The iwcmp command returns the following output:
[PHP]
f f+ irp_campbells_cbi_a_20130313.pdf
f f+ irp_campbells_cbi_a_20130313.xml
f f+ irp_connect_cti_a_20130313.pdf
f f+ irp_connect_cti_a_20130313.xml
f f+ irp_hammersmith_hag_a_20130313.pdf
f f+ irp_hammersmith_hag_a_20130313.xml
[/PHP]
Then I added the following split function to remove the f f+ :
[PHP] my
@files = split(/[fx]\sf\+\s/,$result); [/PHP]
However now when I run a foreach statement, the perl is not recognizing if files are xml and pdf file type. Am I missing something?
[PHP] foreach $filepath(
@files) {
# check file type
my $ft = File::Type->new();
my $file_type = $ft->mime_type($filepath);
# check if file is xml (octet-stream)
if ($file_type eq 'application/octet-stream') {
#do something}
elsif ($file_type eq 'application/pdf') {
#do something else}
[/PHP]