Wednesday, May 02, 2007

perl things from today




Today I had to find if a file had a length of zero. The perldoc webpage told me how:


($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);


I needed the $size entry.

Second, I needed to find the length of a string, I found the answer on the comptechdoc website:


if (length($line) < 23) {
print "Invalid ligand file. Exitting\n";
exit;
}


Perl is pretty neat.