Read a file into an array using Perl

后端 未结 4 1279
情书的邮戳
情书的邮戳 2020-12-31 06:25

I am currently reading a file and storing the data in an array named @lines. Then, I loop through this array using a for loop and inside the loop I

4条回答
  •  抹茶落季
    2020-12-31 07:09

    If you have Perl 5.10 or later, you can use smart matching (~~) :

    my @patterns = (qr/foo/, qr/bar/);
    
    if ($line ~~ @patterns) {
        print "matched\n";  
    }
    

提交回复
热议问题