SlideShare a Scribd company logo
UNIT VI
Perl file system
Perl file system
• Perl File Handling: open, read, write and close files
• Opening files:
• Observation :
 here File Handles is associate with file, u can use the
filehandle to read from the file.
 If the file doesn't exist - or you cannot read it for any
other reason - then the script will die with the
appropriate error message stored in the $! variable.
• if you wanted to modify the file
• Then you'd have to specify the appropriate
mode using the three-argument form of open.
Notice, how both +< and +> open the file in read/write mode
Reading files
• If you want to read a text file line-by-line then
you can do it as such:
Writing files
File Close
Eval
• Perl eval built-in function is very powerful
• The general form of perl eval expects a
expression or a block of code as an argument.

Return Value
This function returns value of last evaluated statement in EXPR or BLOCK
web programming Unit VI PPT  by Bhavsingh Maloth
Advantages of Eval
• trapping errors using eval
• create dynamic code using eval
• insert a code from a file/sub-routine using
eval
Perl eval can’t catch following errors:
• Uncaught signal
• Running out of memory
• Syntax errors
Perl Eval Error Handling – Trapping
Errors
• Eval is used to trap the errors. During the
execution of the subroutine the program
might die because of errors, or external calling
of die function.

In the above, $count contains the value as 0. When we run the code without the
eval block, the program gets exit.
During this time, if the block of perl code is executed inside the eval, then program
continues to run even after the die or errors, and it also captures the errors or
dieing words.
web programming Unit VI PPT  by Bhavsingh Maloth
Perl Packages
• A package is a collection of code which lives in
its own namespace
• A namespace is a named collection of unique
variable names (also called a symbol table).
• Namespaces prevent variable name collisions
between packages
• Packages enable the construction of modules
The Package Statement
• package statement switches the current
naming context to a specified namespace
(symbol table)
• If the named package does not exists, a new
namespace is first created.
• The package stays in effect until either
another package statement is invoked, or until
the end of the end of the current block or file.
• You can explicitly refer to variables within a
package using the :: package qualifier
BEGIN and END Blocks
• BEGIN and END Blocks
• You may define any number of code blocks
named BEGIN and END which act as constructors
and destructors respectively.
• Every BEGIN block is executed after the perl
script is loaded and compiled but before any
other statement is executed
• Every END block is executed just before the perl
interpreter exits.
• The BEGIN and END blocks are particularly useful
when creating Perl modules.
Perl Modules
• Modules : library functions

• A module is a .pm file that defines a library of
related functions
• Modules are conceptually similar to oldfashioned Perl libraries (.pl files), but have a
cleaner implementation
– Selective collection of namespace
– simpler function invocation
How to use a Module
Module and main program
Hello1.pm
package Hello1;
sub greet {
return "Hello, World!";
}
1;

test1.pl
#!/usr/bin/perl
use Hello1;
print Hello1::greet();
Module structure
package Hello1;
sub greet {
return "Hello, World!n";
}
1;

Declare a package; file must
be saved as Hello.pm
Contents of the package:
functions, and variables.

Return a true value at end
web programming Unit VI PPT  by Bhavsingh Maloth
web programming Unit VI PPT  by Bhavsingh Maloth
Object Oriented in Perl
• Object Basics
• There are three main terms, they are object,
class, and method.
Objects
• an object is only a reference to a data type
that knows what class it belongs to.
• The object is stored as a reference in a scalar
variable. Because a scalar only contains a
reference to the object, the same scalar can
hold different objects in different classes.
class

