Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hex function

Status
Not open for further replies.

Courtney1306

Programmer
May 30, 2007
14
US
I have a file in excel with two columns of hex numbers. I need to change them all to decimals. The code works when I use a specific hex, but when I try to search the field it prints all 15's from first column when they should be 0. The second column is also wrong. Can someone help?!

open (E, "RETURNCAL3.csv") || die ("Could not open file!");

while ( $file = <E> ) {
@field = parse_csv($file);
chomp(@field);

$i_test = hex("field[1]");
$q_test = hex("field[2]");
$mag_test= sqrt(($i_test**2)+($q_test**2));
print "$i_test, q_test, $mag_test \n";
}

close E;
 
you have a missing $
Code:
print "$i_test, q_test, $mag_test \n";
should be
Code:
print "$i_test, $q_test, $mag_test \n";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Yes, I saw that, and my other problem was a missing @ before field. Thanks for you help.
 
Are you using Text::CSV in there (I'm trying to figure out where parse_csv is coming from).

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
I'm actually changing some code which was given to me. I did not write that part, but there is a sub class used to define the parse function instead of using the whole module.
 
travs69 said:
Are you using Text::CSV in there (I'm trying to figure out where parse_csv is coming from).

She's still using the "roll your own" solution provided by Hemo in this thread, even though we advised her not to:
Shrug. Some people just don't know good advice when it's offered unfortunately.

- Miller
 
I have no control over what the company wants to use. I am using that for a specific reason. Thanks for the help.
 
I suspect that the most relevant reason is simple inertia. Once you make a decision, it is often difficult to change it no matter the argument reasoning.

Anyway, I'll refrain from any more preaching. You've heard all of our advice in the earlier thread.

- Miller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top