我正在尝试读取文件并保存以 $path 开头的行,直到它遇到数组中的第一个 balnk 行。我有下面的代码,它只打印路径名而不是行。有人可以看看。
Below are the contents of the $file:
\sbd\archieve\date\form
-rwxrwxrwx 1 etd maadm 4354270 Aug 16 21:56 COMAHCUT.dat.20120816.ftpd.201208162156*
-rw-r--r-- 1 etd maadm 0 Aug 16 21:56 COMAHCUT.DONE.20120816.ftpd.201208162156
\sbd\single\archieve\date\form
-rwxr-xr-x 1 etd maadm 1362780 Aug 15 22:02 COMAINS.dat.ftpd.201208152203*
-rwxr-xr-x 1 etd maadm 0 Aug 15 22:02 COMAINS.DONE.ftpd.201208152203*
Below is the code i tried:
#!/usr/bin/perl
my $file = "/home/pauler/practice/DataIt/line.txt";
open (INFO, $file) or die "Cannot open the file $file :$! \n";
my $path = "\sbd\archieve\date\form";
foreach $line (<INFO>) {
if ($line =~ m/$path/) {
push (@array1, $line);
last if ($line =~ m/^$/);
print @array1;
}
}