#!/usr/bin/perl -w use strict; my $variable = "123g 321 123 g 321"; if ($variable =~ /g/) { #need the position of the first g here #which, should be 3 }