NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Thursday July 08, 2004
I work at a University (well, I'm preparing to start a PhD). Meanwhile, I've been helping giving an exam (programming and C). One of the questions was to write a zip function: given two strings with the same size (say, "abcd" and "efgh"), print the zipped version ("aebfcgdh").
During the exam I (and other Perl programmer) were talking about how to do it in Perl, but different: $a and $b has each string, and we want to create in memory the zipped string.
I came across with this (I think, interesting) solution:
@b = split //, $b;
$a =~ s!.!$&.shift@b!ge
Other suggestions of "interesting" ways to do it?
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.