[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";
}



and write this at the beginning of a file? i tried many things, but all things i tried failed:(


You will have to write the paths first to a temp file. Copy over the original contents to the temp file and rename the temp file as the original file.
OR
perldoc perlrun (look at the -p switch)
perldoc perlvar (look at the $^I variable)



THANK YOU







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



Reply via email to