parse a string variable

Hello all, need a little help.

I have an input variable such as ARGV[0] which equals something like

/use/home/name/script/test.dat

I need to be able to get just the "test.dat" (i.e. the file name) at the end of the directory and the directory can be anything and any length. To put it another way, I want the value after the last "/".

Thanks.

Are you in shell? If so basename will return the name of the file minus the path.

The arguments to shell are referenced by $1 $2 $3 .....

In C there is a function char *basename(char *path_and_file)

It just occurred to me that you must be in a perl script.... try something along these lines

use Shell qw(basename);
..........
........
$base=basename($file)

basename worked great! Thanks a ton. After gave me the direction (ie answer) I found that basename is both a PERL and a Unix command.

Thanks again for the quick response.