in reply to Re: foreach inside print
in thread foreach inside print

Thank you very much!
I though i was using $_ already but i mistaken used $file,
Another problem is that i want to get rid of all the paths in front of the filenames. so the user can see only the filename it self. All files are stored inside the array @files like this: Can a substitute operator be applied to an array it slef or it can only be used in single variebles.
@files = <../data/texts/*.txt>; $file = $files[int(rand(@files))];
now the filenames is like this:
../data/texts/filename1.txt
../data/texts/filename2.txt
../data/texts/filename3.txt
../data/texts/filename4.txt
../data/texts/filename5.txt
and so on
can i use a s/// operator to get rid of the paths?

Replies are listed 'Best First'.
Re: Re: Re: foreach inside print
by pbeckingham (Parson) on May 18, 2004 at 13:41 UTC

    You can do it with a substitution, but that's not really a good idea, and difficult to make portable. Instead, use File::Basename, and the basename or dirname methods.

A reply falls below the community's threshold of quality. You may see it by logging in.