[16858] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4270 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 9 06:05:29 2000

Date: Sat, 9 Sep 2000 03:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968493910-v9-i4270@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 9 Sep 2000     Volume: 9 Number: 4270

Today's topics:
        [Q] $_ assignmt in map: bug? (R. S. K.)
        ANNOUNCE: Inline 0.25 "Use C in Perl with no Sticky Res <brian@ingerson.com>
    Re: Background process (Martien Verbruggen)
    Re: Commercial websites using perl (Maggert)
        Converting PHP to Perl - Expert needed ! <Sunil@dukeswell.co.uk>
    Re: Environment variables - how to list them all? (Craig Berry)
    Re: Environment variables - how to list them all? <brian+usenet@smithrenaud.com>
    Re: Environment variables - how to list them all? (Martien Verbruggen)
    Re: fgrep -i  "greek_word" DOES NOT WORK (Martien Verbruggen)
    Re: How can I extract files from a file? I'm using linu (Richard)
    Re: How to find unused variables? <sallan@nwlink.com>
    Re: Last day of month (Martien Verbruggen)
    Re: Multiple socket (David Efflandt)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 09 Sep 2000 06:09:10 GMT
From: NOrJUNKsEMAILk@nojunkemail.net (R. S. K.)
Subject: [Q] $_ assignmt in map: bug?
Message-Id: <8pck66$ceq@dispatch.concentric.net>
Keywords: Perl 5, bugs, assignment, map

I would like to know if this is a known interpreter bug, a misunder-
standing on my part, or what.  I have found this effect in versions
5.005_02 and 5.005_04 on Linux and on NT (activeware), with the same
behavior throughout.  If it WAS a bug and was fixed in a later version,
I'd like to know this to.  I'm not even sure it's a bug; I think it
may even be an ambiguity in the syntax grammar that wasn't anticipated.
And it's also completely likely that I don't understand something and
am writing nonsense.

The effect:  One is looping through an array and using one of the
assignment operators to modify each member:

            @b = (5, 6, 7);
            @a = map $_ += 2, @b; # syntax error
            @a = map $_ *= 2, @b; # works as expected
            @a = map $_ %= 2, @b; # works as expected
            @a = map $_ /= 2, @b; # error: search pattern not terminated
            @a = map {$_ /= 2} @b; # works as expected

There's no problem coding around this (the block form of the first
operator of map does the trick for me)--but it's fairly seldom that
I run into bugs in the more recent Perl interpreters, so I thought
I'd bring it up and see if this one is well-known.  It's been a long
time so I've forgotten where there's a clearing-house of "known bugs"
these days and how to find this one in it.

Thanks in advance for comments by e-mail (see notice below).

=====
To avoid unwanted junk e-mail, I am posting this with falsified Headers.
Bonafide correspondence may be addressed to:
r s k (at) concentric (dot) net
=====


------------------------------

Date: 9 Sep 2000 05:28:39 GMT
From: Brian Ingerson <brian@ingerson.com>
Subject: ANNOUNCE: Inline 0.25 "Use C in Perl with no Sticky Residue"
Message-Id: <srjtevupljn13@corp.supernews.com>

The latest release of Inline.pm is on the shelves of your local CPAN
mirror. Enhancements include:

More doc.
More testing (works w/ 5.7.0)
Inline_Stack_ macros for easier Perl Stack handling.
Allows this new "C => <DATA>" syntax:

    use Inline;
    Inline->import(C => <DATA>);
    
    print "9 + 16 = ", add(9, 16), "\n";
    print "9 - 16 = ", subtract(9, 16), "\n";
    
    __END__
    
    int add(int x, int y) {
      return x + y;
    }
    
    int subtract(int x, int y) {
      return x - y;
    }

____________________________________________________________

As usual, here's the doc:

NAME
    Inline - Use other programming languages inside Perl scripts and
    modules.

SYNOPSIS
        print "9 + 16 = ", add(9, 16), "\n";
        print "9 - 16 = ", subtract(9, 16), "\n";
     
        use Inline C => <<'END_OF_C_CODE';
        
        int add(int x, int y) {
          return x + y;
        }
     
        int subtract(int x, int y) {
          return x - y;
        }
       
        END_OF_C_CODE

DESCRIPTION
    The `Inline' module allows you to put source code from other
    programming languages directly "inline" in a Perl script or
    module. The code is automatically compiled as needed, and then
    loaded for immediate access from Perl.

    `Inline' saves you from the hassle of having to write and
    compile your own glue code using facilities like XS or SWIG.
    Simply type the code where you want it and run your Perl as
    normal. All the hairy details are handled for you. The
    compilation and installation of your code chunks all happen
    transparently; all you will notice is the delay of compilation.

    The `Inline' code only gets compiled the first time you run it
    (or whenever it is modified) so you only take the performance
    hit once. Code that is Inlined into distributed modules (like on
    the CPAN) will get compiled when the module is installed, so the
    end user will never notice the compilation time.

    Best of all, it works the same on both Unix and Microsoft
    Windows. See the section on "SUPPORTED PLATFORMS" below.

  Why Inline?

    Do you want to know "Why would I use other languages in Perl?"
    or "Why should I use `Inline' to do it?"? I'll try to answer
    both.

    Why would I use other languages in Perl?
        The most obvious reason is performance. For an interpreted
        language, Perl is very fast. Many people will say "Anything
        Perl can do, C can do faster". (They never mention the
        development time ;-) Anyway, you may be able to remove a
        bottleneck in your Perl code by using another language,
        without having to write the entire program in that language.
        This keeps your overall development time down, because
        you're using Perl for all of the non-critical code.

        Another reason is to access functionality from existing API-
        s that use the language. Some of this code may only be
        available in binary form. But by creating small subroutines
        in the native language, you can "glue" existing libraries to
        your Perl. As a user of the CPAN, you know that code reuse
        is a good thing. So why throw away those Fortran libraries
        just yet?

        If you are using Inline with the C language (currently the
        only way to do it), then you can access the full internals
        of Perl itself. This opens up the floodgates to both extreme
        power and peril.

        Maybe the best reason is "Because you want to!". Diversity
        keeps the world interesting. TMTOWTDI!

    Why should I use `Inline' to do it?
        There are already two major facilities for extending Perl
        with C. They are XS and SWIG. Now if you're familiar with
        either, then I may be preaching to the choir. Well, here
        goes:

         <SERMON>

        Greetings congregation. This morning I want to open your
        eyes to the virtues of Inline and the perils of XS. Let us
        compare the two.

        ---

        Inline - You can use it from a regular script.

        XS - Requires you to create a module and an XS file and a
        makefile, in addition to your regular script. Actually, the
        program `h2xs' does a nice job of getting you started, but
        that's still a lot of junk to maintain.

        ---

        XS - You need rebuild every time you want to test a small
        change.

        Inline - Perl programmers cannot be bothered with silly
        things like compiling. "Tweak, Run, Tweak, Run" is our way
        of life. `Inline' does all the dirty work for you.

        ---

        XS - There is a difficult learning curve involved with
        setting up and using the XS environment. (At least for a
        simple Perl preacher like me.) Read the following perldocs
        and man pages if you don't believe me:

         * perlxs
         * perlxstut
         * perlapi
         * perlguts
         * perlmod
         * h2xs
         * xsubpp
         * ExtUtils::MakeMaker

        Inline - Makes easy things easy, and hard things possible.
        Just like Perl.

        ---

        XS - Only implements C and C++.

        Inline - Plans to implement several languages. For now,
        `Inline' only implements C and it uses XS to do it. (Dirty
        little secret) But this is the right thing to do. See the
        section on "SUPPORTED LANGUAGES" below.

        ---

        Amen.

         </SERMON>

  How it works

    `Inline' performs the following steps:

    1) Receive the Source Code
        `Inline' gets the source code from your script or module
        with a statement like the following:

         use Inline C => Source-Code;

        where `C' is the programming language of the source code,
        and `Source-Code' is a string (most easily represented by
        using the "Here Document" quoting style; see the section on
        "SYNOPSIS" above), a file name, an open file handle, or a
        reference to a subroutine (that will return source code).

        Since `Inline' is coded in a "`use'" statement, everything
        is done during Perl's compile time. If anything needs to be
        done that will affect the `Source-Code' string, it needs to
        be done in a `BEGIN' block that is *before* the "`use Inline
        ...'" statement. This might include setting interpolated
        variables, or setting options in the `Inline::Config'
        module.

    2) Check if the Source Code has been Compiled
        `Inline' only needs to compile the source code if it has not
        yet been compiled. It accomplishes this seemingly magical
        task in an extremely simple and straightforward manner. It
        runs the source text through the `Digest::MD5' module to
        produce a 128-bit "fingerprint" which is virtually unique.
        The fingerprint (in hex) is *mangled* with the current
        package name (and the script name, if the package is
        "`main'") along with the name of the programming language,
        to form a unique name for the executable module. For
        instance, the `C' code from `examples/example001.pl' (see
        the section on "Examples In C") would mangle into:

         main_C_example001_pl_3a9a7ba88a8fb10714be625de5e701f1.so

        If an executable with that name already exists, then proceed
        to step 8. (No compilation is necessary)

    3) Find a Place to Build and Install
        At this point `Inline' knows it needs to compile the source
        code. The first thing to figure out is where to create the
        great big mess associated with compilation, and where to put
        the object when it's done.

        By default `Inline' will try to build and install under the
        first one of the following places that is a valid directory
        and is writable:

             1) $ENV{PERL_INLINE_BLIB}
                (The PERL_INLINE_BLIB environment variable overrides all
else)
             2) ./blib_I/  
                (The current directory, unless you're in your home
directory)
             3) $bin/blib_I/
                (Where '$bin' is the directory that the script is in)
             4) $ENV{HOME}/blib_I/
                (Under your home directory)
             5) $ENV{HOME}/.blib_I/
                (Same as above but more discrete)

        If none of those exist, Inline will attempt to create and
        use one of following:

             6) $bin/blib_I/ 
             7) ./blib_I/ 

        Failing that, Inline will croak. Optionally, you can
        configure `Inline' to build and install exactly where you
        want, using `Inline::Config'. See the Inline::Config
        manpage. If `$Inline::Config::SITE_INSTALL=1', then `Inline'
        will only use `./blib_I/' to build in, and the
        `$Config{installsitearch}' directory to install the
        executable in. This option is intended to be used in modules
        that are to be distributed on the CPAN, so that they get
        installed in the proper place.

        Optionally, you can configure `Inline' to build and install
        exactly where you want.

        NOTE: `blib' stands for "build library" in Perl-speak. It is
        a directory that gets created when you install a Perl module
        on your system. `blib_I' is the `Inline.pm' version of the
        same concept.

    4) Parse the Source for Semantic Cues
        `Inline' uses the module `Parse::RecDescent' to parse
        through your chunks of source code and look for things that
        it can create run-time bindings to. For instance, in `C' it
        looks for all of the function definitions and breaks them
        down into names and data types. These elements are used to
        correctly bind the `C' function to a `Perl' subroutine.

    5) Create the Build Environment
        Now `Inline' can take all of the gathered information and
        create an environment to build your source code into an
        executable. Without going into all the details, it just
        creates the appropriate directories, creates the appropriate
        source files including an XS file and a `Makefile.PL'.

    6) Compile the Code and Install the Executable
        The planets are in alignment. Now for the easy part.
        `Inline' just does what you would do to install a module.
        "`perl Makefile.PL && make && make test && make install'".
        If something goes awry, `Inline' will croak with a message
        indicating where to look for more info.

    7) Tidy Up
        By default, `Inline' will remove all of the mess created by
        the build process, assuming that everything worked. If the
        compile fails, `Inline' will leave everything intact, so
        that you can debug your errors. Setting
        `$Inline::Config::CLEAN_AFTER_BUILD=0' will also stop
        `Inline' from cleaning up.

    8) DynaLoad the Executable
        `Inline' uses the `DynaLoader::bootstrap' method to pull
        your external module into `Perl' space. Now you can call all
        of your external functions like Perl subroutines. Wheeee!

  Another Way To Do It

    Instead of specifying the source code as a here-document string,
    you may want to put it at the end of your script, after the
    `__END__' statement. Then you can pass it to `Inline' using the
    `DATA' filehandle, like this:

        use Inline;
        Inline->import(C => <DATA>);
        
        print "9 + 16 = ", add(9, 16), "\n";
        print "9 - 16 = ", subtract(9, 16), "\n";
        
        __END__
        
        int add(int x, int y) {
          return x + y;
        }
        
        int subtract(int x, int y) {
          return x - y;
        }

    Since the `use' command is executed at compile time and the
    `DATA' filehandle isn't available until runtime, you'll need to
    invoke the `import' call manually. This is a useful idiom
    anytime you need to specify `Inline' code at runtime.

  Configuration

    `Inline' trys to do the right thing as often as possible. But
    sometimes you may need to override the default actions. This is
    where `Inline::Config' comes to the rescue. `Inline::Config'
    gives you a more fine-grained control over the entire process.
    The other side of that coin is "you need to know what you are
    doing".

    An important point to remember is that the config settings must
    be done *before* the `Inline' code is evaluated. Since a "`use'"
    happens at (`Perl''s) compile time, you may need to something
    like this:

        BEGIN {
            use Inline;
            $Inline::Config::OPTION_NUMBER_9 = 'Yes';
        # or
            Inline::Config->new->option_number_9('Yes');
        }
        
        use Inline C => "C code goes here...";

    See the Inline::Config manpage for more info.

  Configuration from the Command Line

    `Inline' lets you set many of the configuration options from the
    command line. This can be very handy, especially when you only
    want to set the options temporarily, for say, debugging.

    For instance, to get some general information about your
    `Inline' code in the script `Foo.pl', use the command:

        perl -MInline=INFO Foo.pl

    If you want to force your code to compile, even if its already
    done, use:

        perl -MInline=FORCE Foo.pl

    If you want to do both, use:

        perl -MInline=INFO -MInline=FORCE Foo.pl

    or better yet:

        perl -MInline=INFO,FORCE Foo.pl

    See the Inline::Config manpage for more info.

  Writing Modules with Inline

    Writing CPAN modules that use other programming languages is
    easy with `Inline'. Let's say that you wanted to write a module
    called `Math::Simple' using the previous example code. Start by
    using the following command:

        h2xs -PAXn Math::Simple

    This will generate a bunch of files that form a skeleton of what
    you need for a distributable module. Next, modify the
    `Simple.pm' file to look like this:

        package Math::Simple;
        
        use strict;
        use vars qw($VERSION @ISA @EXPORT_OK);
        require Exporter;
        @ISA = qw(Exporter);
        @EXPORT_OK = qw(add subtract);
        BEGIN {
            $VERSION = '0.01';
        }
        
        use Inline;
        Inline->import(C => <DATA>);
        
        1;
        
        __DATA__
        
        int add(int x, int y) {
          return x + y;
        }
        
        int subtract(int x, int y) {
          return x - y;
        }

    Finally, you need to add the following line to the top of your
    `test.pl' file:

        use Inline SITE_INSTALL;

    When the person installing `Math::Simple' does a "`make test'",
    the `Inline' module will compile the Inlined code and place the
    executable code into the `./blib' directory. Then when a "`make
    install'" is done, the module will be copied into Perl's
    `$Config{installsitearch}' directory (which is where an
    installed module should go).

    Now all you need to do is:

        perl Makefile.PL
        make dist

    That will generate the file `Math-Simple-0.01.tar.gz' which is a
    distributable package.

  Fancy Tricks

    The `Inline' module opens up all sorts of possibilities
    regarding what you can do with `Perl' and `C'. Since everything
    happens at run time (depending on how you think of it) you can
    generate `C' code on the fly and effectively '`eval'' it. (How
    this might be useful is left as an exercise to the reader :-)

    Here is how you would code such a beast:

        BEGIN {$c_code = &c_code_generator()}
        use Inline C => $c_code;  # will die if code doesn't compile
        my_function();

    or

        $c_code = &c_code_generator();
        eval {use Inline C => $c_code};
        if ($@) {
            handle_error($@);     # trap error if code doesn't compile
        }
        else {
            my_function();
        }

SUPPORTED LANGUAGES
    Currently, "`C'" is the only supported language. This is
    obviously the most important language to support. That is
    because `Perl' itself is written in `C'. By giving a your `Perl'
    scripts access to `C', you in effect give them access to the
    entire glorious internals of `Perl'. (Caveat scriptor :-)

    `C' is also the easiest language to implement because the tools
    needed to do so, (like XS and `ExtUtils::MakeMaker') have
    already been written and are very flexible and reliable.
    `Inline' currently makes use of these pre-existing tools.

    But there is definitely no reason why `Inline' must or should
    stop with `C'. As long as sensible bindings can be defined
    between Perl and another language, that language could be a
    candidate for the `Inline' module. Current languages I am
    considering adding support for include:

     - C++
     - Fortran
     - Pascal
     - Python

    Note: Since many `C' compilers allow the use of assembly code
    within C, you may want to consider Assembly Language as
    supported. Ready to start scripting out new device drivers?

SUPPORTED PLATFORMS
    This module should work anywhere that CPAN extension modules
    (those that use XS) can be installed, using the typical install
    format of:

        perl Makefile.PL
        make
        make test
        make install

    It has been tested on many Unix variants and Windows NT.

    NOTE: `Inline.pm' requires Perl 5.005 or higher because
    `Parse::RecDescent' requires it. (Something to do with the `qr'
    operator)

    Inline has been tested on the following platforms:

     V#   OS      OS V#   Perl V# Human              Email 
     0.25 Linux   2.2.13  5.00503 Brian Ingerson     ingy@cpan.org
     0.25 Linux   2.2.13  5.6     Brian Ingerson     ingy@cpan.org
     0.20 FreeBSD 3.4     5.00503 Timothy A Gregory 
