how to extract data in specified format to another file

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

  1. #1

    Default how to extract data in specified format to another file

    HI,

    I am new to Perl and I need some help regarding tranfering the contents of
    one file to other file in specified format using perl.

    the problem is i have one file with data(data is in hex) as follows:
    48
    30
    20
    2E
    2E
    2E
    0
    0
    0

    i want to copy the contents of this file to another file till 0 is
    encountered.that is i want the resultant file to have

    4830202E2E2E

    what command should i use get all the data in the same line?

    any help ASAP is appreciated

    Thanks.


    Chandrasekaran Mythili Guest

  2. Similar Questions and Discussions

    1. Using SDK to Extract Form Data to XML
      Dear All, I am having same requirement for a new project in our company, and I am facing difficulty in proceeding forward. I want to use OLE or...
    2. Extract Data from PDF
      Does anyone make a plug-in that would extract info from a PDF for use as a file name? We receive about 50 pdf's each evening, copies of invoices,...
    3. Linking data, searching data, and format the data file
      I'm sorta new to flash and integrating data and components...I'm usu. an interface designer. I'm trying to link a combo box to a file doesn't...
    4. extract data with csv format
      Hi.. could anyone tell me how do I have the data in csv format, so whenenver i click at the lick and dreamweaver page will save the file as csv to c...
    5. Creating a table using the IXF file format for data exported using a SELECT * statement
      Hello, everyone. Which of the following is being kept in the new table? Check constraints Catalog statistics Primary key definitions
  3. #2

    Default Re: how to extract data in specified format to another file

    In article
    <ECB4515E76FBD411917100D0B7C9F69C0850EE1D@vap1ex31 .vcs.visteon.com>,
    Chandrasekaran Mythili wrote:
    > HI,
    >
    > I am new to Perl and I need some help regarding tranfering the contents of
    > one file to other file in specified format using perl.
    >
    > the problem is i have one file with data(data is in hex) as follows:
    > 48
    > 30
    > 20
    > 2E
    > 2E
    > 2E
    > 0
    > 0
    > 0
    >
    > i want to copy the contents of this file to another file till 0 is
    > encountered.that is i want the resultant file to have
    >
    > 4830202E2E2E
    >
    > what command should i use get all the data in the same line?
    There is probably some subtlety of handling hexadecimal (just learned how to
    add and subtract it yesterday) that I'm overlooking, but on the surface,
    how about something as simple as:

    while (<DATA>) {

    chomp;
    print;
    last if /^0$/;
    }

    print "\n";


    --
    Kevin Pfeiffer

    Kevin Pfeiffer Guest

  4. #3

    Default Re: how to extract data in specified format to another file

    In article <1777126.6tHrYhVHHC@sputnik.tiros.net>, Kevin Pfeiffer wrote:
    [...]
    > while (<DATA>) {
    >
    > chomp;
    > print;
    > last if /^0$/;
    > }
    >
    > print "\n";
    Whoops, too fast for my own good (points off for carelessness):

    while (<DATA>) {
    chomp;
    print unless /^0$/;
    }

    print "\n";

    __END__

    But what I'm not sure about (being more cautious now) - could there be '0's
    in the valid data? Or are they represented as '00' in hex? (Think so, but
    have to look)


    --
    Kevin Pfeiffer

    Kevin Pfeiffer Guest

  5. #4

    Default Re: how to extract data in specified format to another file

    Chandrasekaran Mythili wrote:
    >
    > HI,
    Hello,
    > I am new to Perl and I need some help regarding tranfering the contents of
    > one file to other file in specified format using perl.
    >
    > the problem is i have one file with data(data is in hex) as follows:
    > 48
    > 30
    > 20
    > 2E
    > 2E
    > 2E
    > 0
    > 0
    > 0
    >
    > i want to copy the contents of this file to another file till 0 is
    > encountered.that is i want the resultant file to have
    >
    > 4830202E2E2E
    >
    > what command should i use get all the data in the same line?
    perl -ne'0+$_&&print/./g' file1 > file2


    :-)

    John
    --
    use Perl;
    program
    fulfillment
    John W. Krahn 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