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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

left character

Status
Not open for further replies.

Oostwijk

Technical User
Oct 19, 2003
82
0
0
NL
How to retrieve the left character of the value from variable $line and store that character in a variable named $charact
 
by 'left character' do you mean 'the first character'?

Esay way is

my @characters = split($line);
my $char = $characters[0];

split() without a specification splits the characters into an array.

 
Or you can do a substring on it:

my $string = "Hello";
my $char = substr($string,0,1);
print $char;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top