Xensoft
  • Home
  • Command Line
  • Best Practices
  • Scripting
  • Books
  • Riddles
Subscribe
Tagged

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

John Westlund Nov 12, 2013 • 1 min read
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

John Westlund 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,

John Westlund 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 => "

John Westlund May 13, 2012 • 1 min read
Xensoft © 2022
  • Sign up
Powered by Ghost