• A class within Perl is a package that contains the
corresponding methods required to create and
manipulate objects.
• Methods:
• A method within Perl is a subroutine, defined with
the package. The first argument to the method is
an object reference or a package name,
depending on whether the method affects the
current object or the class.
• Perl provides a bless() function which is used to
return a reference and which becomes an object.
Defining a Class
• a class is corresponds to a Package.
• To create a class in Perl, we first build a package.
• A package is a self-contained unit of user-defined
variables and subroutines, which can be re-used
over and over again.
• They provide a separate namespace within a Perl
program that keeps subroutines and variables
from conflicting with those in other packages.
• To declare a class named Person in Perl we
do:
package Person;
Note:
The scope of the package definition extends to
the end of the file, or until another package
keyword is encountered.
Creating and Using Objects
• To create an object, we need object
constructor.
• This constructor is a method defined within
the package.
• Most programmers choose to name this
object constructor method new, but in Perl
one can use any name.
methods
• A method is a means by which an object's
data is accessed or modified.
• In Perl, a method is just a subroutine defined
within a particular package.
• So to define a method to print our Person
object, we do:
• The subroutine print is now associated with
the package Person.
• To call the method print on a Person object,
we use the Perl "arrow" notation.
Object creation
• To create an object,we need an object
constructor
• This constructor is a method defined within
the package.
• What have we done? We created a subroutine
called new associated with the package Person.
• The entries of the hash reference $self become
the attributes of our object.
• We then use the bless function on the hash
reference.
• The bless function takes two arguments: a
reference to the variable to be marked and a
string containing the name of the class.
• This indicates that the variable now belongs to
the class Person.
Interfacing to the operating system
• The Perl interface allows you to create Perl
scripts that can read the accounting files
produced by the exacct framework.
• You can also create Perl scripts that write
exacct files.
Creating internet ware applications
• Internet provides a global open infrastructure
for exchanging and sharing of various
resources for the people all over the world.
• The rapid development and the wide
application of Internet make it become a new
mainstream platform for software to be used,
developed, deployed and executed. With the
vision of “Internet as computer”,
• many application styles such as pervasive
computing, grid computing, service computing
and cloud computing occur on this open and
dynam
• in order to adapt the software system to such a
new environment, its structure model should
be autonomous, cooperative, situational,
evolvable, emergent, trustworthy,ic
environment.
• Internetware system is able to identify the changes
of open and dynamic environment such as Internet,
respond to the changes in the way of architectural
transformation, and exhibit context-aware, adaptive
and trustworthy behaviors in the open and dynamic
environment in order to meet its flexible design
objectives.
• Internetware challenges many aspects of software
technologies, from operating platforms,
programming models, to engineering approaches
web programming Unit VI PPT  by Bhavsingh Maloth
web programming Unit VI PPT  by Bhavsingh Maloth
web programming Unit VI PPT  by Bhavsingh Maloth
Ad

More Related Content

What's hot (20)

Chapter 08 data file handling
Chapter 08 data file handlingChapter 08 data file handling
Chapter 08 data file handling
Praveen M Jigajinni
 
Input output files in java
Input output files in javaInput output files in java
Input output files in java
Kavitha713564
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
Sasidhar Kothuru
 
Pearl
PearlPearl
Pearl
Naga Dinesh
 
Unit 1-introduction to perl
Unit 1-introduction to perlUnit 1-introduction to perl
Unit 1-introduction to perl
sana mateen
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
Kavitha713564
 
Python Session - 2
Python Session - 2Python Session - 2
Python Session - 2
AnirudhaGaikwad4
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
Emertxe Information Technologies Pvt Ltd
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
BMS Institute of Technology and Management
 
LD_PRELOAD Exploitation - DC9723
LD_PRELOAD Exploitation - DC9723LD_PRELOAD Exploitation - DC9723
LD_PRELOAD Exploitation - DC9723
Iftach Ian Amit
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experienced
zynofustechnology
 
ANSI C Macros
ANSI C MacrosANSI C Macros
ANSI C Macros
Srikrishnan Suresh
 
Spsl unit1
Spsl   unit1Spsl   unit1
Spsl unit1
Sasidhar Kothuru
 
Pythonpresent
PythonpresentPythonpresent
Pythonpresent
Chui-Wen Chiu
 
intro unix/linux 08
intro unix/linux 08intro unix/linux 08
intro unix/linux 08
duquoi
 
ELF
ELFELF
ELF
Koganti Ravikumar
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
tanmaymodi4
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
Hamid Ghorbani
 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Python
didip
 
Turbo prolog 2.0 basics
Turbo prolog 2.0 basicsTurbo prolog 2.0 basics
Turbo prolog 2.0 basics
Soham Kansodaria
 

Similar to web programming Unit VI PPT by Bhavsingh Maloth (20)

Introduction to PHP and MySql basics.pptx
Introduction to PHP and MySql basics.pptxIntroduction to PHP and MySql basics.pptx
Introduction to PHP and MySql basics.pptx
PriyankaKupneshi
 
UNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year csUNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year cs
javed75
 
File handle in PROGRAMMable extensible interpreted .pptx
File handle in PROGRAMMable extensible interpreted .pptxFile handle in PROGRAMMable extensible interpreted .pptx
File handle in PROGRAMMable extensible interpreted .pptx
urvashipundir04
 
Object oriented programming design and implementation
Object oriented programming design and implementationObject oriented programming design and implementation
Object oriented programming design and implementation
afsheenfaiq2
 
