Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I quickly reformatted this with Perl::Tidy straight out of the box (no options). Check it out. It was fun to use. ;-)

#!/usr/bin/perl use strict; use warnings; use diagnostics; use Data::Dumper; use Win32::Autoglob; use Cwd; my $keepgoing = "keepgoing"; my @globline; my @argdata; my $mastercount = 0; my $chunklock = "orderlock.cfg"; my $successcheck = "successcheck.cfg"; my $chunksuccesscount = "successlog1.cfg"; my $orderline = "orderline.cfg"; my $trackingversion = 0; # 0 is ORDER 1 = Trackin +g # DoOrd.pl * #### SHIPPINGVERSION #system("pause"); if ( $trackingversion == 0 ) { foreach my $thing (@ARGV) { if ( ( $thing =~ /A-/ ) && ( $thing =~ /.txt/ ) ) { push( @argdata, $thing ); } } # REPLACE FILENAME (ADD A UNIQUE NUMBER) + MOVE TO LIMBO foreach (@argdata) { @datain = (); $oldfilename = $_; open( DGRAB, $oldfilename ) || die("Could not open $oldfilename (DATA TO GRAB) \n"); while (<DGRAB>) { push( @datain, $_ ) } close DGRAB; my $movefilename = @datain[2]; $movefilename =~ s/ /-/g; $movefilename =~ s/[^\w\d()-]+//g; my $range = 8999; my $minimum = 1000; my $random_number = int( rand($range) ) + $minimum; $movefilename = "A-" . $movefilename . "--" . $random_number . + ".txt"; push( @newargdata, $movefilename ); system("move $oldfilename limbo/$movefilename"); } # FOREACH # ASSIGN NEW FILENAME FROM ORDERNAME @argdata = @newargdata; # DUPLICATE FOR MULTIPLE QUANTITIES foreach (@argdata) { @datain = (); my $originalfilenamequantity = ""; $filenamequantity = "limbo/" . $_; open( DGRAB, $filenamequantity ) || die("Could not open $filenamequantity (DATA TO GRAB) \n") +; while (<DGRAB>) { push( @datain, $_ ) } close DGRAB; print "$filenamequantity LOADED \n"; foreach (@datain) { if ( $_ =~ /QUANTITY:::/ ) { print "Q \n"; @quantitysplit1 = split( /QUANTITY:::/, $_ ); @quantitysplit2 = split( /:::/, @quantitysplit +1[1] ); $quantityvalue = @quantitysplit2[0]; print "@quantitysplit1[1] Quantityvalue: $quantityvalu +e \n\n"; } } # DUPLICATE ORDER BASED ON QUANTITY AMOUNTS if ( $quantityvalue > 1 ) { my $originalfilenamequantity = $filenamequantity; # CREATE DUPLICATES BASED ON QUANT +ITY for ( my $count = 1 ; $count <= $quantityvalue ; $count++ +) { @copydatain = (); open( DGRAB, $filenamequantity ) || die("Could not open $filenamequantity (DATA TO GR +AB) \n"); while (<DGRAB>) { push( @copydatain, $_ ) } close DGRAB; my $copydatainstring = join( '', @copydatain ); my $quantitytoreplacestring = "QUANTITY:::" . $quantityvalue . ":::"; $copydatainstring =~ s/$quantitytoreplacestring/QUANTITY:::1:::/; my $duplicatefilenamequantity = $filenamequantity . $c +ount; open( DGRAB, ">$duplicatefilenamequantity" ); print DGRAB "$copydatainstring"; close(DGRAB); } # IF $quantityvalue > 1 ########## PROBLEM IS HERE ########## PROBLEM IS HERE ########## PROBLEM IS HERE # MOVE ORIGINAL TO ../Done/M-archiv # $originalfilenamequantity =~ s/limbo\///; # tried short fuilenames l +ong filenames... yada yada $currentdir = getcwd; $originalfilenamequantity = $currentdir . "/" . $originalfilenamequantity; print "Currentdir : $currentdir \n FILE: :$originalfilenamequantity: \n"; print "move $originalfilenamequantity 1.txt \n"; system("move $originalfilenamequantity .."); } # FOREACH (@datain) } # foreach die; ########## PROBLEM IS HERE ########## PROBLEM IS HERE ########## PROBLEM IS HERE


"...the adversities born of well-placed thoughts should be considered mercies rather than misfortunes." Don Quixote

In reply to Re: FIle Directory Problem (w/Perl::Tidy) by luis.roca
in thread FIle Directory Problem Driving me crazy. by Monkomatic

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (4)
    As of 2021-04-11 16:52 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?