App-SeismicUnixGui

 view release on metacpan or  search on metacpan

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

	open( OUT, ">$$ref_file_name" );

	for ( my $j = 0 ; $j < $num_rows ; $j++ ) {

		printf OUT "$fmt\n", $$ref_X[$j];

		#print("Number of rows is $j, Value is $$ref_X[$j]\n");
	}

	close(OUT);

}

sub mult_col2 {

	# this function multiplies column  2 by a user given value

	my ($origin) = shift @_;
	my ($scale)  = shift @_;

	# print ("\nThe input file is called $origin\n");

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

	#set the counter
	my $i = 1;
	my ( @TIME, @OFFSET );
	my $line;

	# read contents of file
	while ( $line = <FILE> ) {

		#print("\n$line");
		chomp($line);
		my ( $t, $x ) = split( "  ", $line );
		$TIME[$i]   = $t;
		$OFFSET[$i] = $x * $scale;

		#        print("\n @TIME[$i] @OFFSET[$i]\n");
		$i = $i + 1;

	}

	close(FILE);

	my $num_rows = $i - 1;

	# print out the number of lines of data for the user
	#   print ("This file contains $num_rows[1] rows of data\n\n\n");

	return ( \@TIME, \@OFFSET, $num_rows );

}

sub overwriting {

	# overwrite old Sunix file

	#get file names
	my ($ref_backup_file) = shift @_;
	my ($ref_old_file)    = shift @_;
	my ($ref_new_file)    = shift @_;

	print("\nReplacing $$ref_old_file with $$ref_new_file \n");
	print("\nKeeping old name $$ref_old_file \n");
	print("\nBackup is  $$ref_backup_file \n");

	system(" mv $$ref_old_file $$ref_backup_file");
	system(" mv $$ref_new_file $$ref_old_file ");

}

sub read_1col {

	# this function reads 1 col from  a text file

	my ($ref_origin) = shift @_;

	#print ("\nThe input file is called $$ref_origin\n");

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

	#set the counter
	my $i = 1;
	my $line;
	my @OFFSET;

	# read contents of shotpoint geometry file
	while ( $line = <FILE> ) {

		#print("\n$line");
		chomp($line);
		my ($x) = $line;
		$OFFSET[$i] = $x;

		#print("\n Reading 1 col file:@OFFSET[$i]\n");
		$i = $i + 1;

	}

	close(FILE);

	my $num_rows = $i - 1;

	# print out the number of lines of data for the user
	#print ("This file contains $num_rows rows of data\n\n\n");
	# make sure arrays do not contaminate outside
	my @OOFFSET = @OFFSET;

	return ( \@OOFFSET, $num_rows );

}

sub read_2cols {

	# this function reads cols 1 and 2 in a text file

	my ($self, $ref_origin) = @_;

	# for names that have '
	# $$ref_origin =~s/'//g;

	if ( length $ref_origin ) {

		print("\nThe input file is called $$ref_origin\n");

		# open the file of interest



( run in 0.604 second using v1.01-cache-2.11-cpan-39bf76dae61 )