Perl Tutorial - Practical Extraction and Reporting Language (Perl)

Please leave a remark at the bottom of each page with your useful suggestion.

Table of Contents

  1. Perl Introduction
  2. Perl Program Startup
  3. Perl Regular Expressions
  4. Perl Array Program
  5. Perl Basic Program
  6. Perl Subroutine / Function Program
  7. Perl XML Program
  8. Perl String Program
  9. Perl Statement Program
  10. Perl Network Program
  11. Perl Hash Program
  12. Perl File Handling Program
  13. Perl Data Type Program
  14. Perl Database Program
  15. Perl Class Program
  16. Perl CGI Program
  17. Perl GUI Program
  18. Perl Report Program

Perl Programming Solution

Using Net::FTP to get a file on the server

use Net::FTP;

$ftp = Net::FTP-> new("", Timeout => 30)
		or die "Could not connect.\n";

$username = "anonymous";
$password = "asdf";

$ftp->login($username, $password)
		or die "Could not log in.\n";


$remotefile = "CPAN.html";
$localfile = "file.txt";

$ftp->get($remotefile, $localfile)
		or die "Can not get file.\n";

File Read

call ../filename.xml

use strict;
use File::Basename;
my ($infile) = @ARGV;
my ($file,$dir,$ext) = fileparse($infile, qr/\..*/);
my $outfile = "$dir/$file\_out$ext";

open(IN,"<", "$infile") or die "doesn’t find $file $!"; 
undef $/; my $data = <IN>; close(IN);


open (OUT, ">","$outfile");
print OUT $data;

Functions Subroutine

# Type-1


	sub CleanUP()
	my ($infile,$fdir,$fname) = @_;
	$data =~s/a/b/sgi;
# Type-2

	sub TabCol()
	my $txtdoll=shift;

Write Your Comments or Suggestion...