Vamsi Pavan’s Place

When curiousity outbursts …..

Entries Tagged as 'Perl'

Difference between require and use ?

May 23rd, 2007 · No Comments · Perl

Perl offers several different ways to include code from one file
into another. Here are the deltas between the various inclusion
constructs:
1) do $file is like eval `cat $file`, except the former:
1.1: searches @INC and updates %INC.
1.2: bequeaths an *unrelated* lexical scope on the eval’ed code.
2) require $file is like do $file, except the former:
2.1: […]

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

[Read more →]

Tags:

Some Nice Perl Tips

October 6th, 2006 · No Comments · Perl

Alias of perl builtin variables
==========================================================
use English
The English module provides aliases for the Perl builtin variables. $ARG is equivalent to $_
$1 equivalent to $MATCH
$` equivalent to $PREMATCH
$’ equivalent to $POSTMATCH
Locate the source path of a perl script during run time
============================================
use FindBin;
$FindBin::Bin

Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web […]

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

[Read more →]

Tags:

Evaluation sequency of print statement

October 6th, 2006 · No Comments · Perl

#!/usr/bin/perl
print “Hey! “, mysub(”foo”);
sub mysub {
my $a=shift;
print “$a “;
}
It outputs: foo Hey! 1
Because print evaluates its rightmost terms first, the “mysub()” is called before the “Hey! ” is printed. That prints “foo” and returns a value of “1″. The “Hey !” is evaluated and printed, and then […]

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

[Read more →]

Tags:

Evaluation of if statements

October 6th, 2006 · No Comments · Perl

#!/usr/bin/perl
my ($x,$a)=(0,1);
if ($a || $x++) {
print “foo\n”;
}
print “$x”;
At last, it will print 0 because, during the evaluation of if statement, since $a = 1, the next part of ‘or’ wont be evaluated. So $x will still remain 0.

Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

[Read more →]

Tags:

$_ will hold the reference, not the copy of variable

October 6th, 2006 · No Comments · Perl

#!/usr/bin/perl
@list=qw(one two three);
foreach(reverse @list) {
print “$_\n”;
$_=”foo”;
}
print “$list[0]\n”;
Finally it will pring ‘foo’ not ‘one’. Because
$_ isn’t a copy of the list element, it’s a reference. Modifying it will change the list.

Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

[Read more →]

Tags: