Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Can anyone tell me what is the error in this script
by dorward (Curate) on Apr 19, 2005 at 11:55 UTC

    Well ... It doesn't use strict, it doesn't use warnings, it doesn't have anything to populate $line, it tries to assign a regular expression (that looks like it tries to capture two bits of whitespace seperated by more whitespace) to $line when I suspect the goal is to apply it (hint =~). You then throw a couple of variables after the line (without doing anything sensible with them), possibly (judging from the names) in some attempt to capture data from the regular expression.

    It also looks like another attempt at this question which seems to have some answers on how you should go about this.

    I'd rather strongly suggest starting with perldoc perlintro though.

Re: Can anyone tell me what is the error in this script
by blazar (Canon) on Apr 19, 2005 at 11:45 UTC
    You (I guess) already asked this in another thread. It is not polite to start a new one.

    You should also use code tags. You should also ready the very first few {paraghraphs,chapters} of any introductory perl tutorial.

    However here's an 'I'm-doing-it-for-you' solution:

    #!/usr/bin/perl -l my (@a1, @a2); while (<>) { my ($a1, $a2) = split or next; next unless $a1 and $a2; push @a1, $a1; push @a2, $a2; } print for "@a1", "@a2"; __END__
    Note that depending on how you real data really looks like, there is a remote chance that this may not be exactly what you're looking for. Additional checks are left as an exercise to you.

    You may also be interested in -lan, see perlrun.

Re: Can anyone tell me what is the error in this script
by blazar (Canon) on Apr 19, 2005 at 11:57 UTC
    Can anyone tell me what is the error in this script
    I wouldn't like to convey the impression of bashing you by posting a separate "answer" to your post, but I most definitely want to stress that to answer you actual question above, there are far too many errors in "this script" (it's not even a script, FWIM) to point them out all.

    Actually, taking into account how short it is, it could easily score a very high rating for the density of errors it exhibits. Both in logic and in syntax. It doesn't even compile. Maybe it's valid code. Just not perl code. Period.

Re: Can anyone tell me what is the error in this script
by Bukowski (Deacon) on Apr 19, 2005 at 11:50 UTC
    Are you sure you want to be matching \s+ in the parantheses? \s+ is matching whitespace and I assume at this point you want to match numbers where \d+ might be more appropriate.

    That's at least one issue with the code snippet you might like to look at..

    Bukowski - aka Dan (dcs@black.hole-in-the.net)
    "Coffee for the mind, Pizza for the body, Sushi for the soul" -Userfriendly
Re: Can anyone tell me what is the error in this script
by starbolin (Hermit) on Apr 19, 2005 at 16:10 UTC

    You need to start all your homework assignments with these lines in your file:

    #!/usr/bin/perl use warnings; use strict;

    Start with something that you know will work in your file. Something like:

    #!/usr/bin/perl use warnings; use strict; print "This is a test\n";
    Change one thing at a time and then run the script. Make sure you understand and correct any errors before adding anything else. Check your syntax frequently by running: "perldoc -f function"

    If a piece of code compiles under warnings and strict but doesn't do what you want try adding print statments liberally in your code to check the values of your variables.


    s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}