テキストの塊を含む変数があります
$foo = "
Garbage directory
/test/this/is/a/directory
/this/is/another/foo\nThisd is is\nDrop stuff testing\nRandom stuff emacs is great";
正規表現を使用して行を取得するにはどうすればよいですか/test/this/is/a/directory
私はこれを試しました:
my $foo = "
Garbage directory
/test/this/is/a/directory
/this/is/another/foo\nThisd is is\nDrop stuff testing\nRandom stuff emacs is great";
$foo =~ /^\/test.*$/;
print "\n$foo\n";
しかし、これはテキストの塊全体を印刷し続けるだけです。