Presentation is loading. Please wait.

Presentation is loading. Please wait.

Online Counseling Resource YCMOU ELearning Drive… School of Architecture, Science and Technology Yashwantrao Chavan Maharashtra Open University, Nashik.

Similar presentations


Presentation on theme: "Online Counseling Resource YCMOU ELearning Drive… School of Architecture, Science and Technology Yashwantrao Chavan Maharashtra Open University, Nashik."— Presentation transcript:

1 Online Counseling Resource YCMOU ELearning Drive… School of Architecture, Science and Technology Yashwantrao Chavan Maharashtra Open University, Nashik – 422222, India

2 OC-SBI083-U01-05 Introduction Programmes and Courses  SBI083-CP1_U01_05

3 School of Science and Technology, Online Counseling Resource… Credits  Academic Inputs by Sonali Alkari MSc (Botany), P.G. D.C. Bio-Informatics sonalisa_alkari@yahoo.com

4 School of Science and Technology, Online Counseling Resource… © 2007, YCMOU. All Rights Reserved.4 How to Use This Resource  Counselor at each study center should use this presentation to deliver lecture of 40-60 minutes during Face-To-Face counseling.  Discussion about students difficulties or tutorial with assignments should follow the lecture for about 40-60 minutes.  Handouts (with 6 slides on each A4 size page) of this presentation should be provided to each student.  Each student should discuss on the discussion forum all the terms which could not be understood. This will improve his writing skills and enhance knowledge level about topics, which shall be immensely useful for end exam.  Appear several times, for all the Self-Tests, available for this course.  Student can use handouts for last minutes preparation just before end exam.

5 School of Science and Technology, Online Counseling Resource… © 2007, YCMOU. All Rights Reserved.5 Learning Objectives  After studying this module, you should be able to: Explain what is list &array? Represent literals. Explain Array variables Explain Array operators and finctions Describe Scalar and list context

6 School of Science and Technology, Online Counseling Resource… Introduction:What Is a List or Array  A list is ordered scalar data. An array is a variable that holds a list.  Each element of the array is a separate scalar variable with an independent scalar value.  These values are ordered; that is, they have a particular sequence from the lowest to the highest element.  Arrays can have any number of elements.  The smallest array has no elements, while the largest array can fill all of available memory.

7 School of Science and Technology, Online Counseling Resource… Literal Representation:1  A list literal (the way you represent the value of a list within your program) consists of comma- separated values enclosed in parentheses.  These values form the elements of the list. For example:  (1,2,3) # array of three values 1, 2, and 3  ("fred",4.5) # two values, "fred" and 4.5  The elements of a list are not necessarily constants; they can be expressions that will be reevaluated each time the literal is used.

8 School of Science and Technology, Online Counseling Resource… Literal Representation:2  For example:  ($a,17); # two values: the current value of $a, and 17($b+$c,$d+$e) # two values  The empty list (one of no elements) is represented by an empty pair of parentheses:  () # the empty list (zero elements)  An item of the list literal can include the list constructor operator, indicated by two scalar values separated by two consecutive periods.

9 School of Science and Technology, Online Counseling Resource… Literal Representation:3  This operator creates a list of values starting at the left scalar value up through the right scalar value, incrementing by one each time.  For example: (1.. 5) # same as (1, 2, 3, 4, 5)  (1.2.. 5.2) # same as (1.2, 2.2, 3.2, 4.2, 5.2)  (2.. 6,10,12) # same as (2,3,4,5,6,10,12)  ($a.. $b) # range determined by current values of $a and $b

10 School of Science and Technology, Online Counseling Resource… Variables:1  An array variable holds a single list value (zero or more scalar values).  Array variable names are similar to scalar variable names, differing only in the initial character, which is an at sign ( @ ) rather than a dollar sign ( $ ).  For example:  @fred # the array variable @fred@A_Very_Long_Array_Variable_Name  @A_Very_Long_Array_Variable_Name_that_is_differe nt

11 School of Science and Technology, Online Counseling Resource… Variables:2  Note that the array variable @fred is unrelated to the scalar variable $fred. Perl maintains separate namespaces for different types of things.  The value of an array variable that has not yet been assigned is (), the empty list.  An expression can refer to array variables as a whole, or it can examine and modify individual elements of the array.

