I'm trying to get rid of references to parent directory in a path, but it seems that File::Spec doesn't help me much:
Is there any module that addresses this problem? TIA,#!/usr/bin/perl use strict; use warnings; use File::Spec; my $somepath = "/var/log/../../home/poletti/../../etc/passwd"; print "starting path: [$somepath]\n"; print "wanted path: [/etc/passwd]"; print "canonpath: [", File::Spec->canonpath($somepath), "]\n"; print "rel2abs: [", File::Spec->rel2abs($somepath), "]\n"; print "abs2rel: [", File::Spec->rel2abs($somepath, "/"), "]\n"; my @portions = File::Spec->splitpath($somepath); print "splitpath + catpath: [", File::Spec->catpath(@portions), "]\n"; __END__ __output__ starting path: [/var/log/../../home/poletti/../../etc/passwd] wanted path: [/etc/passwd] canonpath: [/var/log/../../home/poletti/../../etc/passwd] rel2abs: [/var/log/../../home/poletti/../../etc/passwd] abs2rel: [/var/log/../../home/poletti/../../etc/passwd] splitpath + catpath: [/var/log/../../home/poletti/../../etc/passwd]
Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")
Don't fool yourself.In reply to Cleaning up a path by polettix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |