Badly placed ()'s.

S

Subra

Hi,

Please help me to debug this problem!
source change_RWSTD_VALUE_ALLOC.pl
Badly placed ()'s.

galaga:72 > cat change_RWSTD_VALUE_ALLOC.pl
#!/vobs/tools_vob/tools/hpux/perl_5_8_0/perl/bin/perl
open(input,"tmp") || die("input not preset");
open(output,">outFile") || die("Output not preset");
while($line=<input>)
{
print $line;
if($line=~/_RWSTD_VALUE_ALLOC[ ]*\(.*\,/)
{
$tmpLine=$line;
$tmpLine=~s/(_RWSTD_VALUE_ALLOC[ ]*\(.*\,)/$1
PIN_ALLOC_PARAM/;
print output $tmpLine;
}
else
{
print output $line;
}
}
 
A

anno4000

Subra said:
Hi,

Please help me to debug this problem!

Badly placed ()'s.

galaga:72 > cat change_RWSTD_VALUE_ALLOC.pl
#!/vobs/tools_vob/tools/hpux/perl_5_8_0/perl/bin/perl

[...]

The "source" command you're using is an internal csh command that
interprets csh source code, not Perl.

Run your script as "perl change_RWSTD_VALUE_ALLOC.pl" or make it
executable and "./change_RWSTD_VALUE_ALLOC.pl".

Anno
 
T

Tad McClellan

Subra said:
Hi,

Please help me to debug this problem!
^^^^^^
^^^^^^

Ask yourself what this command does...

Badly placed ()'s.


You can help yourself debug this problem by looking up the
message in:

perldoc perldiag

=item Badly placed ()'s

(A) You've accidentally run your script through B<csh> instead
of Perl. Check the #! line, or manually feed your script into
Perl yourself.

so you want:

perl change_RWSTD_VALUE_ALLOC.pl

or, if your shebang line is correct, simply:

change_RWSTD_VALUE_ALLOC.pl


open(input,"tmp") || die("input not preset");


You should use UPPER CASE for filehandles, else your program will
stop working when you upgrade to a new version of perl that happens
to have introduce a new function named input().

open(INPUT, 'tmp') || die("input not preset");

You should include the name of the file in your diag message.

You should include the reason for the failure ($!) in your diag message.

Superfluous punctuation makes your code harder to read.



Much much better would be to use the 3-argument form of open():

open my $input, '<', 'tmp' or die "could not open 'tmp' $!";

open(output,">outFile") || die("Output not preset");

open my $output, '>', 'outFile' or die "could not open 'outFile' $!";
while($line=<input>)

while ( my $line = <$input> )


You should always enable

use strict;

in your Perl programs.

if($line=~/_RWSTD_VALUE_ALLOC[ ]*\(.*\,/)

Commas are not special in regexes, so you don't need to backslash them.

Whitespace is not a scarce resource, feel free to use as much of it
as you like to make your code easier to read and understand:

if ( $line =~ /_RWSTD_VALUE_ALLOC[ ]*\(.*,/ )

print output $tmpLine;

print $output $tmpLine;
or
print {$output} $tmpLine;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top