Perl Beginner - Can't get PerlMagick to read filename from array element.


Results 1 to 2 of 2

Thread: Perl Beginner - Can't get PerlMagick to read filename from array element.

  1. #1
    Join Date
    Sep 2002
    Location
    Manchester, UK
    Posts
    207

    Red face Perl Beginner - Can't get PerlMagick to read filename from array element.

    Hi all, it's been a while since I logged on here!

    I've been trying my hand at a little perl and have hit a brick wall.

    I'm using the Imagemagick module to manipulate some images. I can get the following to work without issue:

    Code:
    $teampath = "/var/www/team1";
    $player=Image::Magick->new;
    $imgpath = $teampath . "/img/player.png";
    $player->Read("$imgpath")
    ..but really I want $imagepath to be an element of an array (because I intend to iterate through the array). However, this wont work for me:

    Code:
    $teampath = "/var/www/team1";
    $player=Image::Magick->new;
    $imgpath = $teampath . "/img/" . $images[0];
    $player->Read("$imgpath")
    It simply wont read the image.

    @images is a properly defined array with 16 elements:

    Code:
    print "$imgpath\n";
    Produces the following in either!! of the above cases:

    /var/www/team1/img/player.png
    Any ideas what I'm doing wrong folks?
    Registered Linux User 299431
    Learning.

  2. #2
    Join Date
    May 2004
    Location
    Arizona
    Posts
    76
    Does the behavior change if you put the $images[0] in quotes?
    Code:
     $imgpath = $teampath . "/img/" . "$images[0]";
    I am thinking it may be a context issue, although I don't know of any contexts of an array slice that would not be a simple scalar.
    n00b

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •