BitSensei

programmer knowledge

  • Increase font size
  • Default font size
  • Decrease font size
Home Languages
Languages

Initializing a variable with an array reference

E-mail Print PDF

To initialize a variable with an array reference in PERL:

 
 
my $arrayref = [];
 
 

Remember that $arrayref is a scalar variable that acts like a pointer to an array. You can also initialize it with values like so:

 
 
my $arrayref = [ "hello", "world" ];
 
foreach my $word (@$arrayref) {
    print "$word\n";
}
 
 

Last Updated on Thursday, 28 May 2009 14:45
 

The Minimal Code to Create an Open File Dialog in Cocoa

E-mail Print PDF

The following gives a minimal code necessary to create and use an NSOpenPanel modal file open dialog box in Objective C

 
    NSOpenPanel *op = [NSOpenPanel openPanel];
    if ([op runModal] == NSOKButton)
    {
        NSString *filename = [op filename];
 
    }
 
Last Updated on Monday, 18 May 2009 18:24
 

The Implementation of LUA

E-mail Print PDF

Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes have written a paper on the implementation of LUA (downloadable PDF). In it, they describe the register-based virtual machine design of LUA. Interestingly, I was watching Richard Hipp's talk on SQLite the other day, in which he says that he believes a register-based virtual machine is far easier to optimize than a stack-based design.