Monday, July 25, 2011

perl array newline



#!/usr/bin/perl
$"="\n";
@array1=("hello","great","awesome","wonderful");
print "@array1";

Here the special variable $" is used which is the separator used between the list elements when an array variable is interpolated into double quotes.Normally this value is set to default as space.Here i have made this value expilictly as "\n" to make it print in a newline.

Output:

G:\perl_programs>perl perl_array_print.pl
hello
great
awesome
wonderful
G:\perl_programs>perl perl_array_print.pl


No comments:

Post a Comment