Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 ( [id://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..

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1013399]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-19 17:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found