私がやろうとしているのは、ファイルを開いて1行ずつ読むことです。
正規表現が探しているものを見つけたら、それぞれを@accounts
配列に配置し、画面に出力したいと思います。
結果が出ないのに。ここで単純な間違いを犯しているに違いありませんか?
#!/usr/bin/perl
use strict;
use warnings;
my $line;
my $file;
my $start;
my $end;
my @match;
my @accounts;
print "Enter the file name (example: file.txt): ";
chomp ($file = <STDIN>);
open FILE, $file or die "Cannot open $file read :$!";
while ($line=<FILE>) {
$start = '">';
$end = '</option>';
@match = ($line =~ /$start(.*?)$end/g);
foreach (@match)
{
push @accounts, $_;
print " $_\n ";
}
}