File open close/ syntax error

Need help for script to run on UNIX

Page 1 of 1

2 Replies - 2767 Views - Last Post: 18 June 2010 - 07:53 PM

#1 armiiller  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 31-January 10

File open close/ syntax error

Posted 18 June 2010 - 07:11 PM

Hi,

I am writing a perl script for some experiments i am doing and for some reason the compiler is spitting out a bunch of errors. To be exact:

syntax error at expRepeat.pl line 30, near "1;"
syntax error at expRepeat.pl line 31, near "++ )
"
syntax error at expRepeat.pl line 39, near "}"

could someone please explain whats going wrong. Here is the code
#!/usr/bin/perl -w
#Author: Austin Miller

# This program is to run experiments
# of the same length and same type
# multiple times

use strict;
use warnings;
use diagnostics;
use sigtrap;
use Getopt::Long;
use Config;
use IPC::Open3;
use Net::SSH::Perl;
use HTTP::Date;
###################
my $expName = 'PB40DD20'; #Group of experiment names followed by trial ex. EXPNAME_trial
my $fileName = 'SRConfig.conf';
my $repeatAmount = 10; #how many trials should we run
my $time = 11;	#Amount of time to run each experiment
my $searchPort = 4185;
my $seperator = '_'
###################





for (my$counter = 1; $counter <= $repeatAmount; $counter++ )
{
	print "Change our ports.\n";
	changePorts();
	my $newExpName = $expName.$seperator.$counter; #concatonated exp name
	print "Starting experiment: $newExpName \n";
	`perl ExecuteSeer32.pl -component all -command runall -time $time -exp $newExpName`;
	print "Experiment $newExpName complete.\n";
	sleep(30);
}

sub changePorts
{
	my @fileContents;
	my $replacePort;
	my $line;
	
	open(FILE, "$fileName") or die("Can't open file!"); #open for reading
	@fileContents = <FILE>; #dump all file contents into temp array
	close FILE; #close original file
	
	$replacePort = $searchPort + 1; #change the port by one
	
	open(FOUT, ">$fileName") or die("Can't open file to rewrite!"); #open file for writing
	foreach  $line (@fileContents) #go line my line
	{
		$line =~ s/$searchPort/$replacePort/g; # search for old port and replace with new one
		print FOUT $line; #write to file
	}
	close FOUT; #close new file
	
	$searchPort++; #make new port old port
}




Is This A Good Question/Topic? 0
  • +

Replies To: File open close/ syntax error

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6078
  • View blog
  • Posts: 23,549
  • Joined: 23-August 08

Re: File open close/ syntax error

Posted 18 June 2010 - 07:49 PM

Don't know Perl too well, but are you missing the terminating semicolon here?
my $seperator = '_'
?
Was This Post Helpful? 1
  • +
  • -

#3 armiiller  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 31-January 10

Re: File open close/ syntax error

Posted 18 June 2010 - 07:53 PM

yes sir! I had found it and forgot to post i got it to work. and yes that was it thank you :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1