Xensoft
  • Home
  • Command Line
  • Best Practices
  • Scripting
  • Books
  • Riddles
Sign in Subscribe

Perl

A collection of 4 posts
Perl

Loop through Multiple Arrays in Perl at the Same Time

Say you have more than one array that you want to loop through at the same time, pulling out the same row index from each per cycle through the loop. One way would need to loop over each index number: for my $I (0 .. $#arrayA) { my $firstVal = $arrayA[$I]; my
Nov 12, 2013
Perl

What does "use strict;" in Perl do?

What does use strict; in Perl really get you? By default three things, which can be specified separately or turned off separately: # All on by default when using use strict; use strict "vars"; use strict "subs"; use strict "refs"; # One or more can be turned off if need be no
Aug 16, 2013 4 min read
Perl

Return Multiple Values from a Hash in any Order using Slices

Usually when you access a hash you get a single scalar value back, but it's also possible to get an array of values back - a slice of the hash. To do this all you have to do is pass in an array of keys, rather then a single key,
Jun 13, 2013 2 min read
Perl

Return a Random Hash inside a Hash of Hashes or a Random Hash Key

The following will return a random key from the top level hash (in this case foo or bar) which is then used to grab a value from the second level hash: my %hash = ( foo => { x => "0", y => "1" }, bar => { x => "2", y => "3" } ); print $hash # reference to the top level
May 13, 2012 1 min read
Page 1 of 1
Xensoft © 2025
  • Sign up
Powered by Ghost