tgregory@tarjema.com      
     0.20 FreeBSD 4.0     5.00503 Timothy A Gregory 
tgregory@tarjema.com      
     0.20 FreeBSD 4.0     5.6     Timothy A Gregory 
tgregory@tarjema.com      
     0.20 Linux   2.0.36  5.00503 Prakasa Bellam    
pbellam@cobaltgroup.com
     0.20 HPUX    B.10.20 5.00503 Jamie Shaffer     
jshaffer@chronology.com
     0.20 SunOS   5.6     5.6.0   Jamie Shaffer     
jshaffer@chronology.com
     0.20 SunOS   5.5.1   5.6.0   Jamie Shaffer     
jshaffer@chronology.com
     0.22 OpenBSD 2.7     5.6.0   Jeremy Devenport   jeremy@weezel.com
     0.22 FreeBSD 3.1     5.00503 Doug Beaver        dougb@scalar.org
     0.25 WinNT   4.0 sp6 5.00503 Brian Ingerson     ingy@cpan.org
     0.24 Cygwin  1.1.1   5.6.0   Leo Schalkwyk     
L.Schalkwyk@iop.kcl.ac.uk

    The Microsoft tests deserve a little more explanation. I used
    the following:

     Windows NT 4.0 (service pack 6)
     Perl 5.005_03 (ActiveState build 522)
     MS Visual C++ 6.0
     The "nmake" make utility (distributed w/ Visual C++)

    `Inline.pm' pulls all of its base configuration (including which
    `make' utility to use) from `config.pm'. Since your MSWin32
    version of Perl probably came from ActiveState (as a binary
    distribution) the `Config.pm' will indicate that `nmake' is the
    system's `make' utility. That is because ActiveState uses Visual
    C++ to compile Perl.

    To install `Inline.pm' (or any other CPAN module) on MSWin32 w/
    Visual C++, use these:

        perl Makefile.PL
        nmake
        nmake test
        nmake install

    The "Cygwin" test was done on a Windows 98 machine using the
    Cygwin Unix/Win32 porting layer software from Cygnus. The `perl'
    binary on this machine was also compiled using the Cygwin tool
    set (`gcc'). This software is freely available from
    http://sources.redhat.com/cygwin/

    If `Inline' works on your platform, please email me the info
    above. If it doesn't work, see the section on "BUGS AND
    DEFICIENCIES" below.

SEE ALSO
    the Inline::Config manpage and the Inline::C::Tutorial manpage

BUGS AND DEFICIENCIES
    This is ALPHA code. The interface may still change.

    When reporting a bug, please do the following:

     - Put "use Inline REPORTBUG;" at the top of your code, or
       use the command line option "perl -MInline=REPORTBUG ...".
     - Run your code.
     - Follow the printed directions.

    Here are some things to watch out for:

    1   The `Parse::RecDescent' grammar for `C' is fledgling. It'll get
        better. For now be careful and examine the generated code
        when things don't work. Also, using "`perl -MInline=INFO
        ...'" will give you useful information.

    2   `Inline' doesn't yet support custom typemapping. To pass
        anything beyond basic C types, use the type `SV*' and do
        your own conversions "inline". See the Inline::C::Tutorial
        manpage for more information on programming with C.

    3   While `Inline' does attempt to clean up after itself, there is
        currently no functionality to remove a shared object when a
        new version is compiled. This shouldn't be hard to do, but I
        want to think about it a little more.

    4   The compile time using Visual C++ on MSWin32 seems to be much
        slower in my tests so far. During this time, your script
        will seem to hang. Just be patient. After compilation, the
        execution time is comparable.

AUTHOR
    Brian Ingerson <INGY@cpan.org>

COPYRIGHT
    Copyright (c) 2000, Brian Ingerson. All Rights Reserved. This
    module is free software. It may be used, redistributed and/or
    modified under the terms of the Perl Artistic License.

    (see http://www.perl.com/perl/misc/Artistic.html)




------------------------------

Date: Sat, 9 Sep 2000 19:12:45 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Background process
Message-Id: <slrn8rjs7t.dgd.mgjv@martien.heliotrope.home>

On 7 Sep 2000 21:58:11 -0500,
	Logan Shaw <logan@cs.utexas.edu> wrote:
> 
> By the way, if you are using Perl on Windows, then I believe fork() is
> unimplemented, although I could be wrong.

It's implemented in 5.6.0, but with the usual caveats that comes with
emulating things like this:

# perldoc perlfork

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd.   | cynical. It's perfectly easy to be
NSW, Australia                  | cynical.


------------------------------

Date: Sat, 09 Sep 2000 10:16:13 GMT
From: mag@ionet.net (Maggert)
Subject: Re: Commercial websites using perl
Message-Id: <39ba0dd8.154057593@news.ionet.net>

On Fri, 8 Sep 2000 14:05:15 -0700, Bart Schaefer
<schaefer@zanshin.com> wrote:

>I'd like to identify some commercial websites that are using perl as their
>"web application server" -- as opposed to Microsoft SiteServer, WebLogic,
>Dynamo, BroadVision, StoryServer, XPedio, etc. etc.
>
mp3.com


MP


------------------------------

Date: Sat, 9 Sep 2000 05:19:08 +0100
From: "Sunil Jaiswal" <Sunil@dukeswell.co.uk>
Subject: Converting PHP to Perl - Expert needed !
Message-Id: <WUiu5.12666$6A2.878117@nnrp4.clara.net>

----> Apologies if this is the wrong place for this post ! <-----

I'm looking for a PHP / Perl Expert who can help me out with some work :

1)   We've developed quite a few pages for a client in PHP / MySQL / DHTML -
I now need these PHP pages converted to Perl5. (2-3 days' of work)

2) This is urgent!  - I need a small database maintenance script written in
Perl - using a MySQL database -   an SSI include will be used to import this
data onto a page.  (A day's work - a few hrs for an expert).

Is there anyone out there who can do these?

If you can...
- You'll need to prove to me you can do the stuff - a few samples of Perl
code with MySQL that you've done should do the trick
- You'll be able to do the work from home.
- Let me know how much you want

Please send your samples / queries to sunil@dukeswell.co.uk.

Thanks !

Sunil
Dukeswell Solutions Limited




------------------------------

Date: Sat, 09 Sep 2000 04:04:30 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Environment variables - how to list them all?
Message-Id: <srjdmehnljn116@corp.supernews.com>

Godzilla! (godzilla@stomp.stomp.tokyo) wrote:
: > Coolness.
: 
: No, it's "Koolations!" if you want to be hip
: and your mind still resides in the Summer
: of Love, 1967, when I was humorously, seven.

You have two years on me, then.  I celebrated the SoL by learning to ride
a bike. :)

[snip]
: Bingo! There is what I needed to know. So, do my sort
: first, add equal signs or whatever else seems nice,
: after a sort, logically, during a print loop.

Exactamundo.  Choosing what to sort on, how to get that, and when to sort
it is the key to good sort-based algorithm design.  See such
mind-croggling examples as the Schwartzian and G-R transforms for great
examples.

: This will make you roll your eyes and grimace. I am thinking
: to plug in a character where I had an equal sign, plug in
: a character which is ignored by sort. Later, during a print
: loop, replace this special character with whatever my
: choice is to sort Key and Value for visual effect. I'll 
: have to first find a table of some sort which shows
: precedence levels for various characters. Perhaps 
: there is standard character which is equal in 
: precedence to a hyphen. I enjoy pulling schizo
: stunts with Perl just to see if I can.

Yow!  Yeah, definite eye-rolling and grimacing. ;)  To do this you'd have
to write your own string-comparison routine, of course, which would
compare character-by-character taking into account your intended
special-char value -- since of course nothing but '=' has the ASCII value
of '='.  At that point, you're in pretty deep, effectively defining a new
collating sequence a la the tricks you can play with locale substitution.

As for the character precedence (i.e., lexical sorting order), here's my
birthday present to you:

#!/usr/bin/perl -w
# asciitab - an ascii table for Godzilla

use strict;

my %special = ( 0x1b => 'ESC',
                0x20 => 'SPACE',
                0x7f => 'DEL' );

@special{0x1c..0x1f} = ('') x 4;

foreach (0..127) {
  printf '%02x/%3d : ', $_, $_;

  if (exists $special{$_}) {
    print $special{$_};
  }
  elsif ($_ < 28) {
    print '^'.chr($_+64);
  }
  else {
    print chr($_);
  }

  print "\n";
}


The first two columns in the output are the hex and decimal values of the
character.  The third column is the character, with ^ indicating a control
character.

: I follow your thoughts and examples very well
: being clear and concise. By chance, are you
: Mr. Beatty, my high school civics teacher?

<Pause, check resume> Doesn't look like it, no. :)

: What I can do Mr. Berry, if I share this short
: script of mine with others, as is, would be to
: qualify it as intended to be used for extracting
: available cgi environmental variables, only.

You could.  But we all know that nobody ever reads the docs, even if you
write them in ten-foot letters using red spray paint on their office wall.
Far better to choose an alternative that won't fail even if they do
something unusual with your code.

: Thanks Mr. Berry. I am now better informed and
: enjoy a bit more confidence in knowledge. This
: is trivia I have added to my dubious scrapbook.

Quite welcome!

: > <quibble>
: > Methane is odorless.  "Natural gas" as used in homes has a smelly
: > chemical added to it in order to make leaks more easily detectable.
: > </quibble>
: 
: Yeah.. yeah.. ever light a fart? Trust me, it's methane.

Would that it were *only* methane...but it's not, and that's where one
gets into, ah, trouble. :)

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


------------------------------

Date: Sat, 09 Sep 2000 00:45:13 -0400
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: Environment variables - how to list them all?
Message-Id: <brian+usenet-A1B40D.00451309092000@news.panix.com>

In article <Pine.GHP.4.21.0009090054211.22034-100000@hpplus03.cern.ch>, 
"Alan J. Flavell" <flavell@mail.cern.ch> wrote:

> On Fri, 8 Sep 2000, brian d foy wrote:
> 
> > the "X-" headers contain a hyphen, for instance. HTTP is extensible.
> > the user can add headers, and those headers might have hyphens
> > in them. 

> Sure, but the corresponding CGI environment variables contain
> underscores.

it depends on how the headers are put into the environment. a
particular server might do that, but the CGI specification
doesn't specify how a server should do it.  indeed, the
draft specification[1] says about the environment variables:

   Here they are shown using a canonical
   representation of capitals plus underscore ("_"). The actual
   representation of the names is system defined; for a
   particular system the representation MAY be defined
   differently than this. [Section 6.1]


[1] http://web.golux.com/coar/cgi/draft-coar-cgi-v11-03.txt

-- 
brian d foy


------------------------------

Date: Sat, 9 Sep 2000 19:14:41 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Environment variables - how to list them all?
Message-Id: <slrn8rjsbh.dgd.mgjv@martien.heliotrope.home>

On Fri, 8 Sep 2000 20:48:08 GMT,
	Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:

> Or, to be short and direct :) 

For certain obscure values of direct :)

> perl -we 'system "env"'

Randal might start giving away useless use of perl awards next.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.   | enough features yet.
NSW, Australia                  | 


------------------------------

Date: Sat, 9 Sep 2000 19:25:01 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: fgrep -i  "greek_word" DOES NOT WORK
Message-Id: <slrn8rjsut.dgd.mgjv@martien.heliotrope.home>

[please, in the future, put your reply _after_ the suitably shortened
text you reply to. It makes it much easier to read posts with multiple
levels of quoting, since it obeys the natural flow of time. Besides
that, that particular style of quoting is the one adopted by this group.
Thank you]
[reordered post]

On Thu, 7 Sep 2000 21:51:52 +0300,
	Theodore Stassinos <thestas@dolnet.gr> wrote:
> "Abigail" <abigail@foad.org> wrote in message
> news:slrn8rfl7c.vlt.abigail@alexandra.foad.org...

[snip of large amoutn of quoted, and misformatted text]

> > Is there any relevance of your posting to this newsgroup?
> >
[snip]
> But to make it clear to you, just for the reference of course is that , i
> don't want to change the structure and filosophy of the entire program just
> because a unix command doesn't work. I believe that perl, in which i have
> written the program, has some methods to do the job.

This makes no sense. If you don't want to change the structure of the
program, then you will have to fix the external program. If you want to
use internal methods, instead of the external program, you will need to
restructure your program. You contradict yourself.

> Maybe by converting the hexadecimal lowercase characters comming in Greek
> (%e1-%f9)  to their uppercase equivalents (%c1-d9) and the opposite would do
> the job. Or even after the "pack" instruction which converts the hexadecimal
> values to their character equivalent , i could produce for each greek word,
> two other, one in uppercase and one in lowercase.

Now, for the future, make sure that this is the sort of stuff you
explicitly put in your first post. If you reread your original post, you
will find that all it says is: 'this grep program doesn't do what I want
it to do. How do I fix it?'.

Not an ounce of Perl content.

If you had phrased your question differently, people would have _known_
what you were talking about, and what you planned to do.

It is not _our_ responsibility to read your mind. It is not _our_
responsibility to list all possible solutions to a problem that might
potentially involve Perl, just because you're too vague. It is however,
_your_ responsibility to ask a clear, and on-topic, question if you want
an answer. If you don't, you waste time, other people's time. That
pisses them off. Protesting their complaints only gets you a spot in
killfiles.

Learn from this, and be clear in the future. When someone criticises,
first make sure that you're not at fault, before becoming defensive.

In this case, you were at fault. Not deliberately, but still.

> So, as you see my friend my question has a big relevance to this perl
> newsgroup and i am really sorry that you did not understood  it.

It really doesn't have that much relevance to the perl newsgroup. but at
least it has some, _NOW_ you phrase it like that. The original question
still has no relevance to Perl. No one could have been expected to read
your original post in the way that you phrase it now. Abigail didn't
misunderstand, you misstated, were simply not clear enough.

Your fault. And again, your bitchy defensiveness only earned you spots
in killfiles.

bye, bye

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | You can't have everything, where
Commercial Dynamics Pty. Ltd.   | would you put it?
NSW, Australia                  | 


------------------------------

Date: Sat, 09 Sep 2000 05:45:24 GMT
From: richard@foxworth.com (Richard)
Subject: Re: How can I extract files from a file? I'm using linux.
Message-Id: <39b9cf14.93774097@news.pnscla1.fl.home.com>

Thanks!

Richard

On Fri, 08 Sep 2000 08:53:00 +0200, Ulrich Ackermann
<uackermann@orga.com> wrote:

>richard@foxworth.com wrote:
>> 
>> How can I extract files from a file? I'm using linux.
>> I need the cachefile name (or names if more than one) from the list
>> below that doesn't have a file extension to process though this
>> routine.
>
>*snipp*
>
>> ./1D/cache39B7FDFD0A2032B.GIF
>> ./1D/cache39B7FDFD0A3032B.gif
>> ./1D/cache39B7FDFD0A4032B.gif
>> ./1A
>> ./1A/cache39B7FDFA09F032B
>
>*snipp*
>
>Hi Richard,
>If the files you are looking for alwasy end up with hex numbers use a
>regex for this. As far as I remember, there is an expression for hex
>numbers in the most recent versions of perl (looks like [:xdigit:], I
>think; see perldoc perlre).
>
>Then this should do the work:
>
>my @files = <CACHE_FILE>;
>my @needed_files;
>for (@files) {
>	$_ =~ /(cache[:xdigit:]+)$/;
>	push @needed_files, $1;
>}
>
>But I have not tested the code. Use with care.
>
>HTH, Ulrich
>-- 
>Ulrich Ackermann
>ORGA Kartensysteme GmbH (SY-PEAT-STA)
>Tel.:+49.5254.991-925 
>mailto:uackermann@orga.com
>



------------------------------

Date: 08 Sep 2000 22:21:12 -0700
From: Steve Allan <sallan@nwlink.com>
Subject: Re: How to find unused variables?
Message-Id: <uwvgmb0on.fsf@nwlink.com>

tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:

>I was shocked! How could Steve Allan <sallan@nwlink.com>
>say such a terrible thing:
>
>>But this doesn't produce warnings for variables declared local with
>>my(). BTW - how did you slip that $a = 'bla' past stict? It doesn't 
>>compile for me.  Try this example -
>
>$a is special. See "perldoc -f sort"
>

Ah - I missed that!  You're right.  But, that's a red herring in that
the example is an exception to the rule.  In general, localized
variables that go unused are not flagged by -w.  I think the OP wants
to be able to detect cases where

use strict;
my($var1, $var2, $var3);

and $var3 goes unused in the script - like most modern C compilers
will do if you turn on the warnings.

Thanks for pointing this out.  It's another good reason not to use the
tempting single-char vars, (like a,b,c and x,y,z) in examples.

-- Steve __


------------------------------

Date: Sat, 9 Sep 2000 19:31:49 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Last day of month
Message-Id: <slrn8rjtbl.dgd.mgjv@martien.heliotrope.home>

On Fri, 08 Sep 2000 17:43:12 GMT,
	Craig Berry <cberry@cinenet.net> wrote:
> Stephen Kloder (stephenk@cc.gatech.edu) wrote:
[fix of quoite character]
> > If the day length changes, localtime() will become inaccurate and in
> > need of an upgrade.  Until then, localtime() has every day for the
> > next 100 years as exactly 24 hours long, with the exception of 2
> > days a year (which are not at the end of the month).
> 
> The point is that the government in any given country could move DST
> to the last day of the month at any moment, and that locale-respecting
> programs would then do the same.  Never make the correctness of your
> code dependent on legislators behaving rationally.

A good example of more or less random changes to DST is the DST change
for the Australia/NSW time zone for this particular year. While the
Olympics are on, we're in DST. two months before we normally would have
been.

It doesn't actually break the case at hand (last day of month), but it
easily could have. And this change was announced half a year ago or so.
Because it would fit in beter with US broadcasting schedules.

No guarantees, ever, indeed.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Failure is not an option. It comes
Commercial Dynamics Pty. Ltd.   | bundled with your Microsoft product.
NSW, Australia                  | 


------------------------------

Date: Sat, 9 Sep 2000 04:51:09 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Multiple socket
Message-Id: <slrn8rjgdo.cej.efflandt@efflandt.xnet.com>

On Fri, 08 Sep 2000, Ville Mattila <ville.mattila@nettipaa.fi> wrote:
>
>I'm looking for a way how I could make a some kind of server software
>with Perl. I have found the system of sockets etc, but as I have tried,
>it can handle only one session by once. Is there any solution to handle
>multiple ones?
>
>Or, is it possible to make one always on -socket and then "temporarily"
>sockets as a server?

'perldoc perlipc' has examples, including a server that forks.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 4270
**************************************


home help back first fref pref prev next nref lref last post