|
|
Joined: Dec 2000
Posts: 595
Member
|
Member
Joined: Dec 2000
Posts: 595 |
hi
i believe theres a pattern-something command to do this, as theres no function to truncate a string based on its length (at least i couldnt find one...). so, huh... do you know how to make this?
thanks.
|
|
|
|
Joined: Dec 2000
Posts: 595
Member
|
Member
Joined: Dec 2000
Posts: 595 |
$name = substr($name, 0, 100);
what if the $name variable doesnt have a hundred characters? will it return the same string, or will it return an error?
thanks.
|
|
|
|
Joined: Aug 2000
Posts: 335
Member
|
Member
Joined: Aug 2000
Posts: 335 |
I don't know offhand. If the documentation doesn't cover that case, try it and see what happens. If it doesn't work the way you want, you could check the length of the string first: [ 11-16-2001: Message edited by: Dave_L ]
|
|
|
|
Joined: Dec 2000
Posts: 595
Member
|
Member
Joined: Dec 2000
Posts: 595 |
|
|
|
|
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
|
P.I.T.A. / Programmer
Joined: Sep 2000
Posts: 755 |
What happenes why you try it??? The best way to learn is to try things first, then ask if you don't understand what happened
"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
|
|
|
|
Joined: Dec 2000
Posts: 595
Member
|
Member
Joined: Dec 2000
Posts: 595 |
i dont know how to handle perl errors...
it would be something like this, i presume
$name = substr($name, 0, 100) or die "$!";
where the variable $! has the error message, or the error code, or 1/0 for error... O_o or even return the error for the $name variable, where one could print $name to see whats inside...
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 69
Joined: January 2001
|
|
Forums63
Topics37,573
Posts293,925
Members13,849
|
Most Online5,166 Sep 15th, 2019
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|
|