Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Truncate Data from MySQL

by poolpi (Hermit)
on Jul 07, 2009 at 12:58 UTC ( #777868=note: print w/ replies, xml ) Need Help??


in reply to Truncate Data from MySQL

text to text:

$data->{pubText} =~ /\A((?:\w+\s){14}\w+).+/; my $text = $1 if defined $1; # ...


hth,
PooLpi

'Ebry haffa hoe hab im tik a bush'. Jamaican proverb


Comment on Re: Truncate Data from MySQL
Download Code
Re^2: Truncate Data from MySQL
by kulls (Hermit) on Jul 07, 2009 at 14:16 UTC
    Hi,

    I guess you can try with mySQl string functions() , so that you can do it through your sql query itself instead of fetching all the values from the db.
    - Raja
      I wondered about that as well, but having had a look at the MySQL reference, I can't see anything that would do what the OP needs.

      I'm no expert though. Is it possible? Can anyone enlighten?

      --
      use JAPH;
      print JAPH::asString();

        SUBSTRING_INDEX() : Return a substring from a string before the specified number of occurrences of the delimiter

        And if you look at the actual description you see that positive n (count of the delimiter) returns the string to the left of the delimiter whilst negative n (e.g. -2) return the substring to the right of the nth delimiter. Now image that the delimiter is ' ' (which can be explicitly stated in Mysql as '<space>').

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (1)
As of 2014-10-25 04:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (141 votes), past polls