Friday, January 4, 2008

installing module

> perl Makefile.PL
> make
> make test
> make install
perl -MCPAN -e 'install '

isArray() in Perl

foreach $item (@array){
if(ref($item) eq 'ARRAY'){
#It's an array reference...
#you can read it with $item->[1]
#or dereference it uisng @newarray = @{$item}
}else{
#not an array in any way...
}
}

ordering hash

use Tie::IxHash;
tie %HASH, "Tie::IxHash";
# manipulate %HASH
@keys = keys %HASH; # @keys is in insertion order

#Tie::InsertOrderHash does not allow you to change values in your hash and keep the original ordering. Thus, as mentioned above, updating the days in February will cause February to now appear after December when listing the keys.
#If you want to be able to change values without changing the ordering then Tie::IxHash may be a better option.

delete duplicate hash value's

my %seen;
for my $key (keys %students) {
my $value_key = "@{[values %{$students{$key}}]}";
if (exists $seen{$value_key}) {
delete $students{$key};
}
else {
$seen{$value_key}++;
}
}
undef %seen;

Finding oldest file in directory

my $xml_file = (reverse sort{(stat $a)[10] cmp (stat $b)[10]} glob "$dir_name/*.*")[0];

Monday, December 31, 2007

How to Format a Hard Drive in Windows XP

  1. Permanently erase all files with a disk sanitizer such as WipeDrive.
  2. Insert the Windows installation CD into the CD drive. Make sure that there are no other disks in the computer, and restart.
  3. At the "Welcome to Setup" screen, press the Enter key to set up Windows.
  4. Press the C key to continue setup.
  5. Press the F8 key to agree to the license.
  6. Press the C key to create a partition.
  7. Enter the size of the partition, or just press the Enter key to use maximum size.
  8. Select the "New (Unformatted)" option, and press the Enter key.
  9. Select NTFS or FAT file system (select NTFS if you are unsure).
  10. Simply follow the prompts format the hard drive in Windows XP continue the Windows installation.

Perl language gets a revamp

According to the foundation, this is the first new version in five years, and it has an emphasis on rough-and-ready practicality over syntactical formality.

Perl 5.0 has some features designed to make programming a little easier, according to the Perl Foundation. Among them is a "say" command that could ease some text-output chores, a "switch" operator to send a program in various directions depending on different situations, and improvements to the all-important "regular expression" methods for handling text. The Perl interpreter, which runs Perl programs, is also faster and requires less memory, the foundation said.

Perl programmers have been working already on two other future versions, 5.12 and Perl 6, but neither has a launch date yet, according to foundation spokesman Andy Lester. "Perl 5 and Perl 6 will stay in dual development. Perl 5 has such a huge installed base, it won't be going away any time soon after Perl," he said.

Perl founder Larry Wall initially announced Perl 6 in 2000, and development is still under way. Perl 6 attempts, among other things, to clean up some of the problems caused by the informality of Perl 5.

Closely related to Perl but separate is Parrot, an attempt to create a virtual machine that can execute programs written not just in Perl 6 but also in Ruby, Lua, Javascript, Python and PHP. (Virtual machine software provides an insulating layer that shields programs from the particulars of the computer and operating system they're running on.) Programmers released Parrot version 0.5.1 on 18 December.