2014-11-11 4 views
0

이미 존재하지 않는 31 번째 줄의 코드에서 강제로 폴더를 만들 수 있습니까? mkdir 명령을 시도했지만 작동시키지 못했습니다. 나는 또한 하나를 시도했다. 내가 특별히 make_path File::Path를 사용하여 제안 HTML/$ "존재하지 않는 경우 폴더 만들기

use lib '/Users/lialin/perl5/lib/perl5'; 
use strict; use warnings; 
use feature 'say'; 
use File::Slurp 'slurp'; # makes it easy to read files. 
use Mojo; 
use Mojo::UserAgent; 
use URI; 

#my $html_file = "Ask/Agilent_Technologies_ask.html"; # take file from directory 
#my $html_file = shift @ARGV; # take file from command lin 

my $calls_dir = "Ask/"; 
opendir(my $search_dir, $calls_dir) or die "$!\n"; 
my @html_files = grep /\.html$/i, readdir $search_dir; 
closedir $search_dir; 
#print "Got ", scalar @files, " files\n"; 

#my %seen =(); 
foreach my $html_files (@html_files) { 
my %seen =(); 
    my $current_file = $calls_dir . $html_files; 
open my $FILE, '<', $current_file or die "$html_files: $!\n"; 

my $dom = Mojo::DOM->new(scalar slurp $calls_dir .$html_files); 
print $calls_dir .$html_files ; 

#for my $csshref ($dom->find('a[href]')->attr('href')->each) { 
#for my $link ($dom->find('a[href]')->attr('href')->each) { 
# print $1; 
#say $1 #if $link->attr('href') =~ m{^https?://(.+?)/index\.php}s; 
open my $fh, '>', "Ask/Parsed/Html/${html_files}.result.txt" or die $!; 
for my $csshref ($dom->find('a[href]')->attr('href')->each) { 
my $cssurl = URI->new($csshref)->abs($calls_dir .$html_files); 

#open my $fh, '>', "Ask/${html_files}.result.txt" or die $!; 
$fh->print("$html_files\n"); 
$fh->print("$cssurl\n"); 
#$fh->print("\t"."$_\n"); 
#print "$cssurl\n"; 
#print $file."\t"."$_\n"; 

}} 
+1

'\'mkdir -p/path/to/file \'' – Sobrique

답변

1

질문/파싱 /"내 $의 FH를 열고 '>' "()

: 이 내가 이야기하고있는 라인입니다.

mkdir을 사용하여 재귀 함수를 작성할 수도 있지만 문제가되지 않는 것 같습니다.이 모듈은 저에게 잘 돌아갔습니다.

관련 문제