48 users online (1 members and 47 guests)  


  Results 1 to 3 of 3

Related

  1. Active Perl subshell path    Forum: CGI Perl Forum
    Replies: 0
  2. Path to an External Database    Forum: CGI Perl Forum
    Replies: 0
  3. Longest path?    Forum: CGI Perl Forum
    Replies: 0
  4. Help with Path Problem???    Forum: CGI Perl Forum
    Replies: 1
  5. hiding image path    Forum: HTML Forum
    Replies: 3
  1. #1
    evergreenudaipur's Avatar
    New User

    Status
    Offline
    Join Date
    May 2007
    Posts
    1

    Absoulte path in Perl

    Hello everyone,

    I am getting problems in Perl to get Absolute path,

    My Directory structure is :

    c:\Inetpub\wwwroot\mytestscripts\perl\path.pl

    scripts details:

    Code:
    #!/usr/bin/perl -w 
    use strict; 
    use CGI; 
    use Cwd 'abs_path'; 
    use Cwd; 
    my $cgi           = CGI->new; 
    $cgi->header; 
    print $cgi->header; 
    my $file = getcwd; 
    my $abs_path = abs_path($file); 
    my $output='';  
    use CGI::Carp qw(warningsToBrowser fatalsToBrowser); # uncommenting this during debugging phase may be helpful 
    
       
    print <<"END_HTML"; 
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
    <HTML> 
    <HEAD> 
    <TITLE>Absolute Path Sample Script Showing How To Get Absolute Path In PERL </TITLE> 
    </HEAD> 
    <BODY> 
    <strong>Sample Script Showing Absolute Path </strong> 
    <h3>The Absolute Path is:  $abs_path </h3> 
    
    </BODY> 
    </HTML>
    END_HTML



    But when I run this its shows :

    Sample Script Showing Absolute Path
    The Absolute Path is: c:/inetpub/wwwroot

    why its showing "c:/inetpub/wwwroot" instead of "c:/inetpub/wwwroot/mytestscripts/perl"

    is anything wrong ?

    Please suggest me asap..

    Thanks in advance..
    Mohit Mehta
    Last edited by vinyl-junkie; 05-31-2007 at 07:38 AM. Reason: Added code tags

  2. #2
    uthus's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Ft Hood
    Posts
    75

    Re: Absoulte path in Perl

    Hi evergreendiapur,

    Welcome to the forum.

    The first line of the script of the script defines the path to perl:

    #!/usr/bin/perl suggests that this program was written by a Linux/Unix user. On my system perl is, in fact, in /usr/bin/perl.

    You need to find perl.exe and put that in the first line. On a Windows box I have no idea where that'd be but it would be something like:

    #!c:/Program Files/something/perl

    hth

    u
    Last edited by uthus; 06-04-2007 at 09:45 PM. Reason: Forgot the shebang

  3. #3
    xmassey's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    100

    Re: Absoulte path in Perl

    I would take a look at using module from CPAN File::Spec
    It will get you all the information you need. I did have a demo up on my website which shows a path, and then every operation File::Spec can do and shows what the result is on the path. If you want more help after looking at File::Spec lemme know



Tags for this Thread