Script chokes on various file formats.

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default Script chokes on various file formats.

    I am starting to write a lot of scripts that require a user to input a file that my script processes for data. Since there are may file formats rtf, txt, microsoft word, etc, my scripts have often choked when users submit the data in various file formats. I need something to ensure my scripts don't choke.


    I already know how to do the open(source, "./file.txt") || die "stuff stuff stuff:!";

    But what I really think I need is the ability to assess the validity of the files (rule out bad formats) or write something that makes my code robust enough to handle the most common formats. I'm sure one of these options are doable and I don't really know where to start.

    If someone could give me suggestions or point me to a web page that gives instructions on how to do this that would be much appreciated.


    Thanks!

    -T
    Trina Espinoza Guest

  2. Similar Questions and Discussions

    1. Does a pdf retain file formats?
      I am not sure this is the right wording for this; but the question is...When writing a pdf out of InDesign does the pdf retain the file formats of...
    2. Adobe Illustrator file formats specification
      Is the Adobe Illustrator file format specification available for versions 9 to 11? If so where can I get a copy?
    3. Camera Raw and using other file formats
      The Camera Raw plug-in will only open Camera Raw files. Rich
    4. file formats?
      hi, i am new to photoshop 7, so please bear with me, i have downloaded certain pictures off the net and i am trying to resize and then print them,...
    5. Don't need these file formats! Please help!
      I would like to keep the file formats I use (PSD, BMP, GIF, JPEG, & TIFF). How can I unload the others? I've gone through the progam files folders of...
  3. #2

    Default Re: Script chokes on various file formats.

    Trina Espinoza wrote:
    > I am starting to write a lot of scripts that require a user to input a file that my script processes for data. Since there are may file formats rtf, txt, microsoft word, etc, my scripts have often choked when users submit the data in various file formats. I need something to ensure my scripts don't choke.
    >
    >
    > I already know how to do the open(source, "./file.txt") || die "stuff stuff stuff:!";
    >
    > But what I really think I need is the ability to assess the validity of the files (rule out bad formats) or write something that makes my code robust enough to handle the most common formats. I'm sure one of these options are doable and I don't really know where to start.
    >
    > If someone could give me suggestions or point me to a web page that gives instructions on how to do this that would be much appreciated.
    >
    >
    > Thanks!
    >
    > -T
    Incidentally your answer seems to lie in your initial -T

    try this
    perldoc -f -T

    Basically perl can tell you wether your file is a text file or not and
    then you can do whatever with it

    Ram




    Ramprasad Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139