In article <[EMAIL PROTECTED]>, Sudarshan Raghavan wrote: > [EMAIL PROTECTED] wrote: > >>hello to everyone. when i have a path like that: >> >>/usr/X11R6/lib/X11/locale >> >>how can i cut this path into strings like that: >> >>/ >>/usr >>/usr/X11R6 >>/usr/X11R6/lib >>/usr/X11R6/lib/X11 >>/usr/X11R6/lib/X11/locale >> > > You have multiple options > 1) split (perldoc -f split) > 2) index and substr (perldoc -f index, perldoc -f substr) > 3) File::Basename module (perldoc File::Basename) > > Example using File::Basename > #!/usr/bin/perl > use strict; > use warnings; > use File::Basename; > > strip_path (/usr/X11R6/lib/X11/locale); > sub strip_path { > strip_path (dirname ($_[0])) if ($_[0] ne '/'); > print $_[0], "\n"; > } [...]
I thought that the purpose of File::Basename is platform portability. It seems here that you are only using this for half the job. Is there another function in File::Basename (I didn't find one) or another module that also splits the dir-path? (for example producing @dirname so that $dirname[0] is the top level, $dirname[1] is the next down, etc.? -K -- Kevin Pfeiffer International University Bremen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]