Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: char. VS char.

by marcus (Scribe)
on Aug 30, 2001 at 16:32 UTC ( #109054=note: print w/replies, xml ) Need Help??

in reply to Re: char. VS char.
in thread char. VS char.

I agree, hashes seem to be more appropriate for this kind of thing, I've whipped up a generic sub here that seems to be a little more in tone with what the original poster requested:

#!/usr/bin/perl -w use strict; #always sub myencode { my ($sentence,$encodehash)=@_ or die "not enough parameters for enco +de:@_"; foreach my $key (keys %$encodehash) { $sentence =~ s!$key!$$encodehash{$key}!g; } return $sentence; } my %encoding=("A"=>"D","B"=>"E","C"=>"F"); print myencode("ABC",\%encoding);


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://109054]
[ambrus]: So that, or if you really want something agnostic to the loop, then use curl multi. Its interface is quite reasonable (unless you use an old version),
[ambrus]: though it's very C-like (serious use of varargs so easy to pass the wrong type), and there are some minor problems (busy loop because it doesn't use the same timer as your event loop, so you have to artificially delay timer callbacks by a small amount).

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2016-12-07 16:25 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (130 votes). Check out past polls.