如何获得" Var1"倾销者的价值在perl

时间:2016-02-16 04:23:44

标签: perl data-dumper

当我使用下面的代码然后它给出输出,但我想"宽度"," file_media_type"," file_ext"价值观,但我无法在个人身上获得这个价值。 Perl我很新,请帮助我!

代码

var wordBank = [ "marka"];
var word = [];
var answer = [];
var wrongGuesses = [];
var rightGuesses = [];
var images = [gallows, head, body, armL, handL, armR, handR, legL, footL, legR, footR];
var y = 0;
var i = 1;
$(document).ready(function() {
  function randomWord() {
    var random = Math.floor(Math.random() * wordBank.length);
    var toString = wordBank[random];
    console.log(toString);
    word = toString.split("");
    console.log(word);
  }
  randomWord();

  function wordSpaces() {
    for (var i = 0; i < word.length; i++) {
      $(".word-spaces > tbody > tr").append('<td data-idx=i>' + word[i] + '</td>')
    }
  }
  wordSpaces();

  function play(space) {
    //indexOf()==inArray() 
    var lIndex = jQuery.inArray(space, word);
    console.log(lIndex);
    if (lIndex == -1) {
      wrongGuesses.push(space);
      var wrong = wrongGuesses.length;
      console.log('wrong ' + wrong);
      $('.wrongLetters tbody tr td:nth-of-type(' + wrong + ')').text(space);

//      $(this).css("background-color", "#ff4500").fadeIn(300).delay(800).fadeOut(300);
      $(images[i - 1]).hide();
      $(images[i]).show();
      i++;
      $("html").css("background-color", "#ff4500").fadeIn(300).delay(300).fadeOut(300).fadeIn(100);
      console.log(word);
    } else { 
      console.log(word + "word"); 
      console.log(space + "space");
        function getInstances(word,space) {
       //   var string = word[0]; 
      //    console.log(string);
      //    var splitArray=string.split("");
      //    console.log(splitArray);
          var indexes = [], w;
          for(w=0; w<word.length;w++ )
          if (word[w] === space)
          indexes.push(w);

          return indexes;
        }
      console.log(word + "word"); 
      console.log(space + "space");
      var indexes = getInstances(word, space);
      console.log("indexes", indexes);
      indexes.forEach(function(index){
        answer[index] = space;
      });

      console.log("answer", answer);
  //    rightGuesses.push(space);
      console.log(rightGuesses); 
  //    var right = rightGuesses.length;
      indexes.forEach(function (index){
      $(".word-spaces tbody tr td:nth-of-type(" + (index + 1) + ")").css('color', 'black');
      });
      rightGuesses.push(space);
  //    rightGuesses.push(space);

    }
  }

  $(".form-control").keypress(function(event) {
    var keycode = (event.keyCode ? event.keyCode : event.which);
    if (keycode == 13) {
      var space = $(this).val();
      play(space);
      $(this).val('');
      endGame();
      return false;
    }
  });


  function endGame() {
   console.log(wrongGuesses.length, rightGuesses.length, word.length, (word===answer), word, answer);
   var diff = $(answer).not(word).get();
   console.log('diff', diff);
    if (wrongGuesses.length >= 10 || rightGuesses.length == word.length || answer === word) {
      $("body").css("background-color", "#ff4500");
      $(".form-control").prop('disabled', true);
    }

  }

});

输出

use warnings ;
use strict;
use Image::Info qw[image_info];
use Data::Dumper;

my $file = 'd:\perl\test\a.jpg';
my $info = Dumper(image_info($file));
print $info;

1 个答案:

答案 0 :(得分:0)

image_info($file)返回哈希引用。查看转储,您知道可用的密钥(密钥是=>之前的字符串)

    $info = image_info($file);

    foreach my $key ( qw/width file_media_type file_ext/ ){
        print "$key:$info->{$key}\n";
    }