
FishMonger
Veteran
/ Moderator
Jul 10, 2017, 4:39 PM
Post #4 of 4
(1776 views)
|
Re: [Pshields1984] Perl to create a Column
[In reply to]
|
Can't Post
|
|
There's no need use the dir command to create the file listing. Perl has multiple easy ways to get that list. There also are multiple ways in Perl to create the new file listing. Here is one method using your existing text file, but it's not really how I'd do it myself.
#!/usr/bin/perl use strict; use warnings; use autodie; my $filelist = 'listoffilenames.txt'; my $newlist = 'new_filelist.txt'; open my $in_fh, '<', $filelist; open my $out_fh, '>', $newlist; while (my $filename = <$in_fh>) { chomp $filename; say $out_fh "$filename\tSend This File"; } close $in_fh; close $out_fh; I personally prefer to use full scripts with proper error checking/handling but you could do this as a one-liner just like awk or sed.
(This post was edited by FishMonger on Jul 10, 2017, 4:43 PM)
|