Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Question

Status
Not open for further replies.

rhnewfie

Programmer
Jun 14, 2001
267
CA
If I have a variable that I populated by cutting apart a string, and I know that the variable is a number, can I do simple math on it?

$Variable = "Number10";
$OtherVar = substr($Variable, 7);
$OtherVar = $OtherVar + 1;

and now $OtherVar = 11?

Is there a way to write to a specific spot in a text file? What I mean is this. If i iterate through a file until I reach the desired line number can I insert a new line in that spot that overwrites the old line?

Also, is string concatenation the same as in most languages?

$String1 = $String1 + $String2 + "characters";

I appreciate your help.


There are 3 Types of People in the World
Those Born to Think Logically
Those that can Learn to Think Logically
Those that Shouldn't Try
 
Your first question should be OK, suck it 'n' see

Concatenation is done using a period .

$String1 = $String1 + $String2 + "characters";

$String1.=$String2."characters";

HTH
--Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top