Context - PowerPoint PPT Presentation

About This Presentation
Title:

Context

Description:

Context – PowerPoint PPT presentation

Number of Views:16
Avg rating:3.0/5.0
Slides: 6
Provided by: PaulL155
Learn more at: http://www.cs.rpi.edu
Category:
Tags: context | major | manner

less

Transcript and Presenter's Notes

Title: Context


1
Context
2
Context
  • Every operation in Perl is done in a specific
    context.
  • mode, manner, meaning
  • return value of operation can change depending on
    its context
  • Two major contexts Scalar List

3
Scalar Context
  • returns a single value.
  • Anything assigning to a single value is scalar
    context.
  • x fctn()
  • x1 fctn()
  • xfoo fctn()
  • force scalar context by scalar keyword

4
List Context
  • returns list of values
  • assigning to a list (array, slice) is list
    context
  • _at_x (1, 2, 3)
  • _at_x2..4 (4, 5, 6)
  • _at_x1 5

5
context fun
  • arrays evaluated in scalar context produce size
    of array
  • _at_x (4, 8, 12)
  • sizex _at_x
  • sizex gets value 3.
  • print The list _at_x contains . _at_x .
    values.\n
  • The list 4 8 12 contains 3 values.
Write a Comment
User Comments (0)
About PowerShow.com