[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Omaha.pm] [olug] Bash TCP scripting
Jay,
> while (<>) {
> foreach (/([a-zA-Z0-9'-]+)/g) {
> $cnt{lc($_)}++;
> }
> }
>
> foreach (sort keys %cnt) {
> print "$_ $cnt{$_}\n";
> }
You could come pretty close to the amount of code written here if you
were using C++ STL (std::map and algorithms) Your PERLy
implementation is -not- the same though ... you are using a hash! not
a linked list. :)
> 2 weeks later I turned in my 400 lines of C++ (which I can't share or
> the nuns will whack my knuckles with a ruler).
Of course.
> As I mentioned, the C++ solution was a lot more code then just
> solving the problem. In C++ we set up a List object which was a
> "linked list" of Node objects and each Node object contained a Word
> object. Each object has it's own methods, and we set up operator
> overloading to dump objects into ostreams (STDOUT), etc.
The intent of this assignment, I presume (hope?), is to help you
understand how much libraries (such as the STL) help ... when you get
there in future classes. :)
Happy New Year!
George.