Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -w # Thanks to folks on comp.lang.perl.misc for a few tips. use strict; use Convert::UU qw/uudecode/; die "Filename required\n" unless $ARGV[0]; my $file = shift; print "Parsing $file ...\n\n"; open (FILE, "<", $file) or die "Can't open file for reading: $!\n"; my ($data, $tempfile, $tempmode); MAIN: while (<FILE>) { next MAIN unless /^begin / .. /^end\s+/; INNER: { # extract the filename. If we already have a filename, it's a pos +sible short file in the data file, so reset everything. Could all of +this be done better somehow? if ( /^begin / ) { if ($tempfile) { print "Warning: possible short file $tempfile found\n\n"; $data = ''; } # if ($tempfile) ($tempmode, $tempfile) = ( /\Abegin (\d+) (.*)$/m); last INNER; } # if ( /^begin/ ) last INNER if /^end\s+/; # Last line of data. next MAIN if /[a-z]/; # Skip non-data lines next MAIN if /^\s+$/; # And again } #end of INNER $data .= $_; if ( /^end\s+/ ) { my $filename = $tempfile; my $mode = $tempmode; print "Found uuencoded file $filename\n"; my $outstr = uudecode($data); if (-e $filename) { print "Error, $filename already exists. Ignoring\n\n"; $data = ''; $tempfile = ''; $filename = ''; next MAIN; } open (OUTFILE, ">", $filename) or die "Can't open $filename for writing: $!\n"; print "Writing to $filename ...\n\n"; print OUTFILE $outstr; close OUTFILE; system ("chmod", $mode, $filename) and warn "Unable to change perms of $filename: $!\n"; $data = ''; $tempfile = ''; $filename = ''; } } close (FILE)

*BEEEP*

Code reposted on 4-27-02 so it doesn't appear to be double-spaced when viewed without code wrapping (I hope).

Bah! Updated again on 5-13-02, this time in Netscape, which hopefully won't insert extra ^Ms, like Opera does, apparently.


In reply to A better (?) uudecoder. by mephit

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 avoiding work at the Monastery: (2)
As of 2024-04-25 19:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found