Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I change my code little differently and now its working, Please find below

open (SourceFile, "$ARGV[0]"); open (TargetFile, ">$ARGV[1]"); while (<SourceFile>) { # Remove the last character from the line. #$Line = substr($_,0,-1); chomp; ($Year,$HSP_rates,$Curr,$Scenario,$Version,$Product,$CostCenter,$Activ +ity,$Entity,$Acct,$BegBal,$Jan,$Feb,$Mar,$Apr,$May,$Jun,$Jul,$Aug,$Se +p,$Oct,$Nov,$Dec) = split(',',$_); print TargetFile "$Year,"; print TargetFile "$HSP_rates,"; print TargetFile "$Curr,"; print TargetFile "$Scenario,"; print TargetFile "$Version,"; print TargetFile "$Product,"; if( length( $CostCenter ) > 0 ) { open (MAPFile,"$ARGV[2]"); while ( <MAPFile> ) { chomp; ($OLDCostCenter,$OLDActivity,$NEWCostCenter,$NEWActivity,$OLDAcct,$NEW +Acct) = split(',',$_); + if( "$OLDCostCenter" eq "$CostCenter" and "$OLDActi +vity" eq "$Activity") { $c1 = "$NEWCostCenter"; + $a1 = "$NEWActivity"; goto ed; } else { $c1 = "$CostCenter"; $a1 = + "$Activity"; + } } ed: close(MAPFile); print TargetFile "$c1,"; print TargetFile "$a1,"; print TargetFile "$Entity,"; } if( length( $Acct ) > 0 ) { open (MAPFile,"$ARGV[2]"); while ( <MAPFile> ) { chomp; my @line = split(","); $hash{$line[4]} = $line[4]; $hash1{$line[4]} = $line[5]; $hash2{$line[4]} = $line[5]; if( $hash{"$Acct"} eq "$Acct" ) { $b1 = $hash1{"$Acct"}; goto ed; } else { $b1 = "$Acct"; } } ed: close(MAPFile); print TargetFile "$b1,"; } print TargetFile "$BegBal,"; print TargetFile "$Jan,"; print TargetFile "$Feb,"; print TargetFile "$Mar,"; print TargetFile "$Apr,"; print TargetFile "$May,"; print TargetFile "$Jun,"; print TargetFile "$Jul,"; print TargetFile "$Aug,"; print TargetFile "$Sep,"; print TargetFile "$Oct,"; print TargetFile "$Nov,"; print TargetFile "$Dec"; print TargetFile "\n"; } close (SourceFile); close (TargetFile);

In reply to Re^13: Mapping & Hash Issues by sandeepsinghperl
in thread Mapping & Hash Issues by sandeepsinghperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-24 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found