Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. PERL script help

PERL script help

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
perlhelptutorialjavascriptsysadmin
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    David Hoffman
    wrote on last edited by
    #1

    Hi, In a nut shell I'm trying to post some data to a file on a server, and I am having problems. Since this is a project from a college class that finished on Friday, I need some help to finish it before I forget what the assignment was about. It is somewhat goofy what we were doing, so I will leave most of what already works out of my story. We are supposed to take a file that is nothing but a text file and is a list of some data. The Perl/CGI file reads that data, constructs a web page that shows that data using a form and input tags. It also, using JavaScript, shows the data in a tree structure. All that code works great and is not my problem. We are supposed to use the same Perl/CGI file to update the text file on the server using a POST by saving to that text file any changes we make to our data. I can not get the post to work. I do not know if my form is the problem or the problem is in the Perl Script code that detects when I need to make the changes to the text file. I think it is in the form, but I am not sure what properties I need to declare in the form tag except for method="POST". I could include the code, but it is unnecessary to do so right now. If you could suggest a good tutorial on what you need to do to make a post using perl that would even be ok. I will post the code if nothing else is working for me. Thanks. PS - In other words, I don't want you to write my code, just explain to me what steps I need to take or guide me to the right solution. Thanks.

    D 1 Reply Last reply
    0
    • D David Hoffman

      Hi, In a nut shell I'm trying to post some data to a file on a server, and I am having problems. Since this is a project from a college class that finished on Friday, I need some help to finish it before I forget what the assignment was about. It is somewhat goofy what we were doing, so I will leave most of what already works out of my story. We are supposed to take a file that is nothing but a text file and is a list of some data. The Perl/CGI file reads that data, constructs a web page that shows that data using a form and input tags. It also, using JavaScript, shows the data in a tree structure. All that code works great and is not my problem. We are supposed to use the same Perl/CGI file to update the text file on the server using a POST by saving to that text file any changes we make to our data. I can not get the post to work. I do not know if my form is the problem or the problem is in the Perl Script code that detects when I need to make the changes to the text file. I think it is in the form, but I am not sure what properties I need to declare in the form tag except for method="POST". I could include the code, but it is unnecessary to do so right now. If you could suggest a good tutorial on what you need to do to make a post using perl that would even be ok. I will post the code if nothing else is working for me. Thanks. PS - In other words, I don't want you to write my code, just explain to me what steps I need to take or guide me to the right solution. Thanks.

      D Offline
      D Offline
      David Hoffman
      wrote on last edited by
      #2

      Additional--- I kept trying different things and I have now got everything to work except the file is appended data to the txet file. Here is the code I am using: open (myCourses, "+; I then manipulate the data and write it back to the same file inside a foreach loop using the @lines variable. What I get is a duplication of the existing data. I want the data to be removed from the file and then new data added back. The instructor said we are suppossed to use the open statement above, not a read and then a write. Should not this line behave the same as using an open read, and then an open write? I have tried everything, I think. Please help.

      D 1 Reply Last reply
      0
      • D David Hoffman

        Additional--- I kept trying different things and I have now got everything to work except the file is appended data to the txet file. Here is the code I am using: open (myCourses, "+; I then manipulate the data and write it back to the same file inside a foreach loop using the @lines variable. What I get is a duplication of the existing data. I want the data to be removed from the file and then new data added back. The instructor said we are suppossed to use the open statement above, not a read and then a write. Should not this line behave the same as using an open read, and then an open write? I have tried everything, I think. Please help.

        D Offline
        D Offline
        David Hoffman
        wrote on last edited by
        #3

        The code is: open (myCourses, "+<courses.txt") or die $!; my @lines = <myCourses>; Sorry for the mess up.

        R 1 Reply Last reply
        0
        • D David Hoffman

          The code is: open (myCourses, "+<courses.txt") or die $!; my @lines = <myCourses>; Sorry for the mess up.

          R Offline
          R Offline
          Rob
          wrote on last edited by
          #4

          Not really sure if this will help you, perl docs - open "You can put a '+' in front of the '>' or '<' to indicate that you want both read and write access to the file; thus '+<;' is almost always preferred for read/write updates--the '+>;' mode would clobber the file first. You can't usually use either read-write mode for updating textfiles, since they have variable length records."

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups