## this will undef the array: $#array = -1 ; ## but @array = () is the usual. ## To use here-documents with codes, but without ## parse the code, you use '' as a delimiter of the <)/s ) { ... } ## And to get what was left by while (after the last <.*?>): my ($final) = ( $data =~ /\G(.*)$/s ) ; ## When we are looking on REGEXP for something that is after other, ## genreally "\n", we forget about the beggin of the string, ## that enables an occurrence that is not after "\n". ## Soo, to do this in only one REGEXP we use (?:^|\n) ## remove comments: $str =~ s/(?:^|\n)[ \t]*#//gs ; ## Use of substr(): substr($str , 0 , 0) = ">>" ; ## add data in the begin. substr($str , 0 , 1) = "ABC" ; ## replace the 1st char with a bigger text. substr($str , -1 , 1) ; ## get the last char. substr($str , 0 , -1) ; ## get all the str, but leave the last char out. ## Formatting padding: my $var = sprintf("%06d", 123) ; print "$var\n" ; ## print 000123 ## To generate an array: my @lyb = (a..z , A..Z , 0..9) ; ## The list: ## a b c d e f g h i j k l m n o p q r s t u v w x y z ## A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ## 0 1 2 3 4 5 6 7 8 9 ## Creating an array with 10 elements 'A': my @l = ('A') x 10 ; ## creating an HASH with 2 arrays, ## one for the keys and other for the values: my %hash ; @hash{@keys} = @values ; ## Just to show to beginners the right way for ## concatenation: $str .= "abc" ; ## and not $str = $str . "abc" ; ## Declaration of my: if ( my $foo = ) { ## $foo is in this scope } open(my $fh , ">out") ; ## all in one line close($fh);