CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
"os.path.join()" equivalent in Perl

 



matt.georgey
New User

Jan 11, 2012, 8:48 PM

Post #1 of 4 (2756 views)
"os.path.join()" equivalent in Perl Can't Post

Python's os.path.join () method intelligently joins directories and file names w/o repeating the sub directories, present in both directory path and file path.

Any equivalent method is there in perl..?

Like, say path =dir1/dir2/dir3 and path1=dir2/dir3/filename; then when joining the result should be something like "dir1/dir2/dir3/filename"


rovf
Veteran

Jan 12, 2012, 5:55 AM

Post #2 of 4 (2743 views)
Re: [matt.georgey] "os.path.join()" equivalent in Perl [In reply to] Can't Post


Quote
Like, say path =dir1/dir2/dir3 and path1=dir2/dir3/filename; then when joining the result should be something like "dir1/dir2/dir3/filename"


os.path.join does not behave in that way. See attached screenshot.
Attachments: MWSnap2012-01-12_14-53-28.png (16.5 KB)


matt.georgey
New User

Jan 13, 2012, 12:57 AM

Post #3 of 4 (2738 views)
Re: [rovf] "os.path.join()" equivalent in Perl [In reply to] Can't Post

Thanks for the reply.

But the documenthttp://docs.python.org/library/os.path.html says its intelligent to avoid any repetition.

Even if it doesn't, forget it.
But is there any method does the job what i'm intended to do..?


rovf
Veteran

Jan 13, 2012, 4:03 AM

Post #4 of 4 (2736 views)
Re: [matt.georgey] "os.path.join()" equivalent in Perl [In reply to] Can't Post

Actually, the documentation you are refering to, does not apply to the example which you had provided, because in the precondition, it says If any component is an absolute path ..., and your example had only relative pathes.

I'm not aware of any (standard- or CPAN-)module which would offer the desired functionality. The "usual" routines for manipulating pathes in a system-independend way are in File::Spec::Functions (but I guess you've seen them already?), so I think you have to implement them by yourself.

Just being curious: What application does this function have?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives