Second Perl Scripting – Making Subroutine

#!/usr/bin/perl
use utf8;
use strict;
use warnings; 
#the simplest subroutine form.
sub subroutine
{
	print ("made a subroutine.","\n");
}
#call the subroutine.
subroutine();

#make procedures to output all text of the input file.
#next make these procedures to one subroutine.
#define input text's path.
my $inputtxt="/home/ComputerProgramming_Home/PERL/hi.pl";
#construct file handler $in using open() function.
open(our $in,"<",$inputtxt);#our keyword means global variable
#use <> symbol.
#this means null file handle.
#<$in> means make file handler using $in file path which is opened by open() above.
our $line=<$in>;

#debris code of previous test code.
#print ($line);
#$line=<$in>;
#print ($line);
#for(my $i=0;$i<10;$i++)

#finally, will use eof(End Of File) function of perl.
#this returns 1, if reached to the end of the file.
while(eof($in)!=1)
{
	$line=<$in>;
	print ($line);
}
print ("file end...");

One thought on “Second Perl Scripting – Making Subroutine

Leave a comment