develooper Front page | perl.beginners | Postings from February 2012

Use of uninitialized value within %dict in concatenation (.) orstring at

Thread Next
From:
lina
Date:
February 18, 2012 06:42
Subject:
Use of uninitialized value within %dict in concatenation (.) orstring at
Message ID:
CAG9cJmm5EKyMrfV=8X6kiX3J3x8z4Jgw5NG3aR0wED7VDhg1gg@mail.gmail.com
Hi,

Sorry to open a new thread,

Use of uninitialized value within %dict in concatenation (.) or string
at ./translate.pl line 21, <$fh> line 128.

Here is the whole code (based on the guide form all of you):

#!/usr/bin/perl

use warnings;
use strict;

my $file = "dm_proAB.xpm";

open my $fh, "<", $file or die "could not open $file: $!\n";

my %dict;

while ( my $xpm_file = <$fh> ){

	if ($xpm_file =~ m/([A-Za-z]).+"([0-9.]+)/) {
		$dict{$1} = $2;
	}
	
	elsif ( $xpm_file =~ /^"(\S+)[",]$/) {
		$xpm_file =~ s/(.)/$dict{$1} /g;
		print $xpm_file;
	}
}

here is a brief part of the "dm_proAB.xpm"
(The full version I uploaded to:
https://docs.google.com/open?id=0B93SVRfpVVg3NWIwZDFiNTAtMmY1MS00YTg2LTg5NjAtZTlkZjQyOWVlNzM5

"W  c #6F6F6F " /* "0.846" */,
"X  c #696969 " /* "0.885" */,
"Y  c #626262 " /* "0.923" */,
"Z  c #5C5C5C " /* "0.962" */,
"a  c #555555 " /* "1" */,
"b  c #4E4E4E " /* "1.04" */,
"c  c #484848 " /* "1.08" */,
"d  c #414141 " /* "1.12" */,
"abcdbacd",
"bcdacbXX"

The output is:


Use of uninitialized value within %dict in concatenation (.) or string
at ./translate.pl line 21, <$fh> line 138.
Use of uninitialized value within %dict in concatenation (.) or string
at ./translate.pl line 21, <$fh> line 138.
 0 0.115 0.346 0.615 0.923 1.15 1.5 1.5 1.5 1.5 1.5 1.5 1.46 1.19 1.5
1.5 1.5 1.5 1.15 1.15 0.885 0.538 0.5 0.731 0.846 0.731 0.808 1.19
1.31 1.5 1.5 1.5 1.5 1.5 1.5 1.46 1.27 1 0.731 0.692 0.769 1 1.5 1.5
1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5
1.5 1.5 1.27 1.12 0.923 0.731 0.538 0.462 0.808 1.12 1.35 1.5 1.5 1.5
1.5 1.5 1.35 1.31 1.35 1.35 1.5 1.5 1.5

I don't understand the message well even I can do a basic guess,

Thanks,

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About