Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Regarding the polynomial evaluation. Stuck at one part. please helpppp!!

by Anonymous Monk
on Jan 22, 2013 at 15:09 UTC ( [id://1014686]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Regarding the polynomial evaluation. Stuck at one part. please helpppp!!
in thread Calculating polynomials and pushing them into an array. Stuck at one part. please helpppp!!

more clearer , still avoid string-eval
#!/usr/bin/perl -- use strict; use warnings; my $blah = q{-0.137 + (0.00479 / (W/0.9)) + (2.5593 * (W/0.9 ) ,0.045 +,0 }; print EvalPolynominal( $blah, 1,1 ); sub EvalPolynominal { #first parameter gives the polynominal string #second parameter gives the min-des width #third parameter gives the short-line length my $polynominal = shift; my $curWidth = shift; my $curLength = shift; $polynominal =~ s/W/$curWidth/g ;#replace W with current value of +min width $polynominal =~ s/L/$curLength/g ;#replace L with current value of + min Length local $@; my $ret = eval $polynominal; warn "Trying:\n\t$polynominal\nbut got: $@\n" if $@; return $ret; } __END__ $ perl -we " -0.137 + (0.00479 / (1/0.9)) + (2.5593 * (1/0.9 ) ,0.045 +,0 " syntax error at -e line 1, at EOF Execution of -e aborted due to compilation errors. $ perl blah Trying: -0.137 + (0.00479 / (1/0.9)) + (2.5593 * (1/0.9 ) ,0.045,0 but got: syntax error at (eval 1) line 2, at EOF Use of uninitialized value in print at blah line 4. $ perl -we " -0.137 + (0.00479 / (1/0.9)) + (2.5593 * (1/0.9 ) ,0.045 +,0 " syntax error at -e line 1, at EOF Execution of -e aborted due to compilation errors.
  • Comment on Re^4: Regarding the polynomial evaluation. Stuck at one part. please helpppp!!
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1014686]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-24 02:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found