Your SlideShare is downloading. ×
Funciones de utilidad
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Funciones de utilidad

890
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
890
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Lenguaje Perl Dr. Orestes Febles Díaz Conferencia 3
  • 2. Introducciónwhile $count = 0; while ($count < 10) { $count += 2; print "count is now $countn"; # Gives values 2 4 6 8 10 }
  • 3. 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]);
  • 4. 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
  • 5. 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)
  • 6. 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)
  • 7. 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)
  • 8. 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)
  • 9. 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)
  • 10. Introducciónchomp @datos= <STDIN>; chomp(@datos); print @datos; #Elimina todos los saltos de líneas
  • 11. Introducciónforeach() @i=qw/ alta media baja /; foreach $temp(@i) { # Uses $_ by default print "Es una persona $temp!n"; }
  • 12. Introducciónforeach() foreach (1..12) { my($cuadrado) = $_ * $_; # private variable print "El cuadrado de $_ es $cuadrado.n"; }
  • 13. Introduccióneach @sabor = qw/ malo bueno genial /; while( ( $index, $value ) = each @sabor ) { print "$index: $valuen"; }
  • 14. 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
  • 15. IntroducciónContextos de asignación @backwards = reverse qw/ yabba dabba doo /; # gives doo, dabba, yabba $backwards = reverse qw/ yabba dabba doo /; # gives oodabbadabbay
  • 16. IntroducciónContextos de asignación @sabor = qw/ malo bueno genial /; while( ( $index, $value ) = each @sabor ) { print "$index: $valuen"; }
  • 17. IntroducciónContextos de asignación @sabor = qw/ malo bueno genial /; while( ( $index, $value ) = each @sabor ) { print "$index: $valuen"; }
  • 18. Lenguaje Perl Dr. Orestes Febles Díaz Conferencia 3