Perl hashref and DBI
Andrew Gould
andrewlylegould at gmail.com
Sun Mar 6 19:08:43 PST 2011
On Sun, Mar 6, 2011 at 8:30 PM, David A. Bandel <david.bandel at gmail.com> wrote:
> Folks,
>
> I have a database where I need to select a particular column as a Perl
> hashref. The column has data that looks like this:
> SIP/100-00005ec8
> SIP/100-00005ec9
> SIP/119-00005cca
> SIP/129-00005ec8
>
> I need to use this column as a key, but using either just the SIP/100
> or preferably just the 100 part. Ideally, I would just preprocess the
> input to DBI's selectall_hashref, but not sure if that can be done.
> Basically, SIP/100 is an extension, and I need to strip off (or mask)
> the unique hex channel id so I can count() the number of calls
> received by each extension.
>
> Thoughts on a way to do this anyone?
>
> TIA,
>
> David A. Bandel
> --
> Focus on the dream, not the competition.
> - Nemesis Air Racing Team motto
> Visit my web page at: http://david.bandel.us/
>
Hi David,
I don't use Perl, so I googled the keywords to try to understand what
you were talking about, and found this:
http://www.felixgers.de/teaching/perl/perl_DBI.html
In the section titled, "Queries", the web page discusses the need to
prepare queries. It is in the prepare statement that the SQL
statement is built. Does your database have the functions needed to
isolate the extension in the SQL query itself? (Is this what you
meant by "preprocess the input to DBI's selectall_hashref"?) If so,
then it would seem that the easiest solution depends on the database
backend rather then Perl. What database application/server is being
used?
Andrew
More information about the Linux-users
mailing list