FAQ
Recently I had need of a unix2dos and dos2unix. I'd guess we've all
written multiple of versions of these, since there's not much to them.

This time I had a look at scripts section on CPAN, figuring there'd
be versions there. But there aren't.

So having knocked up them up, are they worth putting on CPAN?
And if so, what Category should they be given - Text?

Neil

Search Discussions

  • William R Ward at Mar 26, 2002 at 3:04 am

    Neil Bowers writes:
    Recently I had need of a unix2dos and dos2unix. I'd guess we've all
    written multiple of versions of these, since there's not much to them.

    This time I had a look at scripts section on CPAN, figuring there'd
    be versions there. But there aren't.

    So having knocked up them up, are they worth putting on CPAN?
    And if so, what Category should they be given - Text?
    What, you mean "perl -pe 's/\015\012/\n/g'" and "perl -pe 's/\n/\015\012/g'"?
    Doesn't seem like it's necessary to me to even bother uploading such a thing.

    If you're in the neighborhood though, how about mac2dos, mac2unix, unix2mac,
    and dos2mac? (Mac uses \015 only)

    --Bill.

    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    If you're not part of the solution, you're part of the precipitate.
  • Jarkko Hietaniemi at Mar 26, 2002 at 1:57 pm

    On Mon, Mar 25, 2002 at 07:04:37PM -0800, William R Ward wrote:
    neil@bowers.com (Neil Bowers) writes:
    Recently I had need of a unix2dos and dos2unix. I'd guess we've all
    written multiple of versions of these, since there's not much to them.

    This time I had a look at scripts section on CPAN, figuring there'd
    be versions there. But there aren't.

    So having knocked up them up, are they worth putting on CPAN?
    And if so, what Category should they be given - Text?
    What, you mean "perl -pe 's/\015\012/\n/g'" and "perl -pe 's/\n/\015\012/g'"?
    Doesn't seem like it's necessary to me to even bother uploading such a thing.
    So you think, but try working around non-UNIX and non-Perl people for
    a while, and the above are deep magic that bestows upon you the aura
    of a mighty guru.
    If you're in the neighborhood though, how about mac2dos, mac2unix, unix2mac,
    and dos2mac? (Mac uses \015 only)
    What would be cool is to have *one* script that sniffs which CR/LF is
    being used in the source file(s). The destination CR/LF would be by
    default the execution platform's, but could be forced to be something
    else. "crlf foo.txt", "crlf -t cr bar.txt".
    --Bill.

    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    If you're not part of the solution, you're part of the precipitate.
    --
    $jhi++; # http://www.iki.fi/jhi/
    # There is this special biologist word we use for 'stable'.
    # It is 'dead'. -- Jack Cohen
  • Neil Bowers at Mar 26, 2002 at 10:21 pm

    What, you mean "perl -pe 's/\015\012/\n/g'" and "perl -pe 's/\n/\015\012/g'"?
    Doesn't seem like it's necessary to me to even bother uploading such a thing.
    So you think, but try working around non-UNIX and non-Perl people for
    a while, and the above are deep magic that bestows upon you the aura
    of a mighty guru.
    Indeed. We have a bunch of people at my work who only know that text
    files
    from the unix machines come out "wrong" in certain programs on their PC.
    And that's OK, because understanding text formats and regular
    expressions
    isn't part of their job.

    Also, being lazy I'd rather not have to remember, or think about,
    the above, and just type unix2dos :-)

    If you're in the neighborhood though, how about mac2dos, mac2unix, unix2mac,
    and dos2mac? (Mac uses \015 only)
    What would be cool is to have *one* script that sniffs which CR/LF is
    being used in the source file(s). The destination CR/LF would be by
    default the execution platform's, but could be forced to be something
    else. "crlf foo.txt", "crlf -t cr bar.txt".
    How about a fixeol script? As you say, by default it would target the
    host platform, but you could do:

    fixeol -tomac foo.txt

    being a unix geek at heart, I think that this should look to see what
    name it was invoked under, and change its behaviour accordingly.
    But experience tells me better not to try and be that smart.

    Thinking about what most users want, a distribution which has

    unix2dos dos2unix
    dos2mac mac2dos
    unix2mac mac2unix

    wouldn't be too hard. I'd use the Template Toolkit to generate each of
    these from generic bits. The scripts are mainly documentation anyway :-)

    So yeah, this might seem overkill for what is essentially a simple job,
    but it would mean I only have to write one more version.

    And what's the script category? Text : Filter?

    Neil
  • Joshua Polterock at Mar 27, 2002 at 6:51 pm

    On Tue, 26 Mar 2002, Jarkko Hietaniemi wrote:
    On Mon, Mar 25, 2002 at 07:04:37PM -0800, William R Ward wrote:
    neil@bowers.com (Neil Bowers) writes:
    Recently I had need of a unix2dos and dos2unix. I'd guess we've all
    written multiple of versions of these, since there's not much to them.

    This time I had a look at scripts section on CPAN, figuring there'd
    be versions there. But there aren't.

    So having knocked up them up, are they worth putting on CPAN?
    And if so, what Category should they be given - Text?
    What, you mean "perl -pe 's/\015\012/\n/g'" and "perl -pe 's/\n/\015\012/g'"?
    Doesn't seem like it's necessary to me to even bother uploading such a thing.
    So you think, but try working around non-UNIX and non-Perl people for
    a while, and the above are deep magic that bestows upon you the aura
    of a mighty guru.
    If you're in the neighborhood though, how about mac2dos, mac2unix, unix2mac,
    and dos2mac? (Mac uses \015 only)
    What would be cool is to have *one* script that sniffs which CR/LF is
    being used in the source file(s). The destination CR/LF would be by
    default the execution platform's, but could be forced to be something
    else. "crlf foo.txt", "crlf -t cr bar.txt".
    --Bill.

    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    If you're not part of the solution, you're part of the precipitate.
    --
    Apologies, I consider myself an intermediate Perl programmer at best, but
    would something like this fit into this category. I realize it has a U*ix
    bent.

    A Perl script called crlf with the following.

    #!/usr/bin/perl -w

    use strict;
    use File::Basename;

    my $dos = "\015\012";
    my $mac = "\015";
    my $unix = "\n";
    my $myPlatform = "$unix";
    my $iam = basename($0);
    my $regexp = "";

    if( $iam eq 'crlf' ) {
    while(<STDIN>) {
    chop;
    print "$_" . $myPlatform;
    }
    } elsif( $iam eq 'dos2unix' ) { $regexp = "s/$dos/$unix/g"; }
    elsif( $iam eq 'unix2dos' ) { $regexp = "s/$unix/$dos/g"; }
    elsif( $iam eq 'mac2dos' ) { $regexp = "s/$mac/$dos/g"; }
    elsif( $iam eq 'mac2unix' ) { $regexp = "s/$mac/$unix/g"; }
    elsif( $iam eq 'dos2mac' ) { $regexp = "s/$dos/$mac/g"; }
    elsif( $iam eq 'unix2mac' ) { $regexp = "s/$unix/$mac/g";
    } else {
    die "I do not recognize my own name.";
    }

    while(<STDIN>) {
    eval $regexp;
    print;
    }

    exit(0);

    Rather than sniffing which eol gets fed in, I assume that if I don't
    know, I call the program as 'crlf' and chop the eol character regardless
    and print $myPlatform. It would be nice to automatically collect the
    platform.

    And a set of symbolic links, i.e.,

    $ ls -l crlf dos2unix dos2mac unix2dos unix2mac mac2dos mac2unix
    -rwxr-xr-x 1 uid gid 654 Mar 26 10:00 crlf
    lrwxrwxrwx 1 uid gid 4 Mar 26 10:01 dos2mac -> crlf
    lrwxrwxrwx 1 uid gid 4 Mar 26 10:01 dos2unix -> crlf
    lrwxrwxrwx 1 uid gid 4 Mar 26 10:01 mac2dos -> crlf
    lrwxrwxrwx 1 uid gid 4 Mar 26 10:01 mac2unix -> crlf
    lrwxrwxrwx 1 uid gid 4 Mar 26 10:01 unix2dos -> crlf
    lrwxrwxrwx 1 uid gid 4 Mar 26 10:01 unix2mac -> crlf

    Peace,
    Josh
  • William R Ward at Mar 27, 2002 at 7:33 pm

    Joshua Polterock writes:
    Apologies, I consider myself an intermediate Perl programmer at best, but
    would something like this fit into this category. I realize it has a U*ix
    bent.

    A Perl script called crlf with the following.
    [...]

    A sound implementation, but I think that all those evals will slow it
    down too much. How about something like this instead:

    #!/usr/bin/perl -w

    use strict;
    use File::Basename;

    my $dos = "\015\012";
    my $mac = "\015";
    my $unix = "\n";
    my $myPlatform = "$unix";
    my $iam = basename($0);
    my $regexp = "";

    $myPlatform = $mac if $^O =~ /mac/i;
    $myPlatform = $dos if $^O =~ /win|dos/i;

    my %subs = (
    crlf => sub { s/[\015\012]+/$myPlatform/ },
    dos2unix => sub { s/$dos/$unix/ },
    unix2dos => sub { s/$unix/$dos/ },
    mac2dos => sub { s/$mac/$dos/ },
    mac2unix => sub { s/$mac/$unix/ },
    dos2mac => sub { s/$dos/$mac/ },
    unix2mac => sub { s/$unix/$mac/ },
    );

    die "I do not recognize my own name."
    unless exists ($subs{$iam});

    my $sub = $subs{$iam};
    while(<STDIN>) {
    &$sub;
    print;
    }


    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    If you're not part of the solution, you're part of the precipitate.
  • Joshua Polterock at Mar 27, 2002 at 7:50 pm

    On Wed, 27 Mar 2002, William R Ward wrote:

    Joshua Polterock writes:
    Apologies, I consider myself an intermediate Perl programmer at best, but
    would something like this fit into this category. I realize it has a U*ix
    bent.

    A Perl script called crlf with the following.
    [...]

    A sound implementation, but I think that all those evals will slow it
    down too much. How about something like this instead:

    #!/usr/bin/perl -w

    use strict;
    use File::Basename;

    my $dos = "\015\012";
    my $mac = "\015";
    my $unix = "\n";
    my $myPlatform = "$unix";
    my $iam = basename($0);
    my $regexp = "";

    $myPlatform = $mac if $^O =~ /mac/i;
    $myPlatform = $dos if $^O =~ /win|dos/i;

    my %subs = (
    crlf => sub { s/[\015\012]+/$myPlatform/ },
    dos2unix => sub { s/$dos/$unix/ },
    unix2dos => sub { s/$unix/$dos/ },
    mac2dos => sub { s/$mac/$dos/ },
    mac2unix => sub { s/$mac/$unix/ },
    dos2mac => sub { s/$dos/$mac/ },
    unix2mac => sub { s/$unix/$mac/ },
    );

    die "I do not recognize my own name."
    unless exists ($subs{$iam});

    my $sub = $subs{$iam};
    while(<STDIN>) {
    &$sub;
    print;
    }


    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    If you're not part of the solution, you're part of the precipitate.
    Much better. This scales nicely.

    Josh
  • John Lenton at Mar 27, 2002 at 7:57 pm

    On Wed, Mar 27, 2002 at 11:33:45AM -0800, William R Ward wrote:
    my $unix = "\n";
    AFAIK, "\n" is only "\n" on unixoids; elsewhere it does what the
    OS needs to have print "hello, world?\n" Just Work(tm).

    --
    John Lenton (john@grulic.org.ar) -- Random fortune:
    Diferentes en la vida, los hombres son semejantes en la muerte.
    -- Lao Tse. (Siglo VI a.C.) Filósofo chino. Fundador del taoismo.
  • Jarkko Hietaniemi at Mar 27, 2002 at 8:05 pm

    On Wed, Mar 27, 2002 at 05:12:57PM -0300, John Lenton wrote:
    On Wed, Mar 27, 2002 at 11:33:45AM -0800, William R Ward wrote:
    my $unix = "\n";
    AFAIK, "\n" is only "\n" on unixoids; elsewhere it does what the
    OS needs to have print "hello, world?\n" Just Work(tm).
    Instead of using \n and \r I propose to use the explicit \x0D and \x0A.
    --
    John Lenton (john@grulic.org.ar) -- Random fortune:
    Diferentes en la vida, los hombres son semejantes en la muerte.
    -- Lao Tse. (Siglo VI a.C.) Filósofo chino. Fundador del taoismo.
    --
    $jhi++; # http://www.iki.fi/jhi/
    # There is this special biologist word we use for 'stable'.
    # It is 'dead'. -- Jack Cohen
  • William R Ward at Mar 27, 2002 at 8:12 pm
    Programming by committee! This is kind of fun, in a twisted way. OK,
    incorporating John's and Wade's suggestions:


    #!/usr/bin/perl -w

    use strict;
    use File::Basename;

    my $dos = "\015\012";
    my $mac = "\015";
    my $unix = "\012";
    my $myPlatform = "$unix";
    my $iam = basename($0);
    my $regexp = "";

    $myPlatform = $mac if $^O =~ /mac/i;
    $myPlatform = $dos if $^O =~ /win|dos/i;

    my %subs = (
    crlf => sub { s/[\015\012]+/$myPlatform/o },
    dos2unix => sub { s/$dos/$unix/o },
    unix2dos => sub { s/$unix/$dos/o },
    mac2dos => sub { s/$mac/$dos/o },
    mac2unix => sub { s/$mac/$unix/o },
    dos2mac => sub { s/$dos/$mac/o },
    unix2mac => sub { s/$unix/$mac/o },
    );

    die "I do not recognize my own name."
    unless exists ($subs{$iam});

    my $sub = $subs{$iam};
    while(<STDIN>) {
    &$sub;
    print;
    }


    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    If you're not part of the solution, you're part of the precipitate.
  • Brad Baxter at Mar 27, 2002 at 9:38 pm
    my $myPlatform = $unix;

    On Wed, 27 Mar 2002, William R Ward wrote:

    Programming by committee! This is kind of fun, in a twisted way. OK,
    incorporating John's and Wade's suggestions:


    #!/usr/bin/perl -w

    use strict;
    use File::Basename;

    my $dos = "\015\012";
    my $mac = "\015";
    my $unix = "\012";
    my $myPlatform = "$unix";
    my $iam = basename($0);
    my $regexp = "";

    $myPlatform = $mac if $^O =~ /mac/i;
    $myPlatform = $dos if $^O =~ /win|dos/i;

    my %subs = (
    crlf => sub { s/[\015\012]+/$myPlatform/o },
    dos2unix => sub { s/$dos/$unix/o },
    unix2dos => sub { s/$unix/$dos/o },
    mac2dos => sub { s/$mac/$dos/o },
    mac2unix => sub { s/$mac/$unix/o },
    dos2mac => sub { s/$dos/$mac/o },
    unix2mac => sub { s/$unix/$mac/o },
    );

    die "I do not recognize my own name."
    unless exists ($subs{$iam});

    my $sub = $subs{$iam};
    while(<STDIN>) {
    &$sub;
    print;
    }


    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    If you're not part of the solution, you're part of the precipitate.
  • William R Ward at Mar 27, 2002 at 9:46 pm

    Brad Baxter writes:
    my $myPlatform = $unix;
    Yeah, The quotes are unnecessary. I noticed that too, just after
    sending it, but it didn't seem important enough to bother with. Also
    $regexp is no longer used.

    --Bill.

    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    If you're not part of the solution, you're part of the precipitate.
  • Joshua Polterock at Mar 27, 2002 at 10:02 pm

    On Wed, 27 Mar 2002, William R Ward wrote:

    Programming by committee! This is kind of fun, in a twisted way. OK,
    incorporating John's and Wade's suggestions:
    All included, I believe we come to the version below.

    Do the '\x0D' and '\x0A', which appear to work fine on my Solaris 2.7 box,
    make this more portable? Also, do we still have platform-centricity in the

    my $unix = "\n";

    statement?

    Josh

    #!/usr/bin/perl -w

    use strict;
    use File::Basename;

    my $dos = "\x0D\x0A";
    my $mac = "\x0D";
    my $unix = "\n";
    my $myPlatform = $unix;
    my $iam = basename($0);

    $myPlatform = $mac if $^O =~ /mac/i;
    $myPlatform = $dos if $^O =~ /win|dos/i;

    my %subs = (
    crlf => sub { s/[$dos$mac$unix]+/$myPlatform/og },
    dos2unix => sub { s/$dos/$unix/o },
    unix2dos => sub { s/$unix/$dos/o },
    mac2dos => sub { s/$mac/$dos/o },
    mac2unix => sub { s/$mac/$unix/o },
    dos2mac => sub { s/$dos/$mac/o },
    unix2mac => sub { s/$unix/$mac/o },
    );

    die "I do not recognize my own name."
    unless exists ($subs{$iam});

    my $sub = $subs{$iam};
    while(<STDIN>) {
    &$sub;
    print;
    }

    exit(0);
  • Jarkko Hietaniemi at Mar 27, 2002 at 10:04 pm

    $myPlatform = $mac if $^O =~ /mac/i;
    $myPlatform = $dos if $^O =~ /win|dos/i;
    darwin owners will be upset :-)

    --
    $jhi++; # http://www.iki.fi/jhi/
    # There is this special biologist word we use for 'stable'.
    # It is 'dead'. -- Jack Cohen
  • William R Ward at Mar 27, 2002 at 11:21 pm

    Joshua Polterock writes:
    Do the '\x0D' and '\x0A', which appear to work fine on my Solaris 2.7 box,
    make this more portable? Also, do we still have platform-centricity in the

    my $unix = "\n";

    statement?
    \x0D is the same as \015, and \x0A is the same as \012. Hexadecimal
    (Base 16) vs. octal (base 8). I'm more used to octal for this sort
    of thing, but have no quarrel with using hexadecimal. However, \n
    should be \012 or \x0A, not \n.

    --Bill.

    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    If you're not part of the solution, you're part of the precipitate.
  • Brad Baxter at Mar 28, 2002 at 1:57 pm

    Re:

    crlf => sub { s/[$dos$mac$unix]+/$myPlatform/og },
    Three (hair-splitting) questions:

    1. Isn't [$dos$mac$unix]+ going to match the same as [$dos]+?
    2. Do you need 'g'?
    3. Can anyone benchmark whether s/[$dos]+$/$myPlatform/o is faster than
    s/[$dos]+/$myPlatform/o? It seems like it ought to be, but my efforts
    haven't proven it.

    Brad

    On Wed, 27 Mar 2002, Joshua Polterock wrote:

    On Wed, 27 Mar 2002, William R Ward wrote:

    Programming by committee! This is kind of fun, in a twisted way. OK,
    incorporating John's and Wade's suggestions:
    All included, I believe we come to the version below.

    Do the '\x0D' and '\x0A', which appear to work fine on my Solaris 2.7 box,
    make this more portable? Also, do we still have platform-centricity in the

    my $unix = "\n";

    statement?

    Josh

    #!/usr/bin/perl -w

    use strict;
    use File::Basename;

    my $dos = "\x0D\x0A";
    my $mac = "\x0D";
    my $unix = "\n";
    my $myPlatform = $unix;
    my $iam = basename($0);

    $myPlatform = $mac if $^O =~ /mac/i;
    $myPlatform = $dos if $^O =~ /win|dos/i;

    my %subs = (
    crlf => sub { s/[$dos$mac$unix]+/$myPlatform/og },
    dos2unix => sub { s/$dos/$unix/o },
    unix2dos => sub { s/$unix/$dos/o },
    mac2dos => sub { s/$mac/$dos/o },
    mac2unix => sub { s/$mac/$unix/o },
    dos2mac => sub { s/$dos/$mac/o },
    unix2mac => sub { s/$unix/$mac/o },
    );

    die "I do not recognize my own name."
    unless exists ($subs{$iam});

    my $sub = $subs{$iam};
    while(<STDIN>) {
    &$sub;
    print;
    }

    exit(0);

  • Joshua Polterock at Mar 28, 2002 at 4:17 pm

    On Thu, 28 Mar 2002, Brad Baxter wrote:

    Re:
    crlf => sub { s/[$dos$mac$unix]+/$myPlatform/og },
    Three (hair-splitting) questions:

    1. Isn't [$dos$mac$unix]+ going to match the same as [$dos]+? Yes.
    2. Do you need 'g'?
    I think this comes as a matter of taste. I generally like to globally
    replace strings of returns with a single new line. Including the 'g'
    switch compresses extra white space. Dropping the 'g' switch preserves
    extra white space. At least I see this when importing mac2unix.
    3. Can anyone benchmark whether s/[$dos]+$/$myPlatform/o is faster than
    s/[$dos]+/$myPlatform/o? It seems like it ought to be, but my efforts
    haven't proven it.
    I do not know if it runs faster, but the added '$' in the regular expression
    breaks the import I describe above when importing mac text with streams of
    returns.

    Josh
    Brad

    On Wed, 27 Mar 2002, Joshua Polterock wrote:

    On Wed, 27 Mar 2002, William R Ward wrote:

    Programming by committee! This is kind of fun, in a twisted way. OK,
    incorporating John's and Wade's suggestions:
    All included, I believe we come to the version below.

    Do the '\x0D' and '\x0A', which appear to work fine on my Solaris 2.7 box,
    make this more portable? Also, do we still have platform-centricity in the

    my $unix = "\n";

    statement?

    Josh

    #!/usr/bin/perl -w

    use strict;
    use File::Basename;

    my $dos = "\x0D\x0A";
    my $mac = "\x0D";
    my $unix = "\n";
    my $myPlatform = $unix;
    my $iam = basename($0);

    $myPlatform = $mac if $^O =~ /mac/i;
    $myPlatform = $dos if $^O =~ /win|dos/i;

    my %subs = (
    crlf => sub { s/[$dos$mac$unix]+/$myPlatform/og },
    dos2unix => sub { s/$dos/$unix/o },
    unix2dos => sub { s/$unix/$dos/o },
    mac2dos => sub { s/$mac/$dos/o },
    mac2unix => sub { s/$mac/$unix/o },
    dos2mac => sub { s/$dos/$mac/o },
    unix2mac => sub { s/$unix/$mac/o },
    );

    die "I do not recognize my own name."
    unless exists ($subs{$iam});

    my $sub = $subs{$iam};
    while(<STDIN>) {
    &$sub;
    print;
    }

    exit(0);

  • William R Ward at Mar 28, 2002 at 9:23 pm

    Brad Baxter writes:
    Re:
    crlf => sub { s/[$dos$mac$unix]+/$myPlatform/og },
    Three (hair-splitting) questions:

    1. Isn't [$dos$mac$unix]+ going to match the same as [$dos]+?
    Yes, that's true. It should probably be replaced with
    ($dos|$mac|$unix) to avoid problems when reading Mac files, since Mac
    files will be read in one big slurp (no "\n" characters found).
    2. Do you need 'g'?
    Yes, for slurping Mac files.
    3. Can anyone benchmark whether s/[$dos]+$/$myPlatform/o is faster than
    s/[$dos]+/$myPlatform/o? It seems like it ought to be, but my efforts
    haven't proven it.
    It would not be useful if you're reading Mac files.

    Hmm, in the case of xxx2yyy where the original file type is known,
    perhaps we should be setting the input file separator accordingly?
    That way, even Mac files will be read line-by-line.

    Also, in the line that sets $^O, change "win" to "mswin" to satisfy
    Darwin (Mac OS X) users. OSX uses the Unix standard, apparently.

    --Bill.

    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    If you're not part of the solution, you're part of the precipitate.
  • Wade Johnson at Mar 27, 2002 at 7:57 pm
    I'd make one more change.

    Add the 'o' option to the substitutions.

    my %subs = (
    crlf => sub { s/[\015\012]+/$myPlatform/o },
    dos2unix => sub { s/$dos/$unix/o },
    unix2dos => sub { s/$unix/$dos/o },
    mac2dos => sub { s/$mac/$dos/o },
    mac2unix => sub { s/$mac/$unix/o },
    dos2mac => sub { s/$dos/$mac/o },
    unix2mac => sub { s/$unix/$mac/o },
    );

    So that we don't recompile the regexp for each line in the program.

    G. Wade

    -----Original Message-----
    From: Joshua Polterock
    Sent: Wednesday, March 27, 2002 1:50 PM
    To: William R Ward
    Cc: Jarkko Hietaniemi; scripts@perl.org
    Subject: Re: unix2dos and dos2unix

    On Wed, 27 Mar 2002, William R Ward wrote:

    Joshua Polterock writes:
    Apologies, I consider myself an intermediate Perl programmer at best, but
    would something like this fit into this category. I realize it has a U*ix
    bent.

    A Perl script called crlf with the following.
    [...]

    A sound implementation, but I think that all those evals will slow it
    down too much. How about something like this instead:

    #!/usr/bin/perl -w

    use strict;
    use File::Basename;

    my $dos = "\015\012";
    my $mac = "\015";
    my $unix = "\n";
    my $myPlatform = "$unix";
    my $iam = basename($0);
    my $regexp = "";

    $myPlatform = $mac if $^O =~ /mac/i;
    $myPlatform = $dos if $^O =~ /win|dos/i;

    my %subs = (
    crlf => sub { s/[\015\012]+/$myPlatform/ },
    dos2unix => sub { s/$dos/$unix/ },
    unix2dos => sub { s/$unix/$dos/ },
    mac2dos => sub { s/$mac/$dos/ },
    mac2unix => sub { s/$mac/$unix/ },
    dos2mac => sub { s/$dos/$mac/ },
    unix2mac => sub { s/$unix/$mac/ },
    );

    die "I do not recognize my own name."
    unless exists ($subs{$iam});

    my $sub = $subs{$iam};
    while(<STDIN>) {
    &$sub;
    print;
    }


    --
    William R Ward bill@wards.net
    http://www.wards.net/~bill/
    >
    ----------------------------------------------------------------------------
    -
    If you're not part of the solution, you're part of the precipitate.
    Much better. This scales nicely.

    Josh
  • Neil Bowers at Apr 2, 2002 at 2:00 pm
    So now how about wrapping this up in a module, and having the script
    use that? That way Ronald's CGI could use it. Also I notice that
    Mark Veltzer's Meta distribution has a subset of this functionality,
    in Meta::Utils::Dos. Wouldn't be surprised if other people have modules
    doing some of this stuff too.

    Text::CRLF? Interface?

    $crlf = Text::CRLF->new();

    # default behaviour - convert to my platform, from STDIN to STDOUT
    $crlf->convert();

    # a dos2unix filter
    $crlf->dos2unix($INFILE, $OUTFILE);

    # i don't care where it came from, just where it's going
    $crlf->to_unix($INFILE, $OUTFILE);

    Hmm, you can't have a sub called 2unix(), so maybe the other methods
    should be called dos_to_unix ...?

    I'll write the testsuite.

    Neil
  • William R Ward at Apr 2, 2002 at 8:59 pm

    Neil Bowers writes:
    So now how about wrapping this up in a module, and having the script
    use that? That way Ronald's CGI could use it. Also I notice that
    Mark Veltzer's Meta distribution has a subset of this functionality,
    in Meta::Utils::Dos. Wouldn't be surprised if other people have modules
    doing some of this stuff too.

    Text::CRLF? Interface?

    $crlf = Text::CRLF->new();

    # default behaviour - convert to my platform, from STDIN to STDOUT
    $crlf->convert();

    # a dos2unix filter
    $crlf->dos2unix($INFILE, $OUTFILE);

    # i don't care where it came from, just where it's going
    $crlf->to_unix($INFILE, $OUTFILE);

    Hmm, you can't have a sub called 2unix(), so maybe the other methods
    should be called dos_to_unix ...?

    I'll write the testsuite.
    OK, here's my idea for such a module... Its AUTOLOAD function
    supports methods named X2Y, X_to_Y, XtoY, X_toY, or Xto_Y. Or simply
    toY, to_Y, or _to_Y. Or convert() as in your example. You can use
    uppercase letters if you like; it's case-insensitive. X and Y are one
    of "crlf", "cr", "lf", or any of several aliases for these:
    * Instead of "crlf" you can say "dos," "windows," "win32," or "mswin."
    * For "lf" you can say "unix," "linux," "darwin," or "osx."
    * For "cr" you can say "mac" or "macos."
    Again, these are case-insensitive, so "DOS2UNIX" or "MacOS9ToDarwin".

    I got a little carried away with the Mac regexp's, I'm afraid.
    For OSX (Darwin), I match mac(intosh)?os(x|1[0-9])
    For all other Mac's, it uses mac(intosh)?(os[1-9])?
    It seems to work, though...

    Also, if you don't feel like using OO syntax, you can also import
    methods. If you say "use Text::CRLF 'dos2unix'" then that function
    will be available in your current package. It uses the object
    $DEFAULT in the Text::CRLF package and calls the appropriate method.

    I need to write more comments, but here's the code anyway...



    package Text::CRLF;

    use strict;
    use vars qw($AUTOLOAD $DEFAULT);

    my $crlf = "\x0D\x0A";
    my $cr = "\x0D";
    my $lf = "\x0A";

    my $myPlatform = $lf;
    $myPlatform = $cr if $^O =~ /mac/i;
    $myPlatform = $crlf if $^O =~ /mswin|dos/i;

    my %subs = (
    convert => sub { s/($crlf|$cr|$lf)/$myPlatform/og },
    crlf2lf => sub { s/$crlf/$lf/og },
    lf2crlf => sub { s/$lf/$crlf/og },
    cr2crlf => sub { s/$cr/$crlf/og },
    cr2lf => sub { s/$cr/$lf/og },
    crlf2cr => sub { s/$crlf/$cr/og },
    lf2cr => sub { s/$lf/$cr/og },
    "2crlf" => sub { s/($crlf|$cr|$lf)/$crlf/og },
    "2cr" => sub { s/($crlf|$cr|$lf)/$cr/og },
    "2lf" => sub { s/($crlf|$cr|$lf)/$lf/og },
    );

    sub DESTROY { }

    sub AUTOLOAD
    {
    my($self, @args) = @_;
    my($pack, $func) = ($AUTOLOAD =~ /^(.+)::(.+)$/);
    $func = lc $func; # Case insensitive
    $func =~ s/_?to_?/2/; # Allow "crlf_to_lf" if user prefers
    $func =~ s/unix|linux|darwin|mac(intosh)?os(x|1[0-9])/lf/g;
    $func =~ s/mac(intosh)?(os[1-9])?/cr/g;
    $func =~ s/dos|windows|win32|mswin/crlf/g;

    die qq/Can't locate object method "$func" via package "$pack"/
    unless exists $subs{$func};

    my $sub = $subs{$func};
    foreach (@args)
    {
    $_ = join('', <$_>)
    if (ref $_ && (ref $_ eq 'GLOB') || $_->isa("IO::Handle"));
    &$sub;
    }
    wantarray ? @args : (@args ? \@args : $args[0]);
    }

    $SIG{ALRM} = sub { die "alarm" };
    alarm(10);

    sub import
    {
    my($pkg, @funcs) = @_;
    my $callpkg = caller(0);
    $DEFAULT = new $pkg;
    foreach my $f (@funcs)
    {
    eval "sub exp_$f { \$DEFAULT->$f(\@_); }";
    die "eval failed: $@" if $@;
    eval '*'.$callpkg.'::'.$f.' = \&exp_'.$f;
    die "eval failed: $@" if $@;
    }
    }

    sub new
    {
    my $class = shift;
    bless { @_ } => $class;
    }

    1;


    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    If you're not part of the solution, you're part of the precipitate.
  • William R Ward at May 7, 2002 at 3:18 am
    So, what's the latest with this? I can just upload the module I
    posted to CPAN but I'd like to have some consensus around this...

    --Bill.


    bill@wards.net (William R Ward) writes:
    neil@bowers.com (Neil Bowers) writes:
    So now how about wrapping this up in a module, and having the script
    use that? That way Ronald's CGI could use it. Also I notice that
    Mark Veltzer's Meta distribution has a subset of this functionality,
    in Meta::Utils::Dos. Wouldn't be surprised if other people have modules
    doing some of this stuff too.

    Text::CRLF? Interface?

    $crlf = Text::CRLF->new();

    # default behaviour - convert to my platform, from STDIN to STDOUT
    $crlf->convert();

    # a dos2unix filter
    $crlf->dos2unix($INFILE, $OUTFILE);

    # i don't care where it came from, just where it's going
    $crlf->to_unix($INFILE, $OUTFILE);

    Hmm, you can't have a sub called 2unix(), so maybe the other methods
    should be called dos_to_unix ...?

    I'll write the testsuite.
    OK, here's my idea for such a module... Its AUTOLOAD function
    supports methods named X2Y, X_to_Y, XtoY, X_toY, or Xto_Y. Or simply
    toY, to_Y, or _to_Y. Or convert() as in your example. You can use
    uppercase letters if you like; it's case-insensitive. X and Y are one
    of "crlf", "cr", "lf", or any of several aliases for these:
    * Instead of "crlf" you can say "dos," "windows," "win32," or "mswin."
    * For "lf" you can say "unix," "linux," "darwin," or "osx."
    * For "cr" you can say "mac" or "macos."
    Again, these are case-insensitive, so "DOS2UNIX" or "MacOS9ToDarwin".

    I got a little carried away with the Mac regexp's, I'm afraid.
    For OSX (Darwin), I match mac(intosh)?os(x|1[0-9])
    For all other Mac's, it uses mac(intosh)?(os[1-9])?
    It seems to work, though...

    Also, if you don't feel like using OO syntax, you can also import
    methods. If you say "use Text::CRLF 'dos2unix'" then that function
    will be available in your current package. It uses the object
    $DEFAULT in the Text::CRLF package and calls the appropriate method.

    I need to write more comments, but here's the code anyway...



    package Text::CRLF;

    use strict;
    use vars qw($AUTOLOAD $DEFAULT);

    my $crlf = "\x0D\x0A";
    my $cr = "\x0D";
    my $lf = "\x0A";

    my $myPlatform = $lf;
    $myPlatform = $cr if $^O =~ /mac/i;
    $myPlatform = $crlf if $^O =~ /mswin|dos/i;

    my %subs = (
    convert => sub { s/($crlf|$cr|$lf)/$myPlatform/og },
    crlf2lf => sub { s/$crlf/$lf/og },
    lf2crlf => sub { s/$lf/$crlf/og },
    cr2crlf => sub { s/$cr/$crlf/og },
    cr2lf => sub { s/$cr/$lf/og },
    crlf2cr => sub { s/$crlf/$cr/og },
    lf2cr => sub { s/$lf/$cr/og },
    "2crlf" => sub { s/($crlf|$cr|$lf)/$crlf/og },
    "2cr" => sub { s/($crlf|$cr|$lf)/$cr/og },
    "2lf" => sub { s/($crlf|$cr|$lf)/$lf/og },
    );

    sub DESTROY { }

    sub AUTOLOAD
    {
    my($self, @args) = @_;
    my($pack, $func) = ($AUTOLOAD =~ /^(.+)::(.+)$/);
    $func = lc $func; # Case insensitive
    $func =~ s/_?to_?/2/; # Allow "crlf_to_lf" if user prefers
    $func =~ s/unix|linux|darwin|mac(intosh)?os(x|1[0-9])/lf/g;
    $func =~ s/mac(intosh)?(os[1-9])?/cr/g;
    $func =~ s/dos|windows|win32|mswin/crlf/g;

    die qq/Can't locate object method "$func" via package "$pack"/
    unless exists $subs{$func};

    my $sub = $subs{$func};
    foreach (@args)
    {
    $_ = join('', <$_>)
    if (ref $_ && (ref $_ eq 'GLOB') || $_->isa("IO::Handle"));
    &$sub;
    }
    wantarray ? @args : (@args ? \@args : $args[0]);
    }

    $SIG{ALRM} = sub { die "alarm" };
    alarm(10);

    sub import
    {
    my($pkg, @funcs) = @_;
    my $callpkg = caller(0);
    $DEFAULT = new $pkg;
    foreach my $f (@funcs)
    {
    eval "sub exp_$f { \$DEFAULT->$f(\@_); }";
    die "eval failed: $@" if $@;
    eval '*'.$callpkg.'::'.$f.' = \&exp_'.$f;
    die "eval failed: $@" if $@;
    }
    }

    sub new
    {
    my $class = shift;
    bless { @_ } => $class;
    }

    1;


    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    If you're not part of the solution, you're part of the precipitate.
    --
    William R Ward bill@wards.net http://www.wards.net/~bill/
    -----------------------------------------------------------------------------
    AMAZING BUT TRUE: There is so much sand in northern Africa that if it were
    spread out it would completely cover the Sahara Desert!
  • Wade Johnson at Mar 28, 2002 at 4:24 pm
    I think the 'g' breaks '$' processing because Unix would read the
    whole Mac file in as a single line. (No "\n" characters.) This brings
    up another useful point, if Mac files are read in as a single line,
    then the 'g' option would be _required_ in order to process all lines.

    Probably worth a check to see if Perl under Unix would actually read
    a whole Mac file in in one slurp.

    The 'g' should not, in general, have any effect on whitespace.
    However, the [$dos]+ would gobble up extra empty lines from a mac
    file, because the whole file is loaded at once.

    G. Wade

    -----Original Message-----
    From: Joshua Polterock
    Sent: Thursday, March 28, 2002 10:17 AM
    To: Brad Baxter
    Cc: scripts@perl.org
    Subject: Re: unix2dos and dos2unix

    On Thu, 28 Mar 2002, Brad Baxter wrote:

    Re:
    crlf => sub { s/[$dos$mac$unix]+/$myPlatform/og },
    Three (hair-splitting) questions:

    1. Isn't [$dos$mac$unix]+ going to match the same as [$dos]+? Yes.
    2. Do you need 'g'?
    I think this comes as a matter of taste. I generally like to globally
    replace strings of returns with a single new line. Including the 'g'
    switch compresses extra white space. Dropping the 'g' switch preserves
    extra white space. At least I see this when importing mac2unix.
    3. Can anyone benchmark whether s/[$dos]+$/$myPlatform/o is faster than
    s/[$dos]+/$myPlatform/o? It seems like it ought to be, but my efforts
    haven't proven it.
    I do not know if it runs faster, but the added '$' in the regular expression
    breaks the import I describe above when importing mac text with streams of
    returns.

    Josh
    Brad

    On Wed, 27 Mar 2002, Joshua Polterock wrote:

    On Wed, 27 Mar 2002, William R Ward wrote:

    Programming by committee! This is kind of fun, in a twisted way. OK,
    incorporating John's and Wade's suggestions:
    All included, I believe we come to the version below.

    Do the '\x0D' and '\x0A', which appear to work fine on my Solaris 2.7
    box,
    make this more portable? Also, do we still have platform-centricity in
    the
    my $unix = "\n";

    statement?

    Josh

    #!/usr/bin/perl -w

    use strict;
    use File::Basename;

    my $dos = "\x0D\x0A";
    my $mac = "\x0D";
    my $unix = "\n";
    my $myPlatform = $unix;
    my $iam = basename($0);

    $myPlatform = $mac if $^O =~ /mac/i;
    $myPlatform = $dos if $^O =~ /win|dos/i;

    my %subs = (
    crlf => sub { s/[$dos$mac$unix]+/$myPlatform/og },
    dos2unix => sub { s/$dos/$unix/o },
    unix2dos => sub { s/$unix/$dos/o },
    mac2dos => sub { s/$mac/$dos/o },
    mac2unix => sub { s/$mac/$unix/o },
    dos2mac => sub { s/$dos/$mac/o },
    unix2mac => sub { s/$unix/$mac/o },
    );

    die "I do not recognize my own name."
    unless exists ($subs{$iam});

    my $sub = $subs{$iam};
    while(<STDIN>) {
    &$sub;
    print;
    }

    exit(0);

  • Joshua Polterock at Mar 28, 2002 at 5:27 pm
    Perl under Unix happily slurps the entire Mac file. I'm playing with a
    version that 'buffers' the entire input stream rather than handling
    line-by-line in all cases. For extremely large files this may break if
    you run out of resources, but it seems pretty fast and means I handle
    all cases consistently.

    Josh
    On Thu, 28 Mar 2002, Wade Johnson wrote:

    I think the 'g' breaks '$' processing because Unix would read the
    whole Mac file in as a single line. (No "\n" characters.) This brings
    up another useful point, if Mac files are read in as a single line,
    then the 'g' option would be _required_ in order to process all lines.

    Probably worth a check to see if Perl under Unix would actually read
    a whole Mac file in in one slurp.

    The 'g' should not, in general, have any effect on whitespace.
    However, the [$dos]+ would gobble up extra empty lines from a mac
    file, because the whole file is loaded at once.

    G. Wade

    -----Original Message-----
    From: Joshua Polterock
    Sent: Thursday, March 28, 2002 10:17 AM
    To: Brad Baxter
    Cc: scripts@perl.org
    Subject: Re: unix2dos and dos2unix

    On Thu, 28 Mar 2002, Brad Baxter wrote:

    Re:
    crlf => sub { s/[$dos$mac$unix]+/$myPlatform/og },
    Three (hair-splitting) questions:

    1. Isn't [$dos$mac$unix]+ going to match the same as [$dos]+? Yes.
    2. Do you need 'g'?
    I think this comes as a matter of taste. I generally like to globally
    replace strings of returns with a single new line. Including the 'g'
    switch compresses extra white space. Dropping the 'g' switch preserves
    extra white space. At least I see this when importing mac2unix.
    3. Can anyone benchmark whether s/[$dos]+$/$myPlatform/o is faster than
    s/[$dos]+/$myPlatform/o? It seems like it ought to be, but my efforts
    haven't proven it.
    I do not know if it runs faster, but the added '$' in the regular expression
    breaks the import I describe above when importing mac text with streams of
    returns.

    Josh
    Brad

    On Wed, 27 Mar 2002, Joshua Polterock wrote:

    On Wed, 27 Mar 2002, William R Ward wrote:

    Programming by committee! This is kind of fun, in a twisted way. OK,
    incorporating John's and Wade's suggestions:
    All included, I believe we come to the version below.

    Do the '\x0D' and '\x0A', which appear to work fine on my Solaris 2.7
    box,
    make this more portable? Also, do we still have platform-centricity in
    the
    my $unix = "\n";

    statement?

    Josh

    #!/usr/bin/perl -w

    use strict;
    use File::Basename;

    my $dos = "\x0D\x0A";
    my $mac = "\x0D";
    my $unix = "\n";
    my $myPlatform = $unix;
    my $iam = basename($0);

    $myPlatform = $mac if $^O =~ /mac/i;
    $myPlatform = $dos if $^O =~ /win|dos/i;

    my %subs = (
    crlf => sub { s/[$dos$mac$unix]+/$myPlatform/og },
    dos2unix => sub { s/$dos/$unix/o },
    unix2dos => sub { s/$unix/$dos/o },
    mac2dos => sub { s/$mac/$dos/o },
    mac2unix => sub { s/$mac/$unix/o },
    dos2mac => sub { s/$dos/$mac/o },
    unix2mac => sub { s/$unix/$mac/o },
    );

    die "I do not recognize my own name."
    unless exists ($subs{$iam});

    my $sub = $subs{$iam};
    while(<STDIN>) {
    &$sub;
    print;
    }

    exit(0);

  • Ronaldws at Mar 28, 2002 at 10:46 pm
    Any interest in CGI versions of these applications. I have some prototypes
    at http://www.software-path.com/olapp.html. They were written some time ago
    in Perl. If there is interest I would clean up and release the source.

    Ronald Schmidt
  • Ronaldws at Apr 3, 2002 at 10:37 pm
    I have put the somewhat cleaned up code to the line ending conversion cgi
    below and attached it to this message. It all does begin to seem a bit like
    Rube Goldberg's razor (to use a mixed metaphor). Is this wanted on CPAN?
    Please read the header comment before playing with it. You can see it in use
    without installing at at

    http://www.software-path.com/olapp.html

    Enjoy,
    Ronald Schmidt


    ##########################################################################
    #
    # line_end.cgi
    #
    # Text file line ending conversion cgi script. Allows for conversion
    # of dos/win text files to and from unix and similarly for mac.
    #
    # Presents two kinds of user interfaces.
    # 1) generic
    # This is presented by default if the justconvert parameter is
    # not specified. It presents a pull down menu of platforms for
    # conversion and generic instructions.
    # 2) specific
    # If the justconvert parameter is present:
    # e.g. http://mysite/cgi-bin/line_end.cgi?justconvert=unix2dos
    # then a form will presented without a pull down menu and with
    # specific instructions describing the particular conversion intended.
    # This optimizes for simplicity for the end user.
    #
    # Prerequisite: Text::CRLF
    #
    # Written by RonaldWS@software-path.com: Ronald Schmidt
    #
    ##########################################################################


    use strict;

    use Text::CRLF;
    use Data::Dumper;

    use CGI qw/:standard/;
    use CGI::Carp 'fatalsToBrowser';
    $CGI::POST_MAX=1024 * 1024; # max 1Meg posts

    ##########################################################################
    # If the OS/platform you need for conversion is not listed in the
    # platform drop down menu you can add it here. Platform names supported
    # by Text::CRLF will also be supported by this program.
    ##########################################################################
    my @platform_select = (
    'unix2dos', 'dos2unix', 'mac2dos', 'mac2unix', 'dos2mac', 'unix2mac',
    '2dos', '2unix', '2mac'
    );
    my %platform_select_labels = (
    $platform_select[0] => 'UNIX to Dos/Windows',
    $platform_select[1] => 'Dos/Windows to UNIX',
    $platform_select[2] => 'Macintosh to Dos/Windows',
    $platform_select[3] => 'Macintosh to Dos/Windows',
    $platform_select[4] => 'Dos/Windows to Macintosh',
    $platform_select[5] => 'UNIX to Macintosh',
    $platform_select[6] => 'UNIX or Mac to Dos/Windows',
    $platform_select[7] => 'Dos/Windows or Mac to UNIX',
    $platform_select[8] => 'Dos/Windows or UNIX to Mac'
    );

    ##########################################################################
    # start of main logic
    ##########################################################################

    # convert and return the input file
    if (param('input_file')) {
    my ($platform) = (param('platform') =~ /^(\w*?2\w+)$/); # launder
    my $input_fh = param('input_file');
    binmode($input_fh); # allow running under win/dos too
    bless $input_fh, 'IO::Handle'; # persuade CRLF its a file handle

    my $output_file = eval "Text::CRLF::$platform(undef, \$input_fh)";
    my $output_fn = param('output_file');

    print <<EOT;
    Content-Disposition: attachment; filename="$output_fn"
    Content-Type: application/octet-stream

    EOT
    print $output_file->[0];
    }

    # the input was too big - some fuss with eval for backwards compatibility
    elsif (my $too_big = eval "cgi_error()") {
    print header(-status=> $too_big ), start_html,
    h1($too_big),
    end_html;
    }

    # present the form to allow input of files etc.
    else {
    my ($just_convert, $jc_from, $jc_to);
    my ($title, $small_header, $submit_text);
    if (param('justconvert') && (param('justconvert') =~ /(\w*?)2(\w+)/)) {
    $just_convert = 1;
    $jc_from = $1;
    $jc_to = $2;
    }

    # set up explanations/descriptions used on form based on specific
    # conversion requested or (! $just_convert) generic instructions.
    if ($just_convert) {
    if ($jc_from) {
    $title = "CGI $jc_from line ending to $jc_to " .
    'line ending facility.';
    $submit_text =
    "$jc_from line ending to $jc_to line ending";
    }
    else {
    $title = "CGI conversion to $jc_to line ending " .
    'facility.';
    $submit_text =
    "Convert to $jc_to line ending";
    }
    $small_header = 'Select a file on your machine.';

    }
    else {
    $title = 'Line ending conversion program.';
    $small_header = 'Select a platform conversion and file on '.
    'your machine.';
    $submit_text = 'Convert file';
    }

    # helps set output file name in dialog in some end cases
    my $JSCRIPT=<<END;
    function set_download_file() {
    if (document.forms["line_end"].output_file.value.length > 0) {
    document.forms["line_end"].action += "/" +
    document.forms["line_end"].output_file.value;
    }
    else if (document.forms["line_end"].input_file.value.length > 0) {
    document.forms["line_end"].action += "/" +
    document.forms["line_end"].input_file.value;
    }
    }
    END

    print header, start_html(
    -title => $title,
    -script => $JSCRIPT,
    -BGCOLOR => 'white'
    ),
    h1($title),
    h2("$small_header\n" .
    'Submit the form to convert the file.'),
    start_form(
    -method => 'POST',
    -enctype => &CGI::MULTIPART,
    -action => $ENV{'SCRIPT_NAME'},
    -name => 'line_end',
    -onSubmit => 'set_download_file()'
    );

    if ($just_convert) {
    print hidden(-name => 'platform',
    -value => lc(param('justconvert')));
    }
    else {
    print p(), "Platforms ";
    print popup_menu(
    -name => 'platform',
    -values => \@platform_select,
    -labels => \%platform_select_labels
    );
    }

    print p(), "Input File ", filefield(-name => 'input_file',
    -size => 30);
    print p(), 'Output File ', textfield(-name => 'output_file');
    print br, br, submit(-value => $submit_text), hr;

    print end_form, end_html;
    }
  • Ronaldws at Apr 3, 2002 at 10:43 pm

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupscripts @
categoriesperl
postedMar 24, '02 at 9:35p
activeMay 7, '02 at 3:18a
posts27
users8
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase