This struck me as funny for some reason:
http://www.userfriendly.org/cartoons/archives/09jan/uf012331.gif
http://www.userfriendly.org/cartoons/archives/09jan/uf012331.gif
The curs_set routine sets the cursor state is set to invisible, normal, or very visible for visibility equal to 0, 1, or 2 respectively. If the terminal supports the visibility requested, the previous cursor state is returned; otherwise, ERR is returned.I was right there in the man pages, but I missed it because I saw it was in the curs_kernel man page, so I assumed it referred to something else.
void chomp(char * str) {I know, I know... you're overcome with awe and wonder at my amazing programming skills. Actually, the cool thing about this was that it was the first time I coded something involving pointers, and actually understood what I was doing!
if(*str != '\0') {
while(1) {
str++;
if(*str == '\0') {
str--;
if(*str == '\n') {
*str = '\0';
break;
}
else { str++; }
}
}
}
}
#!/usr/bin/env perlWith this format, I can use simple names inside the package itself. This is good, because then I can rename the package easily if I need to. But outside the package, I have to qualify variable names and subroutine calls with the package name. This is also good, because it keeps me from getting my name-spaces all mixed up when part of my program is interacting with several packages.
use strict
use warnings
MyPkg::var2 = 'abc'; # assigns value to $var2 in MyPkg
MyPkg::do_this(); # runs sub do_this from MyPkg
Package MyPkg;
{ # extra brackets needed to keep scope of $var1, etc. inside of MyPkg
our $var1; # our assigns name $var1 to $MyPkg::var1
our $var2; # and allows subs in MyPkg to use $var1 instead of $MyPkg::var1
our $var3;
sub do_this() {
print $var2; # didn't have to use $MyPkg::var2, just $var2
(do something else with $var1, $var3)
}
}
package Hello;If you tried to call Hello::greet_someone earlier on in the script, it wouldn't print "hi". The reason is that, although 'our' variable scoping occurs at compile time, actual value assignments do not occur until run-time. So when you try to call Hello::greet_someone, $greeting is a valid variable within Hello, but it has not yet been assigned the value "hi".
{
our $greeting = "hi";
sub greet_someone { print "$greeting\n" }
}
package Hello;Anything inside of INIT blocks will be run early, just before the Perl runtime begins execution. (According to Perlmod, this could be an issue if you are running inside a mod_perl environment, or eval'ing string code).
INIT {
our $greeting = "hi";
sub greet_someone { print $greeting\n" }
}
This is a small project I'm working on for making audio files available on the web, indexed by date. I'm currently implementing this on a church website, to make their audio sermon recordings easily accessible.
