Mohd Mohtashim has Published 251 Articles

Sending an HTML Message using Perl

Mohd Mohtashim

Mohd Mohtashim

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

511 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

226 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

244 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

Grouping Matching in Perl

Mohd Mohtashim

Mohd Mohtashim

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

1K+ Views

From a regular-expression point of view in Perl, there is no difference between the following two expressions except that the former is slightly clearer.$string =~ /(\S+)\s+(\S+)/; and $string =~ /\S+\s+\S+/;However, the benefit of grouping is that it allows us to extract a sequence from a regular expression. Groupings are returned ... Read More

Matching Boundaries & Selecting Alternatives in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 12:04:17

218 Views

Matching Boundaries in PerlThe \b matches at any word boundary in Perl, as defined by the difference between the \w class and the \W class. Because \w includes the characters for a word, and \W the opposite, this normally means the termination of a word. The \B assertion matches any position that is not ... Read More

The Translation Operator in Perl

Mohd Mohtashim

Mohd Mohtashim

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

555 Views

Translation is similar, but not identical, to the principles of substitution in Perl, but unlike substitution, translation (or transliteration) does not use regular expressions for its search on replacement values. The translation operators are −tr/SEARCHLIST/REPLACEMENTLIST/cds y/SEARCHLIST/REPLACEMENTLIST/cdsThe translation replaces all occurrences of the characters in SEARCHLIST with the corresponding characters in ... Read More

The Substitution Operator in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 12:00:43

2K+ Views

The substitution operator s/// in Perl is really just an extension of the match operator that allows you to replace the text matched with some new text. The basic form of the operator is −s/PATTERN/REPLACEMENT/;The PATTERN is the regular expression for the text that we are looking for. The REPLACEMENT ... Read More

Matching Only Once in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 11:58:55

204 Views

There is a simpler version of the match operator in Perl - the ?PATTERN? operator. This is basically identical to the m// operator except that it only matches once within the string you are searching between each call to reset.For example, you can use this to get the first and ... Read More

The Match Operator in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 11:57:31

1K+ Views

The match operator m// in Perl, is used to match a string or statement to a regular expression. For example, to match the character sequence "foo" against the scalar $bar, you might use a statement like this −Example Live Demo#!/usr/bin/perl $bar = "This is foo and again foo"; if ($bar =~ ... Read More

Filehandle Special Variables in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 11:55:01

188 Views

There are various File Handle related Special Variables in Perl. We have listed them in different below in tabular form:$|If set to nonzero, forces an fflush(3) after every write or print on the currently selected output channel.$OUTPUT_AUTOFLUSH$%The current page number of the currently selected output channel.$FORMAT_PAGE_NUMBER$=The current page length (printable ... Read More

Advertisements