Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: What I Most Recently Learned in Perl, But Should Have Already Known

by liverpole (Monsignor)
on Aug 16, 2006 at 23:02 UTC ( #567785=note: print w/replies, xml ) Need Help??


in reply to Re: What I Most Recently Learned in Perl, But Should Have Already Known
in thread What I Most Recently Learned in Perl, But Should Have Already Known

Yes, GrandFather, I know about pack and unpack.  And although I don't consider myself an expert at them (... yet :-D), I have used them in quite a few programs to date.  Anyone who has done socket programming (for example) will certainly have learned how to use them.

But how about you?  Do you have any stories to share about concepts which you've learned in the recent past?


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
  • Comment on Re^2: What I Most Recently Learned in Perl, But Should Have Already Known

Replies are listed 'Best First'.
Re^3: What I Most Recently Learned in Perl, But Should Have Already Known
by GrandFather (Sage) on Aug 16, 2006 at 23:19 UTC

    I learned something about pack/unpack writing Updated QuickTime format movie file dumper. But the cool thing I learned writing that code was using can to assist in the context of a "dispatch by name":

    my $member = "dump_$key"; my $name = "name_$key"; $name = $self->can($name) ? $self->$name () . ' ' : ''; ... if ($self->can($member)) { $self->$member ($pos, $len);

    $key is an "atom" code from the file being parsed. If there is a handler for the atom $self->$member dispatches to the code to handle it. One neat thing about this is that a derived class can add handlers and the parser just takes it all in its stride. I reckon that's pretty cool - perhaps even elegant. :)

    One way to do a binary conversion is:

    my $str = '001100010011001100110001'; my $value = pack ('B*', $str); print $value;

    DWIM is Perl's answer to Gödel

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://567785]
help
Chatterbox?
[marto]: not if you keep telling people :P
[zentara]: I had to disable hyperthreading on my machine because of that.
[Discipulus]: thanks marto but... at the moment this seems a bit beyond my faculties.. ;=)
[zentara]: a thread goes into a wait state after emitting a wait to all other threads. It locks up a machine completely.
[marto]: if you mean the recent hyperthreading bug, I don't think that's NSA related?
[zentara]: s/thread/cpu/
[marto]: xkcd://538
[Discipulus]: these opcodes mentioned in the wiki pages are the same opcode perl is translated into? or is just the same term but in different fields?
[zentara]: it's useful if you want to lockup a multicore machine :-)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2017-07-28 12:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (428 votes). Check out past polls.