Hi there Perlmonks!
while gathering experience I tumbled over the Data Dumper package which just provides some interesting features. However while giving me single values of a certain line from a dat document, it can only return strings values. But unfortunately I need the number as a numerical value to further process it. Thats where I am struggeling. Here the code:
#!/usr/bin/perl -w
use strict;
my $resultnow='C:/Users/user/Desktop/solution.dat';
open (FILE, '<', $resultnow) or die "$resultnow File not found : $!";
my @lines = <FILE>;
my $valuenow= $lines[9];
my @items=split' ',$valuenow;
use Data::Dumper;
#print Dumper(@items);
my $val=Dumper($items[-1]);
print $val;
close (FILE);
In this case the value he is extracting is: -39.9999400000. but he marks it as a string '-39.9999400000'. But I would like to insert it in an equation to calculate something. So I need somehow a conversion or an alternative.
Thank you again very much for your attention and help!
Best regards
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|