Easiest way to open a text file and read it into an array with Perl

前端 未结 8 1651
星月不相逢
星月不相逢 2020-12-14 02:46

Adding a standard Perl file open function to each script I have is a bit annoying:

sub openfile{
    (my $filename) = @_;
    open FILE,\"$filename\" or die          


        
8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 03:11

    that is the famous "slurp mode":

      my @lines =  ;
    

    you may also see Perl Slurp Ease

提交回复
热议问题