Skip to content

Instantly share code, notes, and snippets.

@ApexExpress
Created November 21, 2023 17:40
Show Gist options
  • Save ApexExpress/dd271c816cabbad2e1a1260426e9ccda to your computer and use it in GitHub Desktop.
Save ApexExpress/dd271c816cabbad2e1a1260426e9ccda to your computer and use it in GitHub Desktop.
Generally A Perl File
#!/usr/bin/perl
use strict;
use warnings;
# Open the file for reading
my $file_path = "data.txt";
open my $fh, '<', $file_path or die "Could not open file '$file_path' for reading: $!";
# Read and print each line from the file
while (my $line = <$fh>) {
chomp $line; # Remove newline character
print "Line from file: $line\n";
}
# Close the filehandle
close $fh or die "Error closing file '$file_path': $!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment