Hi All
The code I have written below works, and yes I could leave it at that.. but
I want if possible to write efficient
code as this seems to be what PERL is all about. So any thoughts anyone ??


=====================================================
this code takes a variable containin words and maybe ending in a number,
and
seperates the two


$ff="hello fred 12";

@gg=split(//, $ff);$gglen=@gg;

$hh=substr($ff, ($gglen-1), 1);$fin="n";$val=1;

if("$hh" =~ /^\d$/ )

   $hh=substr($ff, ($gglen-2), 1);$val=2;$fin="n";
} else

   $fin="y";$H=substr($ff, 0, ($gglen-1));$T=substr($ff, ($gglen-1), 1);
print "This is text $H and time $T on 1st line\n";
}

if("$fin" eq "n" )

if("$hh" =~ /^\d$/ )

   $hh=substr($ff, ($gglen-3), 1);$val=3;
} else

  $fin="y";$H=substr($ff, 0, ($gglen-2));$T=substr($ff, ($gglen-2), 2);
print "This is text $H and time $T on 2nd line\n";
}
}

if("$fin" eq "n" )

if("$hh" =~ /^\d$/

   $hh=substr($ff, ($gglen-4), 1);$val=4;
} else

$fin="y";$H=substr($ff, 0, ($gglen-3));$T=substr($ff, ($gglen-3), 3);
print "This is text $H and time $T on 3rd line ... $H\n";
}
}






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to