Thanks to all of you for the responses.
I'm trying to re-learn, eventually master, programming in Ada.
As simple learning exercises, I'm trying to perform **minimal** emulation of several UNIX/Linux tools/utilities (such as grep, cat, head, wc, etc) using Ada.
I'd like to avoid disabling my terminal by using any of these emulations on a "binary" file, so I'd like to use "file" or "perl -T" in Ada via a system call.
I'm not good enough at Ada at this point to enable my own "-T" file operator, but that's one of the many things I'm aiming for.
I'd sure like to know how Perl determines ("heuristic guess" says perldoc!) that the file is or is not a binary so that I can do that in Ada.
I like the warning I get when using "less" with a file with binary content; it warns me! How does it determine that?
The problem I still have with the Perl one-liner is that I don't know how to embed the filename I want to query inside double quotes or how to escape the slash path separators so that it is not interpreted as a regex.
The reason why I went with the "perl -T" route over the "file" route was that I wanted a simple "text" or "binary" response, nothing I needed to parse further.
Thanks,
Ken Wolcott
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.