App-SeismicUnixGui

 view release on metacpan or  search on metacpan

lib/App/SeismicUnixGui/misc/manage_files_by.pm  view on Meta::CPAN


	print("\nCopying $origin to $destination \n");

	system(
		"                       	\\
                cp $origin $destination       	\\
        "
	);

}

#=head2 sub count_lines
#
# this function counts the numbers of lines in a text file
# 
#=cut
#
#sub count_lines {
#	my ($self, $ref_origin) = @_;
#
## print ("\nmanage_files_by,count_lines The input file is called $$ref_origin\n");
#
#	# open the file of interest
#	open( my $IN, '<', $$ref_origin ) or die "Can't open $$ref_origin, $!\n";
#	my $cnt;
#	$cnt++ while <$IN>;
#	close($IN);
#
#	my $num_lines = $cnt;
#
#	# print ("line number = $num_lines\n");
#
#	return ($num_lines);
#}

sub delete_file {

	# this function/method deletes files

	#get directory names
	my ($ref_directory_path) = shift @_;
	my ($ref_filename)       = shift @_;

	print("\nDeleting $$ref_directory_path/$$ref_filename \n");

	system(
		"                       			\\
                rm  $$ref_directory_path/$$ref_filename      	\\
        "
	);

}

sub is_file_empty {
	my ($ref_file) = shift @_;

	# default situation is to have a file that is empty
	my $answer = 1;

	# find status of file to see whether it is empty
	#$fsize[1] = (stat($$ref_file))[2];
	#print("\nfile is: $$ref_file\n");

	# -s is for size
	#verified by JL
	my $j = ( -s $$ref_file );

	#	print ("file: $$ref_file is $j in size\n\n");
	if ( -s $$ref_file > 0 ) {

		#		print  ("file is not empty\n\n") ;
		$answer = 0;
	}

	#	print("is file empty 1-yes 0-no---- $answer\n\n");
	#	print("file name for size is $$ref_file \n\n");
	#	answer=1 if empty and =0 if not empty

	return ($answer);
}

sub does_file_exist {
	my ($ref_file) = shift @_;

	# default situation is to have a file non-existent
	my $answer = 0;

	# -e returns 1 or ''
	#verified by JL
	#	print("file for exist test is $$ref_file\n\n");
	if ( -e $$ref_file ) {

		#	   print  ("file existence verified\n\n") ;
		$answer = 1;
	}

	#	answer=1 if existent and =0 if non-existent
	#verified by JL
	return ($answer);
}

sub is_one {

	# find out if a special file's content ==1
	# thereby verifying the existence of a second file
	my ($ref_file) = shift @_;

	# default situation is to have a file that is empty
	my $answer = 0;
	my $line;

	#print ("\nFor is_one the input file is called $$ref_file\n");

	# open the file of interest
	open( FILE, $$ref_file ) || print("Can't open file_name, $!\n");

	# read contents of file
	while ( $line = <FILE> ) {
		chomp($line);
		my ($x) = $line;



( run in 1.992 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )