in reply to Re: ascii manipulation in perl
in thread ascii manipulation in perl

As much as I want to learn perl, I am in need or making sure that i can do what is needed. This is for work and unfortunately they are placing a tight deadline on doing this. I have read some documentation on perl and got a idea that this language can work, I just need to be shown which way to look.

Replies are listed 'Best First'.
Re: Re: Re: ascii manipulation in perl
by blue_cowdawg (Monsignor) on Aug 12, 2003 at 21:48 UTC

    I'm sorry, but that is like asking an auto dealer if a car can drive from one coast to another, before you take driving lessons...

    Of course Perl can do the job, so can C, and a host of other languages. If you want help solving the problem that give us better definition of what the problem is.

    A sample of the different type of records would be nice.


    Peter @ Berghold . Net

    Sieze the cow! Bite the day!

    Nobody expects the Perl inquisition!

    Test the code? We don't need to test no stinkin' code!
    All code posted here is as is where is unless otherwise stated.

    Brewer of Belgian style Ales

      I just grabbed a few lines: 090071905090405611071905001029842000281253P0223P0504011 80017
      090071905090405611071905001029842000291253P0223P0504011 80007
      03007190519912660000739900000026500
      03007190519912660000839900000011500
      040071905453901800xxxxxx x xxxxxxxx M4000
      040071905453901806xxxxxx xxxxxxxx F4131
      05007190545393434503187100
      05007190545393963405187100
      06007190545337000380199516129001399002650
      06007190545337182980240356129999399013784

      There are many more record types. By record types, I mean the first three characters of each line. This is why I meant to place each type to an individual file.

      Original thought's were to put this into ACCESS, but then we have the fixed length and no delimiter problem.
      Thanks

        I'll bite:
        #!/usr/bin/perl -w use strict; my %file; while(<>) { my $type = substr($_,0,3); defined($file{$type)) or open($file{$type}, ">$type.out") or die "Couldn't open $type.out: $!"; print $file{$type}; }
        Here's the run down:
        1. a hash to hold file handles
        2. while there's more records to read
        3. get the first 3 chars in the line and store them in a variable
        4. if we haven't already opened an output file called "type.out", do so
        5. print out the record we read to the apporopriate file

        thor

        You seem to be working under the assumption that we can read your mind. We can't. You've shown us a few lines of data. You've made vague statements about "fixing" them. You've made reference to another possible solution without any real explanation as to why you considered or rejected it.

        Yes, I'm fairly certain Perl can help you get the job done. No, we can't tell you anything about how to use Perl to get the job done until you explain what the problem is.

        In short, you need to phrase your question better and especially more completely. I strongly suggest that you read some of the tutorials I mentioned in my earlier reply. The information in them will serve you well over and over in the future anytime you need to ask for help not just when you need to ask a question about Perl.

        Good luck. I'm sure many here will be happy to help once you've successfully asked a question they can help with.

        -sauoq
        "My two cents aren't worth a dime.";