Home: Perl Programming Help: Beginner:
Convert shell head command to Perl



digioleg54
User

Apr 20, 2017, 8:41 AM


Views: 1239
Convert shell head command to Perl

In my CGI script I have

Code
$_ = `head -1 $finfo`;


How can I made this line as Perl? I run it on Apache

Thanks


FishMonger
Veteran / Moderator

Apr 20, 2017, 9:21 AM


Views: 1235
Re: [digioleg54] Convert shell head command to Perl

You need to do it in 2 or 3 statements depending on if you explicitly close the file or not.

1) use the open function to open the file.
2) read the 1st line into your var.
3) (optional) close the file.