12 School of Science and Technology, Online Counseling Resource… Array Operators and Functions :1  Array functions and operators act on entire arrays.  Some return a list, which can then either be used as a value for another array function, or assigned into an array variable.  Probably the most important array operator is the array assignment operator, which gives an array variable a value.  It is an equal sign, just like the scalar assignment operator.

13 School of Science and Technology, Online Counseling Resource… Array Operators and Functions :2  Perl determines whether the assignment is a scalar assignment or an array assignment by noticing whether the assignment is to a scalar or an array variable. For example:  @fred = (1,2,3); # The fred array gets a three-element literal  @barney = @fred; # now that is copied to @barney  If a scalar value is assigned to an array variable, the scalar value becomes the single element of an array:  @huh = 1; # 1 is promoted to the list (1) automatically

14 School of Science and Technology, Online Counseling Resource… Array Operators and Functions :3  Array variable names may appear in a list literal list. When the value of the list is computed, Perl replaces the names with the current values of the array, like so:  @fred = qw(one two);  @barney = (4,5,@fred,6,7); # @barney becomes # (4,5,"one","two",6,7)  @barney = (8,@barney); # puts 8 in front of @barney  @barney = (@barney,"last");# and a "last" at the end # @barney is now (8,4,5,"one","two",6,7,"last")

15 School of Science and Technology, Online Counseling Resource… Scalar and List Context  As you can see, each operator and function is designed to operate on some specified combination of scalars or lists, and returns either a scalar or a list.  If an operator or function expects an operand to be a scalar, we say that the operand or argument is being evaluated in a scalar context.  Similarly, if an operand or argument is expected to be a list value, we say that it is being evaluated in a list context.

16 School of Science and Technology, Online Counseling Resource… Scalar and List Context  Normally, this is fairly insignificant.  But sometimes you get completely different behavior depending on whether you are within a scalar or a list context.  For example, @fred returns the contents of the @fred array in a list context, but the length of the same array in a scalar context.  These subtleties are mentioned when each operator and function is described.  A scalar value used within a list context is promoted to a single-element array.

17 School of Science and Technology, Online Counseling Resource… What You Learn…  You have learnt : Array –type of scalar varaible Literal representation Array-varaible Array operatorrs and their functions Scalar and list context

18 School of Science and Technology, Online Counseling Resource… Critical Thinking Questions 1.What is list ? 2.Represent Literal with example? © 2007, YCMOU. All Rights Reserved.18

19 School of Science and Technology, Online Counseling Resource… Hints For Critical Thinking Question 1.List-scalar data, array –variable to hold list. 2.Literal representation © 2007, YCMOU. All Rights Reserved.19

20 School of Science and Technology, Online Counseling Resource… Study Tips:Books  Beginning Perl by Simon Cozens, Peter Wainwright. 700 pages. Wrox Press Inc. (May 25, 2000). Beginning Perl  Impatient Perl by Greg London (Feb 7, 2004). Extreme Perl by Robert Nagler Impatient Perl Extreme Perl  MacPerl: Power & Ease by Vicky Brown and Chris Nandor. 372 pages. (1998). MacPerl: Power & Ease  Picking Up Perl by Bradley M. Kuhn and Neil Smyth. self published. second edition. (July 2005). Picking Up Perl

21 School of Science and Technology, Online Counseling Resource… Study Tips:Web Resources www.en.wikipedia.org Microsoft Encarta Encyclopedia http://www.perl.org/ http://en.wikibooks.org/wiki/Programming:Perl_Websites http://cpan.perl.org/

22 School of Science and Technology, Online Counseling Resource… Community Web Sites  Planet Perl - an aggregation of selected perl journals Planet Perl  use Perl; - read community news and personal journals, or start your own journal use Perl;  Perl Monks - the wisdom of the Monks can guide you on your Perl Quests Perl Monks  perl.org - your current location perl.org  the Perl Apprenticeship Site the Perl Apprenticeship Site

23 School of Science and Technology, Online Counseling Resource… End of the Presentation Thank You


Download ppt "Online Counseling Resource YCMOU ELearning Drive… School of Architecture, Science and Technology Yashwantrao Chavan Maharashtra Open University, Nashik."

Similar presentations


Ads by Google