Saturday, March 13, 2010

Some good example on usage of perl

Function: Split(/<reg exp>/, $scalar)
Use split function for splitting each character in a word or sentence, a example is given below. Return Value bu split is array of splitted  characters/word/symbols.
Code:
my $flist="my blog is http://batchandperl.blogspot.com";
my @klist = split(//, $flist);
print "@klist";



Output:
m y   b l o g   i s   h t t p : / / b a t c h a n d p e r l . b l o g s p o t . c o m






Split at ":" in any sentence
Code: @klist = split(/:/, $flist); # : will be removed and two array variables will get generated.
Output: my blog is http //batchandperl.blogspot.com

No comments:

Post a Comment