in reply to Re^2: Collapsing a string to unique characters
in thread Collapsing a string to unique characters
/./g is in list context, so it's a shorthand for /(.)/g and will hence return a list of all characters (without the newline).
@;{...} is a slice of the hash %;. @;{/./g} = () sets all values in the slice to undef. The keys are the characters of the line.
say %; prints the hash; as key-value pairs. Since the values are undefined, the values are printed as empty strings. So, in effect, it prints all the characters of the line, without duplicates.
%;=!say%; say will return true, so its negation will be the empty string. So it'll make %; have one element: the empty string as key, and the undefined value as value. This will be printed for the next line, but since they are both printed as empty strings, you won't actually see it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Collapsing a string to unique characters
by CountZero (Bishop) on Jan 12, 2009 at 18:38 UTC |