这是一种固定格式,当我在记事本或 Ultraedit 中打开时,您会看到这种格式。这只是一些示例数据,但我的文本文件有大约 200,000 行和多个目录,就像您在示例中看到的那样。所以基本上我试图附加你看到的路径,它说“V目录:\ word”并将“V:\ word”添加到行尾并将其复制下来,直到它看到新的“目录V:\word\excels" 并在事实之后添加 "V:\word\excels",依此类推。你能帮帮我,可能给狗扔骨头吗?谢谢,非常感谢!
Directory of V:\word
04/30/2007 11:49 AM 938,458 BUILTIN\Admin Filename.pdf
04/06/2012 01:13 PM 3,801 AMERICAS\DoeJ Filename3.pdf
01/11/2007 12:05 PM 26,624 BUILTIN\Admin Filename2.doc
08/01/2007 11:57 AM 18,432 BUILTIN\Admin Filename5.xls
Directory of V:\word\excels
03/03/2010 10:42 AM 35,840 AMERICAS\DavisF Billing3-3.xls
02/24/2010 10:31 AM 34,380 AMERICAS\StewartF Allie2-24.xls
这就是我想要完成的
Directory of V:\word
04/30/2007 11:49 AM 938,458 BUILTIN\Admin Filename.pdf V:\word
04/06/2012 01:13 PM 3,801 AMERICAS\DoeJ Filename3.pdf V:\word
01/11/2007 12:05 PM 26,624 BUILTIN\Admin Filename2.doc V:\word
08/01/2007 11:57 AM 18,432 BUILTIN\Admin Filename5.xls V:\word
Directory of V:\word\excels
03/03/2010 10:42 AM 35,840 AMERICAS\DavisF Billing3-3.xls V:\word\excels
02/24/2010 10:31 AM 34,380 AMERICAS\StewartF Allie.xls V:\word\excels
这就是我在 perl 中所拥有的:我仍然陷入困境,但我认为我正在取得一些进展。
#!/usr/bin/perl
use strict
use warnings
use autodie
open (MYFILE, 'List.txt');
my $str = " Directory of V:\word";
while (<MYFILE>)
{
chomp;
($Date, $Time, $Size, $User, $Filename) = split("\t");
print $Date, $Time, $Size, $User, $Filename, substr $str,14;
print "$_\n";
}
close (MYFILE);