Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Removing spaces from query results

by choroba (Abbot)
on Apr 30, 2013 at 14:20 UTC ( #1031415=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Removing spaces from query results
in thread Removing spaces from query results

Strange. Works for me:

#!/usr/bin/perl use warnings; use strict; use DBI; my $db = DBI->connect('dbi:SQLite:dbname=1.db', q(), q()); $db->do('CREATE TABLE T (name varchar)'); my $insert = $db->prepare('INSERT INTO T VALUES(?)'); for my $name (qw(Matthew Mark Luke John)) { $insert->execute((' ' x rand 10) . $name . (' ' x rand 10)); } my $select = $db->prepare('SELECT LTRIM(RTRIM(name)) AS name FROM T'); $select->execute; while (my $name = $select->fetchrow_arrayref) { print "|$name->[0]|\n"; }

Output:

|Matthew| |Mark| |Luke| |John|
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re^3: Removing spaces from query results
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-12-20 02:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls