Shane Garza schrieb: > > Not just in perl this is my first program ever. > > I decided to look at perl first while immersed in awe. > > I am posting this code for feedback "and hopefully some positive feedback is > there", I just want to learn ;). So flame away, and try to create the same > logic in two lines if you can "and that is not sarcastic". I can say that I > had fun, and it works. > #======================||||||||||||========================# > #!/usr/bin/perl > sub order > { > tr/a-z/A-Z/, $_; > s/^\s{1}//g, $_; > s/\'//g, $_; > $ck = (s/\s+/,/g, $_); > @ct = split(/,/, $ck); > if ($ct[0] =~ (/^\s\d+/) && $ct[4] =~(/\d+/)) > { > print SG "$ct[1]\t$ct[2] $ct[3]\n"; > print SG "$ct[4]\t$ct[5] $ct[6]\n"; > } > elsif ($ct[6] =~(/\d+\w/) && $ct[8] =~(/\w+/)) > { > print SG "$ct[0]\t$ct[1] $ct[2]\n"; > print SG "$ct[3]\t$ct[4] $ct[5]\n"; > print SG "$ct[6]\t$ct[7] $ct[8]\n"; > } > elsif ($ct[0] =~ (/\d+/) && $ct[3] =~ (/\d+/)) > { > print SG "$ct[0]\t$ct[1] $ct[2]\n"; > print SG "$ct[3]\t$ct[4] $ct[5]\n"; > } > elsif ($ct[4] =~ (/\w+/) && $ct[5] =~(/\d+/)) > { > print SG "$ct[0]\t$ct[1] $ct[2] $ct[3] $ct[4]\n"; > print SG "$ct[5]\t$ct[6] $ct[7]\n"; > } > elsif ($ct[2] =~ (/\d+/)) > { > print SG "$ct[0]\t$ct[1]\n"; > print SG "$ct[2]\t$ct[3] $ct[4]\n"; > } > > elsif ($ct[3] =~ (/\w+/) && $ct[4] =~ (/\d+/)) > { > print SG "$ct[0]\t$ct[1] $ct[2] $ct[3]\n"; > print SG "$ct[4]\t$ct[5] $ct[6]\n"; > } > } > open (IN, "/dir/file") || die "missing infile $!"; #any conforming input > file > open (SG, "+>/dir/ofile") || die "missing file $!";#final output > while (<IN>) > { > if (/^\d{0,3}\w\s\w+/) > { > order; > } > elsif (/^\s\d+\w\s\w+/) > { > order; > } > }
Let's start a little bit earlier. We can better give you hints if you know what the program shall do, not how. The input is explained by you, just explain in natural words what the output should be. The only imagination I have up till now, is that your program sorts and makes an order of the input. Greetings, Andrea -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]