0% found this document useful (0 votes)
35 views

01 Data Types in Perl and Pattern Matching

This document discusses data types and pattern matching in Perl. It introduces Perl as a programming language designed for text processing. The three basic data types in Perl are scalars, arrays of scalars, and hashes of scalars. Scalars can contain single values, arrays are ordered lists of scalars accessed by index, and hashes are unordered key/value pairs. The document also covers pattern matching using regular expressions to search and match patterns in strings.

Uploaded by

Vighnesh Mhatre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

01 Data Types in Perl and Pattern Matching

This document discusses data types and pattern matching in Perl. It introduces Perl as a programming language designed for text processing. The three basic data types in Perl are scalars, arrays of scalars, and hashes of scalars. Scalars can contain single values, arrays are ordered lists of scalars accessed by index, and hashes are unordered key/value pairs. The document also covers pattern matching using regular expressions to search and match patterns in strings.

Uploaded by

Vighnesh Mhatre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

1

DATA TYPES IN PERL


AND
PATTERN MATCHING

M.Sc. - II Bioinformatics
G. N. Khalsa College

5/21/2019
2
CONTENTS

 Introduction
 Basic Data Types
 Scalars
 Arrays of Scalars
 Hashes of Scalars
 Pattern Matching
 References

5/21/2019
3
INTRODUCTION

 Perl is a programming language developed by Larry Wall in


1987, especially designed for processing text.

5/21/2019
4
BASIC DATA TYPES IN PERL

 Perl has three basic data types −


 Scalars
 Arrays of Scalars
 Hashes of Scalars, also known as Associative Arrays

5/21/2019
5

5/21/2019
6
SCALARS

5/21/2019
7

5/21/2019
8
ARRAYS OF SCALARS

5/21/2019
9

5/21/2019
10
HASHES OF SCALARS

5/21/2019
11

5/21/2019
12
PATTERN MATCHING

5/21/2019
Concepts of Regular Expressions

 A regular expression is a string of characters that defines the pattern


or patterns you are viewing.
 Its is often called a pattern in Perl, is a template that either matches
or doesn’t match a given string.
 Example:
$_ = “abcd abbe efghab";
if (/abb/)
{
print "it matched\n";}
 The expression /abb/ looks for the three letter string in
$_; if it finds it, it returns a true value.

 The basic method for applying a regular expression is


to use the pattern binding operators =~ and !~. The
first operator is a test and assignment operator.
 There are three regular expression operators within
Perl.
 Match Regular Expression - m//
 Substitute Regular Expression - s///
 Transliterate Regular Expression - tr///
The Match Operator

 The match operator, m//, 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:
my $bar = "This is foo";
if ($bar =~ /foo/){
print "First time is matching\n";
}else{
print "First time is not matching\n";
}

$bar = "foo";
if ($bar =~ /zoo/){
print "Second time is matching\n";
}else{
print "Second time is not matching\n";
}
17

5/21/2019
18
REFERENCES

5/21/2019
19

THANK YOU!

5/21/2019

You might also like