Presentation is loading. Please wait.

Presentation is loading. Please wait.

Scripting Languages ● Perl, Python, Unix Shell, VB, JavaScript, etc. ● Glue Languages. ● Typeless. ● Interchangeable Code and Data. ● Interpreted vs. Compiled.

Similar presentations


Presentation on theme: "Scripting Languages ● Perl, Python, Unix Shell, VB, JavaScript, etc. ● Glue Languages. ● Typeless. ● Interchangeable Code and Data. ● Interpreted vs. Compiled."— Presentation transcript:

1 Scripting Languages ● Perl, Python, Unix Shell, VB, JavaScript, etc. ● Glue Languages. ● Typeless. ● Interchangeable Code and Data. ● Interpreted vs. Compiled. ● Rapid Prototyping and short development time. ● Sacrifice execution speed. ● Symbiotic with system programming languages.

2

3 Rise in importance ● GUIs, Internet, Component frameworks ● Advance in scripting technology (JCL -> Perl) ● Machine speeds are rising (2x every 18 months) ● Change in programming community Arguments for and against are common: So, lets re-enact this over the mailing list !

4 Perl ● Initially designed as a glue for Unix. ● A text processor. ● Free, simple, flexible and loaded with features. ● Compiled and Interpreted.

5 Singulars and Plurals ● Scalars $ident holds a single value. ● Array @ident keyed by number ● Hash%identunordered, keyed by string ● Subroutine&identCallable chunk of code ● Typeglob*ident anything!

6 $mynum = 45; $realnum = 5.6677; $scinum = 3.44e2; $mystr = “string”; $inter = “interpolated $mystr”; $noint = 'no interpolation with $mystr'; $expr = $realnum * $scinum; $stroutput = `ls`; print '123' + 1, “\n”; 124 print '123' + 1, '\n'; 124\n

7 Arrays @nums = (“one”, “two”, “three”); $nums[0] = “one”; $nums[1] = “two”; $nums[2] = “three”; ($num1, $num2, $num3) = @nums; rearranged order ($n1, $n2, $n3) = ($num2, $num3,$num1);

8 Hashes %daysof week = (“Sun”, “Sunday”, “Mon”, “Monday”,..., “Sat”, “Saturday”); %daysof week = ( “Sun” => “Sunday”, “Mon” => “Monday”,..., “Sat” => “Saturday”); $longday{“Tue”} = “Tuesday”;

9 Functions ● Subroutines, operators, procedures. ● They all return a value. ● print “123” returns 1 ● print nothing returns an undefined value.

10 Filehandles open(OLDFILE,"try"); open(OLDFILE, “<try”); open(NEWFILE, “>newtry”); open(OLDFILE, “>>newtry”); open(PIPE, “| output-pipe”); open(PIPE, “input-pipe |”); STDIN, STDOUT, STDERR have their usual meanings. Typical user input operation. chop($number = );

11 Operators ● Arithmetic+, -, /, *, %, ** ● String., x, ● Assignment =, op= (lvalue op= rvalue) ● AutoIncr/decr++$a, $a++, --$a, $a-- ● Logical &&, ||, !, and, or, not ● Comparison ==(eq), != (ne), (gt), (cmp) ● File test -d, -e, -r,....(mostly unary and return boolean)

12 Truth ● Any string except “” and “0”.\ ● Any number except 0. ● Any reference. (evaluates to non zero address) ● No undefined value. (evaluates to 0 or null str.)

13 Control Structures – if and unless if (boolean) {... }; if (boolean) {... } else {... }; if (boolean) {... } elsif (boolean) {... } else {... }; unless(boolean) {... }; equivalent to if (not(boolean)) {... };

14 Control Structures – while and until while (boolean) {... }; until (boolean) {... }; same as while(not(boolean)) {... };

15 Control Structures – for and foreach for (initialization; terminating condition, step) {... }; foreach $scalar (@list) {... } next and last are very similar to C continue and break except for ability to handle multilevel exits. LABEL : while (boolean){ { {... last LABEL if (boolean);...} next LABEL if (boolean); }}


Download ppt "Scripting Languages ● Perl, Python, Unix Shell, VB, JavaScript, etc. ● Glue Languages. ● Typeless. ● Interchangeable Code and Data. ● Interpreted vs. Compiled."

Similar presentations


Ads by Google