SlideShare ist ein Scribd-Unternehmen logo
1 von 41
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
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.
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
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

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Chapter 08 data file handling
Chapter 08 data file handlingChapter 08 data file handling
Chapter 08 data file handling
 
Input output files in java
Input output files in javaInput output files in java
Input output files in java
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Pearl
PearlPearl
Pearl
 
Unit 1-introduction to perl
Unit 1-introduction to perlUnit 1-introduction to perl
Unit 1-introduction to perl
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Python Session - 2
Python Session - 2Python Session - 2
Python Session - 2
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 
LD_PRELOAD Exploitation - DC9723
LD_PRELOAD Exploitation - DC9723LD_PRELOAD Exploitation - DC9723
LD_PRELOAD Exploitation - DC9723
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experienced
 
ANSI C Macros
ANSI C MacrosANSI C Macros
ANSI C Macros
 
Spsl unit1
Spsl   unit1Spsl   unit1
Spsl unit1
 
Pythonpresent
PythonpresentPythonpresent
Pythonpresent
 
intro unix/linux 08
intro unix/linux 08intro unix/linux 08
intro unix/linux 08
 
ELF
ELFELF
ELF
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Python
 
Turbo prolog 2.0 basics
Turbo prolog 2.0 basicsTurbo prolog 2.0 basics
Turbo prolog 2.0 basics
 

Ähnlich wie web programming Unit VI PPT by Bhavsingh Maloth

Ähnlich wie web programming Unit VI PPT by Bhavsingh Maloth (20)

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
 
Chap1 packages
Chap1 packagesChap1 packages
Chap1 packages
 
Summer Training Project On Python Programming
Summer Training Project On Python ProgrammingSummer Training Project On Python Programming
Summer Training Project On Python Programming
 
Javasession6
Javasession6Javasession6
Javasession6
 
Python Tutorial Part 2
Python Tutorial Part 2Python Tutorial Part 2
Python Tutorial Part 2
 
Oopsinphp
OopsinphpOopsinphp
Oopsinphp
 
Apex code (Salesforce)
Apex code (Salesforce)Apex code (Salesforce)
Apex code (Salesforce)
 
Puppet - The IT automation software
Puppet - The IT automation softwarePuppet - The IT automation software
Puppet - The IT automation software
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Java
JavaJava
Java
 
Learning from "Effective Scala"
Learning from "Effective Scala"Learning from "Effective Scala"
Learning from "Effective Scala"
 
dylibencapsulation
dylibencapsulationdylibencapsulation
dylibencapsulation
 
C++ Introduction brown bag
C++ Introduction brown bagC++ Introduction brown bag
C++ Introduction brown bag
 
Working with files (concepts/pseudocode/python)
Working with files (concepts/pseudocode/python)Working with files (concepts/pseudocode/python)
Working with files (concepts/pseudocode/python)
 
Perl_Part7
Perl_Part7Perl_Part7
Perl_Part7
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
 
Chapter-3 Scoping.pptx
Chapter-3 Scoping.pptxChapter-3 Scoping.pptx
Chapter-3 Scoping.pptx
 
Python Course In Chandigarh
Python Course In ChandigarhPython Course In Chandigarh
Python Course In Chandigarh
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 

Mehr von 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 MalothBhavsingh 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 MALOTHBhavsingh 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 MALOTHBhavsingh 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 MALOTHBhavsingh 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 MALOTHBhavsingh 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 MalothBhavsingh Maloth
 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothBhavsingh Maloth
 
Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Bhavsingh Maloth
 
Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Bhavsingh 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-2012Bhavsingh Maloth
 
Web Programming UNIT VIII notes
Web Programming UNIT VIII notesWeb Programming UNIT VIII notes
Web Programming UNIT VIII notesBhavsingh Maloth
 

Mehr von 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
 
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
 
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
 
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
 
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
 
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
 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh maloth
 
Polytechnic jan 6 2012
Polytechnic jan 6 2012Polytechnic jan 6 2012
Polytechnic jan 6 2012
 
Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007
 
Appsc poly key 2013
Appsc poly key 2013Appsc poly key 2013
Appsc poly key 2013
 
Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007
 
Appsc poly key 2013
Appsc poly key 2013Appsc poly key 2013
Appsc poly key 2013
 
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
 
Unit vii wp ppt
Unit vii wp pptUnit vii wp ppt
Unit vii wp ppt
 
Wp unit III
Wp unit IIIWp unit III
Wp unit III
 
Web Programming UNIT VIII notes
Web Programming UNIT VIII notesWeb Programming UNIT VIII notes
Web Programming UNIT VIII notes
 
Wp unit 1 (1)
Wp  unit 1 (1)Wp  unit 1 (1)
Wp unit 1 (1)
 

Kürzlich hochgeladen

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 

Kürzlich hochgeladen (20)

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 

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
  • 9.
  • 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.
  • 13.
  • 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
  • 22.
  • 23.
  • 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