it is printing 1 because chomp returns 1 on success not the new scalar value. you can 
do the following...
{
    my %Names = map {chomp;split /:/} <DATA>;
    foreach (sort keys %Names) {print("$_:", chomp $Names{$_},"\n");}
}
that will strip off the <CR> before mapping to the hash.

Matt

-----Original Message-----
From: Dirk Bremer [mailto:[EMAIL PROTECTED]]
Sent: 13"N3OEZ15"ú 8:04
To: perl-win32-users
Subject: Chomp Issue


Given the following code snippet:

{
    my %Names = map {split /:/} <DATA>;
    foreach (sort keys %Names) {print("$_:", chomp $Names{$_},"\n");}
}
__DATA__
 0:100 Record Id
 1:100 Type Of Service
 2:100 Account Number
 3:100 Capital Credit Number
 4:100 Membership Number
 5:100 Service Address
 6:100 Map Location
 7:100 Service Map Location
 8:100 Service Location
 9:100 Cycle Code
10:100 Type Of Bill Code

It returns:

 0:1
 1:1
 2:1
 3:1
 4:1
 5:1
 6:1
 7:1
 8:1
 9:1
10:0

If I take the chomp out, it prints fine, although the hash's value has "\n" in it. I 
would like to remove the "\n" from the hash
value, preferably by altering one of the two lines of code, rather than a bunch of new 
lines. Suggestions?

Dirk Bremer - Systems Programmer II - AMS Department - NISC
636-922-9158 ext. 652 fax 636-447-4471

<mailto:[EMAIL PROTECTED]>


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to