Object oriented programming design and implementation
Object oriented programming design and implementationObject oriented programming design and implementation
Object oriented programming design and implementation
afsheenfaiq2
 
Chap1 packages
Chap1 packagesChap1 packages
Chap1 packages
raksharao
 
Summer Training Project On Python Programming
Summer Training Project On Python ProgrammingSummer Training Project On Python Programming
Summer Training Project On Python Programming
KAUSHAL KUMAR JHA
 
Javasession6
Javasession6Javasession6
Javasession6
Rajeev Kumar
 
Python Tutorial Part 2
Python Tutorial Part 2Python Tutorial Part 2
Python Tutorial Part 2
Haitham El-Ghareeb
 
An introduction to PHP : PHP and Using PHP, Variables Program control and Bui...
An introduction to PHP : PHP and Using PHP, Variables Program control and Bui...An introduction to PHP : PHP and Using PHP, Variables Program control and Bui...
An introduction to PHP : PHP and Using PHP, Variables Program control and Bui...
Vigneshkumar Ponnusamy
 
Oopsinphp
OopsinphpOopsinphp
Oopsinphp
NithyaNithyav
 
Apex code (Salesforce)
Apex code (Salesforce)Apex code (Salesforce)
Apex code (Salesforce)
Mohammed Safwat Abu Kwaik
 
Puppet - The IT automation software
Puppet - The IT automation softwarePuppet - The IT automation software
Puppet - The IT automation software
agenedy
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
AnsgarMary
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
baabtra.com - No. 1 supplier of quality freshers
 
