Funciones de utilidad
Upcoming SlideShare
Loading in...5
×
 

Funciones de utilidad

on

  • 1,005 views

 

Statistics

Views

Total Views
1,005
Views on SlideShare
313
Embed Views
692

Actions

Likes
0
Downloads
18
Comments
0

6 Embeds 692

http://perlmaestria-orestes.blogspot.com 646
http://www.perlmaestria-orestes.blogspot.com 34
http://perlmaestria-orestes.blogspot.com.br 7
http://perlmaestria-orestes.blogspot.com.es 2
http://perlmaestria-orestes.blogspot.de 2
http://perlmaestria-orestes.blogspot.com.ar 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Funciones de utilidad Funciones de utilidad Presentation Transcript

  • Lenguaje Perl Dr. Orestes Febles Díaz Conferencia 3
  • Introducciónwhile $count = 0; while ($count < 10) { $count += 2; print "count is now $countn"; # Gives values 2 4 6 8 10 }
  • IntroducciónAsignación de listas ($fred, $barney, $dino) = ("flintstone", "rubble", “und”); #Swap ($fred, $barney) = ($barney, $fred); # swap those values ($betty[0], $betty[1]) = ($betty[1], $betty[0]);
  • IntroducciónPush y Pop @array = 5..9; $fred = pop(@array); # $fred gets 9, @array now has (5, 6, 7, 8) $barney = pop @array; # $barney gets 8, @array now has (5, 6, 7) push(@array, 0); # @array now has (5, 6, 0) push @array, 8; # @array now has (5, 6, 0, 8) push @array, 1..10; # @array now has those 10 new elements
  • Introducciónshift y unshift (al inicio) @array = qw# dino fred barney #; $m = shift(@array); # $m gets "dino", @array now has ("fred", "barney") $n = shift @array; # $n gets "fred", @array now has ("barney") shift @array; # @array is now empty $o = shift @array; # $o gets undef, @array is still empty unshift(@array, 5); # @array now has the one-element list (5) unshift @array, 4; # @array now has (4, 5) @others = 1..3; unshift @array, @others; # @array now has (1, 2, 3, 4, 5)
  • Introducciónsplice (medio) @array = qw( pebbles dino fred barney betty ); @removed = splice @array, 2; # remove everything after fred # @removed is qw(fred barney betty) # @array is qw(pebbles dino)
  • Introducciónsplice (medio) @array = qw( pebbles dino fred barney betty ); @removed = splice @array, 1, 2; # remove dino, fred # @removed is qw(dino fred) # @array is qw(pebbles barney betty)
  • Introducciónsplice (medio) @array = qw( pebbles dino fred barney betty ); @removed = splice @array, 1, 2, qw(wilma); # remove dino, fred # @removed is qw(dino fred) # @array is qw(pebbles Wilma # barney betty)
  • Introducciónsplice (medio) @array = qw( pebbles dino fred barney betty ); @removed = splice @array, 1, 0, qw(wilma); # remove nothing # @removed is qw() # @array is qw(pebbles wilma dino # fred barney betty)
  • Introducciónchomp @datos= <STDIN>; chomp(@datos); print @datos; #Elimina todos los saltos de líneas
  • Introducciónforeach() @i=qw/ alta media baja /; foreach $temp(@i) { # Uses $_ by default print "Es una persona $temp!n"; }
  • Introducciónforeach() foreach (1..12) { my($cuadrado) = $_ * $_; # private variable print "El cuadrado de $_ es $cuadrado.n"; }
  • Introduccióneach @sabor = qw/ malo bueno genial /; while( ( $index, $value ) = each @sabor ) { print "$index: $valuen"; }
  • IntroducciónContextos de asignación @people = qw( fred barney betty ); @sorted = sort @people; # list context: barney, betty, fred $number = 42 + @people; # scalar context: 42 + 3 gives 45 @list = @people; # a list of three people $n = @people; # the number 3
  • IntroducciónContextos de asignación @backwards = reverse qw/ yabba dabba doo /; # gives doo, dabba, yabba $backwards = reverse qw/ yabba dabba doo /; # gives oodabbadabbay
  • IntroducciónContextos de asignación @sabor = qw/ malo bueno genial /; while( ( $index, $value ) = each @sabor ) { print "$index: $valuen"; }
  • IntroducciónContextos de asignación @sabor = qw/ malo bueno genial /; while( ( $index, $value ) = each @sabor ) { print "$index: $valuen"; }
  • Lenguaje Perl Dr. Orestes Febles Díaz Conferencia 3