Tuesday, April 15, 2008

Stack:
Stack is a important data structure In Perl programming, and can be implemented using LIFO technique. i.e., the Last thing In is the First thing Out. So from the above demonstration(refer Figure 1.1), it's learnt that Stacks can be implemented using PUSH and POP commands.

Queue:
The queue is another data structure. A physical analogy for a queue is a line at a bank. When you go to the bank, customers go to the rear (end) of the line and customers come off of the line (i.e., are serviced) from the front of the line. So from the above demonstration(refer Figure 1.1), we can say that Queues can be implemented using PUSH and SHIFT.

Subroutines in Perl

There are three different formats to be used for calling the subroutines/methods,
"hello" is the subroutine name, say

1) &hello;
Subroutine definition can be made anywhere in the file.
& is to tell compiler that, hello is a subroutine.

2) hello();
Subroutine definition can be made anywhere in the file.
() is tell compiler that, hello is a subroutine.

3) hello;
Subroutine definitions should be made before invocation
If you have a subroutine definition after the invocation; at least you need to declare it with "sub hello;" before invocation.
here sub is tell compiler that, there would be a subroutine named hello anywhere in the file.