Python programming Concepts (Functions, classes and Oops concept
Python programming Concepts (Functions, classes and Oops conceptPython programming Concepts (Functions, classes and Oops concept
Python programming Concepts (Functions, classes and Oops concept
Lipika Sharma
 
Java
JavaJava
Java
nirbhayverma8
 
Class and Objects in python programming.pptx
Class and Objects in python programming.pptxClass and Objects in python programming.pptx
Class and Objects in python programming.pptx
Rajtherock
 
Learning from "Effective Scala"
Learning from "Effective Scala"Learning from "Effective Scala"
Learning from "Effective Scala"
Kazuhiro Sera
 
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
PYTHON  OBJECT-ORIENTED PROGRAMMING.pptxPYTHON  OBJECT-ORIENTED PROGRAMMING.pptx
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
hpearl130
 
Introduction to PHP and MySql basics.pptx
Introduction to PHP and MySql basics.pptxIntroduction to PHP and MySql basics.pptx
Introduction to PHP and MySql basics.pptx
PriyankaKupneshi
 
UNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year csUNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year cs
javed75
 
File handle in PROGRAMMable extensible interpreted .pptx
File handle in PROGRAMMable extensible interpreted .pptxFile handle in PROGRAMMable extensible interpreted .pptx
File handle in PROGRAMMable extensible interpreted .pptx
urvashipundir04
 
Object oriented programming design and implementation
Object oriented programming design and implementationObject oriented programming design and implementation
Object oriented programming design and implementation
afsheenfaiq2
 
Object oriented programming design and implementation
Object oriented programming design and implementationObject oriented programming design and implementation
Object oriented programming design and implementation
afsheenfaiq2
 
Chap1 packages
Chap1 packagesChap1 packages
Chap1 packages
raksharao
 
Summer Training Project On Python Programming
Summer Training Project On Python ProgrammingSummer Training Project On Python Programming
Summer Training Project On Python Programming
KAUSHAL KUMAR JHA
 
An introduction to PHP : PHP and Using PHP, Variables Program control and Bui...
An introduction to PHP : PHP and Using PHP, Variables Program control and Bui...An introduction to PHP : PHP and Using PHP, Variables Program control and Bui...
An introduction to PHP : PHP and Using PHP, Variables Program control and Bui...
Vigneshkumar Ponnusamy
 
Puppet - The IT automation software
Puppet - The IT automation softwarePuppet - The IT automation software
Puppet - The IT automation software
agenedy
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
AnsgarMary
 
Python programming Concepts (Functions, classes and Oops concept
Python programming Concepts (Functions, classes and Oops conceptPython programming Concepts (Functions, classes and Oops concept
Python programming Concepts (Functions, classes and Oops concept
Lipika Sharma
 
Class and Objects in python programming.pptx
Class and Objects in python programming.pptxClass and Objects in python programming.pptx
Class and Objects in python programming.pptx
Rajtherock
 
Learning from "Effective Scala"
Learning from "Effective Scala"Learning from "Effective Scala"
Learning from "Effective Scala"
Kazuhiro Sera
 
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
PYTHON  OBJECT-ORIENTED PROGRAMMING.pptxPYTHON  OBJECT-ORIENTED PROGRAMMING.pptx
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
hpearl130
 
Ad

More from Bhavsingh Maloth (17)

web programming Unit VIII complete about python by Bhavsingh Maloth
web programming Unit VIII complete about python  by Bhavsingh Malothweb programming Unit VIII complete about python  by Bhavsingh Maloth
web programming Unit VIII complete about python by Bhavsingh Maloth
Bhavsingh Maloth
 
Web programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTH
Web programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTHWeb programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTH
Web programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh Maloth
Bhavsingh Maloth
 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh maloth
Bhavsingh Maloth
 
Polytechnic jan 6 2012
Polytechnic jan 6 2012Polytechnic jan 6 2012
Polytechnic jan 6 2012
Bhavsingh Maloth
 
Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007
Bhavsingh Maloth
 
Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007
Bhavsingh Maloth
 
98286173 government-polytechnic-lecturer-exam-paper-2012
98286173 government-polytechnic-lecturer-exam-paper-201298286173 government-polytechnic-lecturer-exam-paper-2012
98286173 government-polytechnic-lecturer-exam-paper-2012
Bhavsingh Maloth
 
Unit vii wp ppt
Unit vii wp pptUnit vii wp ppt
Unit vii wp ppt
Bhavsingh Maloth
 
Wp unit III
Wp unit IIIWp unit III
Wp unit III
Bhavsingh Maloth
 
Web Programming UNIT VIII notes
Web Programming UNIT VIII notesWeb Programming UNIT VIII notes
Web Programming UNIT VIII notes
Bhavsingh Maloth
 
Wp unit 1 (1)
Wp  unit 1 (1)Wp  unit 1 (1)
Wp unit 1 (1)
Bhavsingh Maloth
 
web programming Unit VIII complete about python by Bhavsingh Maloth
web programming Unit VIII complete about python  by Bhavsingh Malothweb programming Unit VIII complete about python  by Bhavsingh Maloth
web programming Unit VIII complete about python by Bhavsingh Maloth
Bhavsingh Maloth
 
Web programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTH
Web programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTHWeb programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTH
Web programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh Maloth
Bhavsingh Maloth
 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh maloth
Bhavsingh Maloth
 
Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007
Bhavsingh Maloth
 
Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007
Bhavsingh Maloth
 
98286173 government-polytechnic-lecturer-exam-paper-2012
98286173 government-polytechnic-lecturer-exam-paper-201298286173 government-polytechnic-lecturer-exam-paper-2012
98286173 government-polytechnic-lecturer-exam-paper-2012
Bhavsingh Maloth
 
Web Programming UNIT VIII notes
Web Programming UNIT VIII notesWeb Programming UNIT VIII notes
Web Programming UNIT VIII notes
Bhavsingh Maloth
 
Ad

Recently uploaded (20)

Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 

web programming Unit VI PPT by Bhavsingh Maloth

  • 2. Perl file system • Perl File Handling: open, read, write and close files • Opening files: • Observation :  here File Handles is associate with file, u can use the filehandle to read from the file.  If the file doesn't exist - or you cannot read it for any other reason - then the script will die with the appropriate error message stored in the $! variable.
  • 3. • if you wanted to modify the file • Then you'd have to specify the appropriate mode using the three-argument form of open.
  • 4. Notice, how both +< and +> open the file in read/write mode
  • 5. Reading files • If you want to read a text file line-by-line then you can do it as such:
  • 8. Eval • Perl eval built-in function is very powerful • The general form of perl eval expects a expression or a block of code as an argument. Return Value This function returns value of last evaluated statement in EXPR or BLOCK
  • 10. Advantages of Eval • trapping errors using eval • create dynamic code using eval • insert a code from a file/sub-routine using eval Perl eval can’t catch following errors: • Uncaught signal • Running out of memory • Syntax errors
  • 11. Perl Eval Error Handling – Trapping Errors • Eval is used to trap the errors. During the execution of the subroutine the program might die because of errors, or external calling of die function. In the above, $count contains the value as 0. When we run the code without the eval block, the program gets exit.
  • 12. During this time, if the block of perl code is executed inside the eval, then program continues to run even after the die or errors, and it also captures the errors or dieing words.
  • 14. Perl Packages • A package is a collection of code which lives in its own namespace • A namespace is a named collection of unique variable names (also called a symbol table). • Namespaces prevent variable name collisions between packages • Packages enable the construction of modules
  • 15. The Package Statement • package statement switches the current naming context to a specified namespace (symbol table) • If the named package does not exists, a new namespace is first created.
  • 16. • The package stays in effect until either another package statement is invoked, or until the end of the end of the current block or file. • You can explicitly refer to variables within a package using the :: package qualifier
  • 17. BEGIN and END Blocks • BEGIN and END Blocks • You may define any number of code blocks named BEGIN and END which act as constructors and destructors respectively. • Every BEGIN block is executed after the perl script is loaded and compiled but before any other statement is executed • Every END block is executed just before the perl interpreter exits. • The BEGIN and END blocks are particularly useful when creating Perl modules.
  • 18. Perl Modules • Modules : library functions • A module is a .pm file that defines a library of related functions • Modules are conceptually similar to oldfashioned Perl libraries (.pl files), but have a cleaner implementation – Selective collection of namespace – simpler function invocation
  • 19. How to use a Module
  • 20. Module and main program Hello1.pm package Hello1; sub greet { return "Hello, World!"; } 1; test1.pl #!/usr/bin/perl use Hello1; print Hello1::greet();
  • 21. Module structure package Hello1; sub greet { return "Hello, World!n"; } 1; Declare a package; file must be saved as Hello.pm Contents of the package: functions, and variables. Return a true value at end
  • 24. Object Oriented in Perl • Object Basics • There are three main terms, they are object, class, and method.
  • 25. Objects • an object is only a reference to a data type that knows what class it belongs to. • The object is stored as a reference in a scalar variable. Because a scalar only contains a reference to the object, the same scalar can hold different objects in different classes.
  • 26. class • A class within Perl is a package that contains the corresponding methods required to create and manipulate objects. • Methods: • A method within Perl is a subroutine, defined with the package. The first argument to the method is an object reference or a package name, depending on whether the method affects the current object or the class. • Perl provides a bless() function which is used to return a reference and which becomes an object.
  • 27. Defining a Class • a class is corresponds to a Package. • To create a class in Perl, we first build a package. • A package is a self-contained unit of user-defined variables and subroutines, which can be re-used over and over again. • They provide a separate namespace within a Perl program that keeps subroutines and variables from conflicting with those in other packages.
  • 28. • To declare a class named Person in Perl we do: package Person; Note: The scope of the package definition extends to the end of the file, or until another package keyword is encountered.
  • 29. Creating and Using Objects • To create an object, we need object constructor. • This constructor is a method defined within the package. • Most programmers choose to name this object constructor method new, but in Perl one can use any name.
  • 30. methods • A method is a means by which an object's data is accessed or modified. • In Perl, a method is just a subroutine defined within a particular package. • So to define a method to print our Person object, we do:
  • 31. • The subroutine print is now associated with the package Person. • To call the method print on a Person object, we use the Perl "arrow" notation.
  • 32. Object creation • To create an object,we need an object constructor • This constructor is a method defined within the package.
  • 33. • What have we done? We created a subroutine called new associated with the package Person. • The entries of the hash reference $self become the attributes of our object. • We then use the bless function on the hash reference. • The bless function takes two arguments: a reference to the variable to be marked and a string containing the name of the class. • This indicates that the variable now belongs to the class Person.
  • 34. Interfacing to the operating system • The Perl interface allows you to create Perl scripts that can read the accounting files produced by the exacct framework. • You can also create Perl scripts that write exacct files.
  • 35. Creating internet ware applications
  • 36. • Internet provides a global open infrastructure for exchanging and sharing of various resources for the people all over the world. • The rapid development and the wide application of Internet make it become a new mainstream platform for software to be used, developed, deployed and executed. With the vision of “Internet as computer”,
  • 37. • many application styles such as pervasive computing, grid computing, service computing and cloud computing occur on this open and dynam • in order to adapt the software system to such a new environment, its structure model should be autonomous, cooperative, situational, evolvable, emergent, trustworthy,ic environment.
  • 38. • Internetware system is able to identify the changes of open and dynamic environment such as Internet, respond to the changes in the way of architectural transformation, and exhibit context-aware, adaptive and trustworthy behaviors in the open and dynamic environment in order to meet its flexible design objectives. • Internetware challenges many aspects of software technologies, from operating platforms, programming models, to engineering approaches