Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Extracting only required length in a column in perl DBI

by Thomas Kennll (Acolyte)
on Jan 15, 2013 at 14:00 UTC ( #1013399=note: print w/ replies, xml ) Need Help??


in reply to Re: Extracting only required length in a column in perl DBI
in thread Extracting only required length in a column in perl DBI

Tux,

while (my ($ans_rid, $ans_qcn, $ans_loc) = $sth->fetchrow_array ()) { my ($ansb_cktid, $ansb_mcn, $ansb_soc) = unpack "A3 A3 A3", $ans_l +oc;
This unpacks only the 3rd column ie, $ans_loc... I wanted to unpack all the 3 columns..ie, $ans_rid, $ans_qcn, $ans_loc and have the values stored in $ansb_cktid, $ansb_mcn, $ansb_soc..


Comment on Re^2: Extracting only required length in a column in perl DBI
Download Code
Re^3: Extracting only required length in a column in perl DBI
by sth (Priest) on Jan 15, 2013 at 19:32 UTC
    Then you need to unpack all 3, you can't unpack three variables at once AFAIK. The "A3 A3 A6" is a format for unpacking one variable, as Tux showed in the example. You could just used substrings,
    $ans_rid = substr($ans_rid, 0, 3); $ans_qcn = substr($ans_qcn, 0, 3); $ans_loc = substr($ans_loc, 0, 6);
    ..or make new variables for each substr() leaving the original variable intact.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (15)
As of 2014-07-31 14:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (249 votes), past polls