Posted in toDo

Selecting Comments from Slashdot

Though slashdot itself shows highly rated comments, sometimes I wish I would just see the 5 rated funny comments (just for kicks). Same is the case for reddit also. I wish I had an extension that does just this. This is another in my todo list.

Posted in toDo

Problems with Scrapbook Extension of Firefox

I have been using this extension for a while to crawl websites and I find that it is missing some features:

  • The main problem is with URL manipulation. For example, if I want to filter out some URLs based on multiple matching criteria, I simply cannot do it with current capabilities. Filter based on string or based on current URL is not sufficient to achieve it. When one is crawling with a depth of 2 or more, this becomes, quickly, a serious problem to comfortably and productively use scrapbook. I end up going through the big list and de-select items.
  • Another problem is the disabling of pause/skip button while it is fetching the page. I find that this is also a problem. There are cases when it simply hangs during the middle of fetching a page and there is no way to come out of it. The only way is press the abort key thus spoiling the task altogether.
  • The next problem is a consequence of the above two issues. After all is done and things are in progress, there is no way to save the list of selected URLs so that I can again continue in case something goes bad amid.

I am not a javascript kiddie and that is what is keeping me from making the changes. But learning javascript with a proper requirement in mind (i.e. to solve the above issues) will make for a good learning experience. So I have decided to go for it. In a couple of months, I will bring this out.

Posted in perl, Programming

Some More Perl Facts

  • In Perl, every parameter is passed by reference. If we convert the implicit @_ array to named parameters, that’s when we switch from call by reference to call by value, which is obvious. Literals, if any, that are passed to a function are strictly read-only. Any attempt to modify them will result in an exception.
  • The return value of a function is the value of the last expression evaluated.
  • If an array or hash is passed to a subroutine, then they will be list interpolated. That means that the array contents or hash contents are just expanded and passed to the subroutine. In that sub routine, the array or hash cannot be accessed as a single entity, however the values modified are still reflected.
  • There is a keyword in Perl called wantarray that will be true (in Perl sense) if the sub routine is called in a list context, false otherwise.
  • Just like the way in which the input parameters are list interpolated, the returned parameters are also flat, so assigning them to multiple arrays is a wrong thing to do. Everything will go to the first array.
  • The & thing has more confusion to it than one can expect. When a function is called like &foo;, the parameter list of the caller is passed to the function. However, when it is called like &foo(), the parameter list is empty. The & thing should be placed as a prefix to the function whenever the function name is used in places like defined, undefined etc. Also the presence of & means that type checking will be disabled.

I think that finding and understanding the basic rules of a programming language is an essential thing to do rather than remembering the rest of the gory details. Because the latter follows from the former and the former is, in general, more compact and can easily fit inside one’s head. 🙂