Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

-type: -f: unknown type

by rickkar (Initiate)
on Oct 30, 2012 at 23:27 UTC ( #1001575=perlquestion: print w/ replies, xml ) Need Help??
rickkar has asked for the wisdom of the Perl Monks concerning the following question:

in running the code below i get

amc-~$ perl test3.pl

find: -type: -f: unknown type

need help in figuring out how to remedy

find: -type: -f: unknown type

#!/usr/bin/perl use strict; use warnings; use 5.010; use LWP::Simple; use File::Find; # for traversing directory and locating a part +icular file use File::Copy; use XML::Simple; # for parsing XML use JSON::Parse; # for parsing JSON format #use Data::Dumper qw(pp); use Data::Dumper; #use Data::Dump qw(pp); my $filepath_root = '/Users/karcichr/Downloads/Elsevier/fulltext/elsev +ier/historical/' || shift @ARGV; for( my @files = qx{find $filepath_root -name 'main.xml' -type -f} ) + # step (1+2) { my $ref = XMLin( $_ ); # step (3) { die "Showing first main.xml xml: ", pp( $ref ); # dump + $ref structure, so to learn where doi/title is } }

Comment on -type: -f: unknown type
Download Code
Re: -type: -f: unknown type
by Anonymous Monk on Oct 30, 2012 at 23:37 UTC

    Why are you using qx instead of File::Find::find()?

    $ find2perl $filepath_root -name main.xml -type -f

    #! c:\perl\5.14.1\bin\MSWin32-x86-multi-thread\perl.exe -w eval 'exec c:\perl\5.14.1\bin\MSWin32-x86-multi-thread\perl.exe -S + $0 ${1+"$@"}' if 0; #$running_under_some_shell use strict; use File::Find (); # Set the variable $File::Find::dont_use_nlink if you're using AFS, # since AFS cheats. # for the convenience of &wanted calls, including -eval statements: use vars qw/*name *dir *prune/; *name = *File::Find::name; *dir = *File::Find::dir; *prune = *File::Find::prune; sub wanted; # Traverse desired filesystems File::Find::find({wanted => \&wanted}, $filepath_root); exit; sub wanted { my ($dev,$ino,$mode,$nlink,$uid,$gid); /^main\.xml\z/s && (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && -f _ && print("$name\n"); }
Re: -type: -f: unknown type
by space_monk (Chaplain) on Oct 31, 2012 at 03:01 UTC
    The simple answer is surely that it should be
    qx{find $filepath_root -name 'main.xml' -type f}
    Note the removal of the '-' before the 'f'. There may be better solutions than making a call to the shell though.....

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1001575]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2014-10-26 09:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (153 votes), past polls