Mohd Mohtashim has Published 238 Articles

Default Autoloading in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 02-Dec-2019 07:42:17

162 Views

Perl offers a feature which you would not find in any other programming languages: a default subroutine. Which means, if you define a function called AUTOLOAD(),  then any calls to undefined subroutines will call AUTOLOAD() function automatically. The name of the missing subroutine is accessible within this subroutine as $AUTOLOAD.Default autoloading ... Read More

Method Overriding in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 02-Dec-2019 07:37:42

435 Views

You can add your additional functions in child class or you can add or modify the functionality of an existing methods in its parent class. It can be done as follows −#!/usr/bin/perl package Employee; use Person; use strict; our @ISA = qw(Person);    # inherits from Person # Override constructor ... Read More

Understanding Inheritance in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 02-Dec-2019 07:35:16

1K+ Views

Object-oriented programming has very good and useful concept called inheritance. Inheritance simply means that properties and methods of a parent class will be available to the child classes. So you don't have to write the same code again and again, you can just inherit a parent class.For example, we can ... Read More

Defining Class Methods in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 02-Dec-2019 07:32:13

465 Views

Other object-oriented languages have the concept of security of data to prevent a programmer from changing an object data directly and they provide accessor methods to modify object data. Perl does not have private variables but we can still use the concept of helper methods to manipulate object data.Lets define ... Read More

Creating and Using Objects using Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 02-Dec-2019 07:29:20

252 Views

To create an instance of a class (an object) we need an object constructor in Perl. This constructor in Perl is a method defined within the package. Most programmers choose to name this object constructor method new, but in Perl you can use any name.You can use any kind of ... Read More

What are Object and Class in Perl?

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 12:18:19

170 Views

There are three main terms, explained from the point of view of how Perl handles objects. The terms are object, class, and method.An object within Perl is merely a reference to a data type that knows what class it belongs to. The object is stored as a reference in a scalar ... Read More

Sending an Attachment with email using Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 12:15:51

2K+ Views

If you want to send an attachment in your email using Perl, then following script serves the purpose −#!/usr/bin/perl use MIME::Lite; $to = 'abcd@gmail.com'; $cc = 'efgh@mail.com'; $from = 'webmaster@yourdomain.com'; $subject = 'Test Email'; $message = 'This is test email sent by Perl Script'; $msg = MIME::Lite-=>new(    From => ... Read More

Sending an HTML Message using Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 12:14:02

643 Views

If you want to send HTML formatted email using sendmail, then you simply need to add Content-type: text/html in the header part of the email as follows −#!/usr/bin/perl $to = 'abcd@gmail.com'; $from = 'webmaster@yourdomain.com'; $subject = 'Test Email'; $message = 'This is test email sent by Perl Script'; open(MAIL, "|/usr/sbin/sendmail -t"); ... Read More

Sending a Plain Message using Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 12:12:41

354 Views

If you are working on Linux/Unix machine then you can simply use sendmail utility inside your Perl program to send email. Here is a sample script that can send an email to a given email ID. Just make sure the given path for sendmail utility is correct. This may be different for ... Read More

The G Assertion in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 12:10:09

345 Views

The \G assertion in Perl allows you to continue searching from the point where the last match occurred. For example, in the following code, we have used \G so that we can search to the correct position and then extract some information, without having to create a more complex, single ... Read More

Advertisements