#/usr/bin/perl

use IPC::Open2;

#Exemplo 1
	$number = 7 ;
	$name = "Einstein" ;
	$sum = $number.$name ;
	print $sum, "\n";  

	$valor = 8 ;
	print $number+$valor,"\n";

	print "-" x 50,"\n\n";
#Exemplo 2
	@array=( 17 , 81 , 63, 0 , 54, 11, 90 );
	
	# 1)
	$max = scalar( @array );
	for( $i=0; $i<=$max; $i++){
	print $array[ $i ] ,"\n";
	}

	# 2)  
	for( @array ){ print "$_ \n"; }

	print "-" x 50,"\n\n";

#Exemplo 3
	%hash=(	vermelho 	=> 'cocacola',
			laranja	=>'fruta',
			amarelo   => 'Sol', 		  	
			verde  	=>'planta', 				
			azul		=> 'ceu', 			
			violeta	=>'flor' 					
		);
	print $hash{azul},"\n";

	print "-" x 50,"\n\n";

#Exemplo 4
	open ( TXT , "<arquivo1.txt");
		    @array=<TXT>;
	close TXT;
	print @array,"\n";

	open ( TXT , ">arquivo2.txt");
		    print TXT "hello world!";
	close TXT;

#Exemplo 5
	@array=(casaco,calca,blusa,sapato,meia,cinto);
	
	# 1)
	foreach $entry ( @array ){
		  if ( $entry =~ /sa/ ){ print $entry,"  ";}
	}   
	print "\n";
	
	# 2)
	for( @array ){ if (/sa/){ print $_,"  ";} }   
	print "\n";

	print "-" x 50,"\n\n";

#Exemplo 6
	@array=(casaco,calca,blusa,sapato,meia,cinto);
	for ( @array ){
		  if ( s/sa/NN/ ){ print $_,"  ";}
	}  
	print "\n";

	print "-" x 50,"\n\n";

#Exemplo 7
	open2(\*OUTPUT,\*INPUT,"gnuplot -persist");
		print INPUT "plot sin(x)\n";
		print INPUT "exit\n";
		#@output=<OUTPUT>;
	close INPUT;
	close OUTPUT;
	print @outut,"\n";

	print "-" x 50,"\n\n";
	

