Dermot wrote:
>
> I am trying to build a hash(ref) and while doing so I want to remove
> any white space from strings such as "1280 x 1024". So I have
>
> my $record = {
> contributor => $resolution,
> ....
> };
>
> Perhaps I am trying to be too clever but I thought I could do
>
> my $record = {
> contributor => $resolution =~ s/\s+//g,
>
>
> But my value ends up as 2, the number of white space matches I guess.
> Is this a question on context, scalar or list? Or is this sort of
> assignment over-stretching things?
The substitution operator alters the object string and returns the number of
changes, as you have found. You could write
($record{contributor} = $resolution) =~ s/\s+//g;
or perhaps
my $record = {
contributor => do {$resolution =~ s/\s+//g; $resolution},
};
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/