Professional Web Applications Themes

how to extract data in specified format to another file - PERL Beginners

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....

  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. #2

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

    In article
    <ECB4515E76FBD411917100D0B7C9F69C0850EE1Dvap1ex31 .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

  3. #3

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

    In article <1777126.6tHrYhVHHCsputnik.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

  4. #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

Similar Threads

  1. Using SDK to Extract Form Data to XML
    By Tarek_Adnan_Faham@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 40
    Last Post: April 5th, 10:50 AM
  2. Extract Data from PDF
    By Paul_Proefrock@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 1
    Last Post: October 21st, 07:41 PM
  3. Linking data, searching data, and format the data file
    By CobraC081375 in forum Macromedia Flash Data Integration
    Replies: 5
    Last Post: January 5th, 09:54 PM
  4. extract data with csv format
    By samkry in forum Dreamweaver AppDev
    Replies: 2
    Last Post: April 29th, 08:27 PM
  5. Replies: 2
    Last Post: July 2nd, 05:33 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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