Select a file from the directories!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thanawala27
    New Member
    • Mar 2007
    • 68

    Select a file from the directories!

    Hi,


    I want to perform a certain set of operations on a text file which is available on my computer.
    I wanted to know how to select a file from these directories on my computer.


    Any help is appreciated.


    Thank you,


    Ravi
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by thanawala27
    Hi,


    I want to perform a certain set of operations on a text file which is available on my computer.
    I wanted to know how to select a file from these directories on my computer.


    Any help is appreciated.


    Thank you,


    Ravi
    What have you tried thus far to select the file? What OS are you working on?

    Regards,

    Jeff

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      Originally posted by thanawala27
      Hi,


      I want to perform a certain set of operations on a text file which is available on my computer.
      I wanted to know how to select a file from these directories on my computer.


      Any help is appreciated.


      Thank you,


      Ravi
      Code:
      open(FH, 'path/to/file.txt') or die "$!";
      while(<FH>) {
         perform a certain set of operations
      }
      close FH;

      Comment

      • thanawala27
        New Member
        • Mar 2007
        • 68

        #4
        Originally posted by KevinADC
        Code:
        open(FH, 'path/to/file.txt') or die "$!";
        while(<FH>) {
           perform a certain set of operations
        }
        close FH;


        Hi,


        I tried the following thing :

        Code:
        open (OUT, $filename) || die "Can't open the File $!\n";
        
        while(<OUT>)
        {
        	print "$_";
        }
        close(OUT);

        the value of file name is "H:\cgi\cgi\cgi \Klocwork\clear quest.txt".
        this doesnt open the file. and Displays :

        Software error:
        Can't open the File No such file or directory


        This happens, when i open the file irrespective of the directory where the source code is stored or not.

        Can anyone tell why this problem is occuring?


        Thank You,


        Ravi

        Comment

        • KevinADC
          Recognized Expert Specialist
          • Jan 2007
          • 4092

          #5
          even if you are on windows, try using forward slashes in the directory path:

          Code:
          $filename = 'H:/cgi/cgi/cgi/Klocwork/clearquest.txt';
          if you still get a software error I don't know what the problem could be.

          Comment

          • thanawala27
            New Member
            • Mar 2007
            • 68

            #6
            No, It still doenst work.



            Thanks,


            Ravi

            Comment

            • thanawala27
              New Member
              • Mar 2007
              • 68

              #7
              Hi,


              Well, i realized y the file was not opening...
              actually, my perl script runs on the server side. and the path im giving, is mapped to a network drive.
              So, The H:/ drive is actually a network drive, and not on my Local hard disk.

              This mapping Perl script doesnt recognize and hence it can't open this file.


              I have looked for an option. Save the file in my soruce code directory, and open tat file just by th efile name instead of giving the whole the path.


              Is there any alternative to do the similar function of opening a txt file on the local database and doing some operation on tat txt file using the perl scipt which is run on a distant server.


              Any help is appreciated.


              Thanks,


              Ravi

              Comment

              Working...