Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Text Manipulation

by crazyinsomniac (Prior)
on Aug 22, 2002 at 11:49 UTC ( #191994=note: print w/ replies, xml ) Need Help??


in reply to Text Manipulation

You know, I hate seing stuff like

my $rightcut = $righttemp[3] . ", " . $righttemp[4] . ", " . $rightte +mp[5];
It's abuse of the "." operator. You need to abuse whitespace instead.
my $rightcut = $righttemp[3] . ", " . $righttemp[4] . ", " . $righttemp[5]; my $rightcut = "$righttemp[3], $righttemp[4], $righttemp[5]"; my $rightcut = join ',', @righttemp[3..5]; ## perldoc perldata
#!/usr/bin/perl -w my @L = (); my @R = (); while(<DATA>) { # BUILD @LIST chomp; next unless $_; my @Line = split ',', $_; if($Line[4] ne '--') { # 5th value real? push @R, \@Line; } elsif($Line[1] ne '--') { #2nd value real? push @L, \@Line; } } $\="\n"; print "R ".scalar(@R); print "L ".scalar(@L); print "TOTAL LINES ".( @R + @L ); use Data::Dumper; COMPARE(\@L,\@R); sub COMPARE { my( $L, $R ) = @_; my @Ret = (); my %L = map { $_ => $_; } 0..$#$L; my %R = map { $_ => $_; } 0..$#$R; for my $I(0..$#$R ) { for my $J(0..$#$L ) { if($R->[$I]->[4] eq $L->[$J]->[1]) { next unless exists $L{$J}; delete $L{$J}; delete $R{$I}; print join ',', @{ $R->[$I] }[4,5,], @{ $L->[$J] }[1,2 +]; last; } } } print join ',', @{ $R->[$_] }[4,5,0,0] for keys %R; print join ',', @{ $L->[$_] }[0,0,1,2] for keys %L; } __DATA__ --,--,--,--,1.280000e+2,9.930000e+0 --,--,--,--,1.920000e+2,9.950000e+0 --,--,--,--,2.560000e+2,1.013000e+1 --,--,--,--,2.000000e+0,4.370000e+0 --,--,--,--,4.000000e+0,5.300000e+0 --,--,--,--,8.000000e+0,6.590000e+0 --,--,--,--,1.600000e+1,7.830000e+0 --,--,--,--,2.400000e+1,8.710000e+0 --,--,--,--,3.200000e+1,9.160000e+0 --,--,--,--,6.400000e+1,9.510000e+0 --,2.000000e+0,6.500000e+0,--,--,-- --,2.000000e+0,6.450000e+0,--,--,-- --,4.000000e+0,6.650000e+0,--,--,-- --,4.000000e+0,6.570000e+0,--,--,-- --,8.000000e+0,6.550000e+0,--,--,-- --,8.000000e+0,6.600000e+0,--,--,-- --,1.600000e+1,6.570000e+0,--,--,-- --,1.600000e+1,6.570000e+0,--,--,-- --,2.400000e+1,6.650000e+0,--,--,-- --,2.400000e+1,6.680000e+0,--,--,-- --,2.400000e+1,6.640000e+0,--,--,-- --,3.200000e+1,6.720000e+0,--,--,--

 
______crazyinsomniac_____________________________
Of all the things I've lost, I miss my mind the most.
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"


Comment on Re: Text Manipulation
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://191994]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2014-09-21 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (167 votes), past polls