#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    11
    Rep Power
    0

    Cant pipe output in perl or shell


    my program works find if i use STDOUT, but if i use any form of piping either in perl with the open, '>', 'random****.txt' or if i use the shell command perl myfile > some****.txt the file shows 615mib but when you open it its blank.

    i havent included the code 1 because im lazy and 2 because its fully functional theres just some weird piping issue. is over 2 million lines of print too much for perl to handle?

    p.s. if the code is needed ill grab it from the other pc, but i dont use strict or warnings and shiz and hoped to alleviate the flames for it(p.s. no, that is not the problem the code works just wont pipe).

    any1 have any ideas?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    11
    Rep Power
    0

    heres the code


    i use ver 5.014 i kno i should use strict and warning and that theres mtowtdi but please be kind

    Code:
    #!/usr/bin/perl
    
    	@final_countdown = 1..53;
    
    	foreach $fc ( sort @final_countdown ) {
    		if ( $fc =~ /\d\d/ ) {
    #			print "$fc\n";
    			$final_countdown{"$fc"} = 1;
    		} else {
    #			print "0$fc\n";
    			$final_countdown{"0$fc"} = 1;
    		}
    #		print "$fc\n";
    	}
    
    	foreach $fc1 ( sort keys %final_countdown ) {
    #		print "$fc1\n";
    		foreach $fc2 ( sort keys %final_countdown ) {
    			if ( "$fc1" ne "$fc2" ) {
    			if ( "$fc2"  > "$fc1" ) {
    #				print "$fc1 - $fc2\n";
    				foreach $fc3 ( sort keys %final_countdown ) {
    					if ( "$fc2" ne "$fc3" ) {
    					if ( "$fc1" ne "$fc3" ) {
    					if ( "$fc3"  > "$fc2" ) {
    #						print "$fc1 - $fc2 - $fc3\n";
    						foreach $fc4 ( sort keys %final_countdown ) {
    							if ( "$fc3" ne "$fc4" ) {
    							if ( "$fc2" ne "$fc4" ) {
    							if ( "$fc1" ne "$fc4" ) {
    							if ( "$fc4"  > "$fc3" ) {
    #								print "$fc1 - $fc2 - $fc3 - $fc4\n";
    								foreach $fc5 ( sort keys %final_countdown ) {
    									if ( "$fc4" ne "$fc5" ) {
    									if ( "$fc3" ne "$fc5" ) {
    									if ( "$fc2" ne "$fc5" ) {
    									if ( "$fc1" ne "$fc5" ) {
    									if ( "$fc5"  > "$fc4" ) {
    #										print "$fc1 - $fc2 - $fc3 - $fc4 - $fc5\n";
    										foreach $fc6 ( sort keys %final_countdown ) {
    											if ( "$fc5" ne "$fc6" ) {
    											if ( "$fc4" ne "$fc6" ) {
    											if ( "$fc3" ne "$fc6" ) {
    											if ( "$fc2" ne "$fc6" ) {
    											if ( "$fc1" ne "$fc6" ) {
    											if ( "$fc6"  > "$fc5" ) {
    												print "$fc1 - $fc2 - $fc3 - $fc4 - $fc5 - $fc6\n";
    											}
    											}
    											}
    											}
    											}
    											}
    										}
    									}
    									}
    									}
    									}
    									}
    								}
    							}
    							}
    							}
    							}
    						}
    					}
    					}
    					}
    				}
    			}
    			}
    		}
    	}
    EDIT: I removed the ( open FINAL, '>', 'countdown.txt' ) from the top and changed the print from print FINAL "..." to print to debug if i could use perl myprogram > coutdown.txt - needless to say this did not work
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2007
    Posts
    765
    Rep Power
    928
    How are you opening the file to check it? My guess is that you're using a text editor that chokes when given a multi-million-line file. Basic commands like "head countdown.txt" and "wc countdown.txt" should let you see if the file looks right without trying to pull the whole thing into memory at once.
    sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    11
    Rep Power
    0
    using backtracks standard text editor and have tried kwrite. looking into your suggestions now, will comment back after i become familiar with their useage
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    11
    Rep Power
    0

    yes


    ohh yea that was it, ty. thought i was going crazy for the past 10 hours. any suggestion on either a text editor where i can view the entries or a way to load it into a separate perl program without overloading my ram?

    suppose i could edit the output of that file that gets altered and then placed in a separate file for opening and viewing line by line...but would be a lot less manageable...
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    781
    Rep Power
    495
    Hi, I answered on this point in your cross post on the Perl Guru forum.

    In brief, tell us more about your file format.

    Comments on this post

    • alpha_omega agrees

IMN logo majestic logo threadwatch logo seochat tools logo