perl - How to read multiple files from a directory, extract specific strings and ouput to an html file? -
greetings,
i have following code , stuck on how proceed modify ask directory, read files in directory, extract specific strings , ouput html file? in advance.
#!/usr/local/bin/perl use warnings; use strict; use cwd; print "enter filename: "; # should enter directory $perlfile =stdin; open input_file, $perlfile || die "could not open file: $!"; open output, '>out.html' || die "could not open file: $!"; # evaluates file , imports array. @comment_array = ; close(input_file); chomp @comment_array; @comment_array = grep /^\s*#/g, @comment_array; $comment; foreach $comment (@comment_array) { $comment =~ /####/; #pattern match grab #s # prints comments screen print results in html format # writes comments output.html writes results html file } close (output);
take 1 step @ time. have lot planned, far haven't changed prompt string ask directory.
to read entered directory name, your:
my $perlfile =stdin; gives error (under use strict;). start looking error (use diagnostics; automates this) , trying figure out should doing instead.
once can prompt directory name , print out, add code open directory , read directory. directories can opened , read opendir , readdir. make sure can read directory , print out filenames before going on next step.
Comments
Post a Comment