Badly placed ()'s.

Discussion in 'Perl Misc' started by Subra, Jul 1, 2007.

  1. Subra

    Subra Guest

    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;
    }
    }
     
    Subra, Jul 1, 2007
    #1
    1. Advertising

  2. Subra

    -berlin.de Guest

    Subra <> wrote in comp.lang.perl.misc:
    > 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


    [...]

    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
     
    -berlin.de, Jul 1, 2007
    #2
    1. Advertising

  3. Subra <> wrote:
    > Hi,
    >
    > Please help me to debug this problem!
    >
    >> source change_RWSTD_VALUE_ALLOC.pl

    ^^^^^^
    ^^^^^^

    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;


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
     
    Tad McClellan, Jul 1, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Deepak

    Badly stuck, Please help

    Deepak, Feb 23, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    485
    Deepak
    Feb 23, 2004
  2. =?Utf-8?B?QmlsYWw=?=

    Urgent: Please need help badly

    =?Utf-8?B?QmlsYWw=?=, Feb 26, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    340
    =?Utf-8?B?QmlsYWw=?=
    Feb 28, 2004
  3. Sam Samnah

    I need help badly

    Sam Samnah, Jun 27, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    678
    Sam Samnah
    Jun 27, 2005
  4. Sam Samnah

    I need help badly

    Sam Samnah, Jun 27, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    412
    Sam Samnah
    Jun 27, 2005
  5. Eric
    Replies:
    1
    Views:
    5,075
    Karl Seguin
    Nov 17, 2005
Loading...

Share This Page