{"id":3661,"date":"2024-02-24T17:32:05","date_gmt":"2024-02-25T02:32:05","guid":{"rendered":"https:\/\/crm270s.abramjmeister.com\/?p=3661"},"modified":"2024-02-24T17:32:05","modified_gmt":"2024-02-25T02:32:05","slug":"combine_text-pl","status":"publish","type":"post","link":"https:\/\/crm270s.mycpamytax.com\/?p=3661","title":{"rendered":"combine_text.pl"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">combines from list of file names in combine.txt:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/perl\n\nuse strict;\nuse warnings;\nuse File::Spec;\n\n# Assume the current directory contains this script, combine.txt, and the files to be combined\nmy $folder_path = File::Spec->rel2abs('.');\n\n# File containing the list of filenames to combine\nmy $list_file = \"$folder_path\/combine.txt\"; # Path to combine.txt in the same folder\n\n# Output file where the combined content will be stored\nmy $output_file = \"$folder_path\/combined_output_02.txt\"; # Output file in the same folder\n\n# Clear the contents of the output file before appending new content\nopen(my $clear_fh, '>', $output_file) or die \"Cannot open $output_file for writing: $!\";\nclose($clear_fh);\n\n# Open the output file for appending\nopen(my $out_fh, '>>', $output_file) or die \"Cannot open $output_file for appending: $!\";\n\n# Open and read the list file containing the filenames to combine\nopen(my $list_fh, '&lt;', $list_file) or die \"Cannot open $list_file for reading: $!\";\nmy @files_to_combine = &lt;$list_fh>;\nchomp(@files_to_combine); # Remove newline characters from each filename\nclose($list_fh);\n\n# Iterate through each file listed in combine.txt, read its content, and append to the output file\nforeach my $file (@files_to_combine) {\n    my $file_path = \"$folder_path\/$file\"; # Construct the full path for each file\n    open(my $in_fh, '&lt;', $file_path) or die \"Cannot open $file_path for reading: $!\";\n    while (my $line = &lt;$in_fh>) {\n        print $out_fh $line; # Append the content of the file to the output file\n    }\n    close($in_fh);\n}\n\n# Close the output file handle\nclose($out_fh);\n\nprint \"Combined files listed in $list_file into $output_file\\n\";\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>combines from list of file names in combine.txt:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[26,42],"tags":[],"class_list":["post-3661","post","type-post","status-publish","format-standard","hentry","category-codes","category--yellowpage"],"_links":{"self":[{"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=\/wp\/v2\/posts\/3661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3661"}],"version-history":[{"count":0,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=\/wp\/v2\/posts\/3661\/revisions"}],"wp:attachment":[{"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}