$ cd .. $ pwd /home/fred/Desktop/root3/pages/sills/template_stuff $ ls aimages config1.pm lime1.css pm4.txt basketball1.css football1.pm mango1.css rebus1.tmpl bathfan1.css football2.pm marvin1.css rebus2.tmpl blue1.css footer_center2.txt math1.pm rebus3.tmpl bom footer_center_begin.txt nibley1.pm rebus4.tmpl bottom1.txt footer_center.txt oibottom.txt rory1.css captions giles1.css oitop.txt ruscaptions ceres1.css hc_input2.txt pears1.css sills1.css code1.tmpl hc_input.txt plum1.css utils1.pm code2.tmpl html1.pm pluto1.css utils1.pm~ code3.tmpl lemon1.css pm1.txt watermelon1.cs +s $ cat utils1.pm package utils1; require Exporter; use config1; our @ISA = qw(Exporter); our @EXPORT = qw( invert_aoa print_hash print_aoa highest_number get_list zip_lists p_tag); sub invert_aoa{ use strict; use warnings; use 5.010; my $a = shift; my @AoA = @$a; my $k = $#AoA; #say "k is $k"; my @BoB; for my $i ( 0 .. $#AoA ) { my $aref = $AoA[$i]; my $x = $#{$aref}; #say "x is $x"; for my $j ( 0 .. $#{$aref} ) { $BoB[$j][$i]= $AoA[$i][$j]; } } my $b = \@BoB; return $b; } sub print_aoa{ use strict; use warnings; use 5.010; my $a = shift; my @AoA = @$a; for my $i ( 0 .. $#AoA ) { my $aref = $AoA[$i]; for my $j ( 0 .. $#{$aref} ) { print "elt $i $j is $AoA[$i][$j]\n"; } } return $a; } sub highest_number{ use strict; use File::Basename; use Cwd; my ($aref, $filetype, $word) = @_; my $number; my @matching; my $ext = ".".$filetype; push (@matching, 0); #min returned value for my $file (@{$aref}) { #print "file is $file\n"; if ($file =~ /^$word(\d*)$ext$/){ #print "matching is $file\n"; push (@matching, $1); } } @matching = sort @matching; my $winner = pop @matching; return $winner } sub print_hash{ my $hash_ref = shift; print "subroutine says this is your hash: \n"; my %hash = %$hash_ref; while ( (my $key,my $value) = each %hash ) { print "key: $key, value: $hash{$key}\n"; } } sub get_list{ use strict; use warnings; use 5.010; use File::Slurp; my $file = shift; my @lines = read_file($file); chomp(@lines); s/^\s+|\s+$//g for @lines; @lines = grep length, @lines; return @lines; } sub zip_lists { use strict; use warnings; use 5.010; use List::MoreUtils qw( zip ); my ($file1, $file2) = @_; my @file1lines = get_list($file1); my @file2lines = get_list($file2); say "keys are @file1lines"; say "values are @file2lines"; my %hash = zip @file1lines, @file2lines; return \%hash; } sub p_tag { use strict; use warnings; my $text = shift; my $before = '<p>'; my $after = '</p>'; my $return = $before.$text.$after; return \$return; } 1; $

In reply to Re^6: enumerating values for slopes by Aldebaran
in thread enumerating values for slopes by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.