[7269] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 895 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 20 12:07:22 1997

Date: Wed, 20 Aug 97 09:01:31 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 20 Aug 1997     Volume: 8 Number: 895

Today's topics:
     TCL 8.0: A whole lot of perl (Aaron Sherman)
     Want to alter date format (Ed)
     Re: Want to alter date format <sfairey@adc.metrica.co.uk>
     Re: Want to alter date format (Mike Stok)
     Re: Want to alter date format <tw36027@glaxowellcome.com>
     Win32 Error:  193 using Perl for Win32 <anders@comet.brussels.hp.com>
     Re: Win95 + Perl back-quotes or fx(<system command>) as (Eric Bohlman)
     Work-around for Server-Push (Dietmar Janetzko)
     Re: writing to a file (Tad McClellan)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 20 Aug 1997 10:05:40 -0400
From: ajs@lorien.ajs.com (Aaron Sherman)
Subject: TCL 8.0: A whole lot of perl
Message-Id: <5tetjk$3cv@lorien.ajs.com>

TCL 8.0 has just been released (it's been in beta for some time
now). Being the person who wrote the (now outdated) comparison on the
perl web site between the two languages, I thought I would just take a
moment to make the perl world think.

TCL 8.0 now handles binary data, has a compile stage before execution,
keeps string lengths around to avoid costly strlen operations, has
dynamic loading and much more. This is interesting because it is
practically a point-for-point response to my (rather perl-positive)
comparison of TCL and perl.

I would still put perl out ahead if only for:

	Better variable handling, esp. in argument passing

	A more robust parser, esp. for block handling

	Slicker regex syntax (e.g. $string =~ /regex/ and $_ default)
	This is really the single point that puts perl in the
	lead of anything else on the command-line.

	More sophisticated handling of variables leads to many
	other features. e.g. closures, simple object model, etc.

Of course, TCL has:

	Tk native (perl Tk is badly out of date and cannot make
	use of many of the add-ons). Tk is now much better, providing
	a native look-and-feel on Macs, Windows and X.

	A tendancy to be more readable

Here's the official Tcl 8.0 info:

What's new in Tcl 8.0

   The most important changes in Tcl 8.0 are summarized below. See the
   README and changes files in the distribution for more complete
   information on what has changed, including both feature changes and
   bug fixes.
    1. Bytecode compiler. The core of the Tcl interpreter has been
       replaced with an on-the-fly compiler that translates Tcl scripts
       to byte codes; a new interpreter then executes the byte codes. In
       earlier versions of Tcl, strings were used as a universal
       representation; in Tcl 8.0 strings are replaced with Tcl_Obj
       structures ("objects") that can hold both a string value and an
       internal form such as a binary integer or compiled bytecodes. The
       new objects make it possible to store information in efficient
       internal forms and avoid the constant translations to and from
       strings that occurred with the old interpreter. We have not yet
       converted all of Tcl to take full advantage of the compiler and
       objects and have not converted any of Tk yet, but even so you
       should see speedups of 2-3x on many programs and you may see
       speedups as much as 10-20x in some cases (such as code that
       manipulates long lists). Future releases should achieve even
       greater speedups. The compiler introduces only a few minor changes
       at the level of Tcl scripts, but it introduces many new C APIs for
       managing objects. See, for example, the manual entries
       doc/*Obj*.3.
    2. Namespaces. There is a new namespace mechanism based on the
       implementation by Michael McLennan of Lucent Technologies. This
       includes new namespace and variable commands. There are many new C
       APIs associated with namespaces, but they will not be exported
       until Tcl 8.1.
    3. Binary I/O. The new object system in Tcl 8.0 supports binary
       strings (internally, strings are counted in addition to being null
       terminated). There is a new binary command for inserting and
       extracting data to/from binary strings. Many commands, such as
       puts, gets, and read, now operate correctly on binary data. There
       is a new variable tcl_platform(byteOrder) to identify the native
       byte order for the current host.
    4. Random numbers. The expr command now contains a random number
       generator, which can be accessed via the rand() and srand() math
       functions.
    5. Registry support. A new registry command is available under
       Windows to access the registry. It is available as a package named
       registry.
    6. Safe-Tcl enhancements. There is a new hidden command mechanism
       implemented with the Tcl commands interp hide, interp expose,
       interp invokehidden, and interp hidden and the C APIs
       Tcl_HideCommand and Tcl_ExposeCommand. There is now support for
       safe packages and extension loading, including new library
       procedures such as safe::interpCreate (see the manual entry safe.n
       for details).
    7. HTTP support. There are new library procedures for doing GET,
       POST, and HEAD requests via the HTTP/1.0 protocol. See the manual
       entry http.n for details.
    8. There is a new command file attributes for getting and setting
       things like permissions and owner. There is also a new command
       file nativename for getting back the platform-specific name for a
       particular file.
    9. There is a new fcopy command to copy data between channels either
       in foreground or in the background using file events. This
       replaces and improves upon the not-so-secret unsupported old
       command unsupported0.
   10. There are new library procedures for finding word breaks in
       strings. See the manual entry library.n for details.
   11. There are new C APIs Tcl_Finalize (for cleaning up before
       unloading the Tcl DLL) and Tcl_Ungets for pushing bytes back into
       a channel's input buffer.
   12. Serial I/O devices. Tcl now supports serial I/O devices on Windows
       and Unix, with a new fconfigure -mode option. The Windows driver
       does not yet support event-driven I/O on serial devices.
   13. The lsort command has new options -dictionary and -index. The
       -index option allows for very rapid sorting based on an element of
       a list.
   14. New notifier. The event notifier has been completely rewritten
       (again). It should now allow Tcl to use an external event loop
       like Motif's when it is embedded in other applications. No
       script-level interfaces have changed, but many of the C APIs have.
       
What's new in Tk 8.0

   The most important changes in Tk 8.0 are summarized below. See the
   README and changes files in the distribution for more complete
   information on what has changed, including both feature changes and
   bug fixes.
    1. Native look and feel. The widgets have been rewritten to provide
       (nearly?) native look and feel on the Macintosh and PC. Many
       widgets, including scrollbars, menus, and the button family, are
       implemented with native platform widgets. Others, such as entries
       and texts, have been modified to emulate native look and feel.
       These changes are backwards compatible except that (a) some
       configuration options are now ignored on some platforms and (b)
       you must use the new menu mechanism described below to get native
       look and feel for menus.
    2. New menus. There is a new interface for creating menus, where a
       menubar is implemented as a menu widget instead of a frame
       containing menubuttons. The -menu option for a toplevel is used to
       specify the name of the menubar; the menu will be displayed
       outside the toplevel using different mechanisms on each platform
       (e.g. on the Macintosh the menu will appear at the top of the
       screen). See the menu demos in the widget demo for examples. The
       old style of menus still works, but does not provide native look
       and feel. Menus have several new features:
          + New -columnbreak and -hidemargin options make it possible to
            create multi-column menus.
          + It is now possible to manipulate the Apple and Help menus on
            the Macintosh, and the system menu on Windows. It is also
            possible to have a right justified Help menu on Unix.
          + Menus now issue the virtual event <&ltMenuSelect>> whenever
            the current item changes. Applications can use this to
            generate help messages.
          + There is a new -direction option for menubuttons, which
            controls where the menu pops up relative to the button.
    3. New font mechanism. Tk's font support has been completely
       reworked:
          + Font names need not be nasty X LFDs: more intuitive names
            like {Times 12 Bold} can also be used. See the manual entry
            font.n for details.
          + Font requests always succeed now. If the requested font is
            not available, Tk finds the closest available font and uses
            that one.
          + Tk now supports named fonts whose precise attributes can be
            changed dynamically. If a named font is changed, any widget
            using that font updates itself to reflect the change.
          + There is a new command font for creating named fonts and
            querying various information about fonts. If a named font is
            changed, any widget using that font updates itself to reflect
            the change.
          + There are now officially supported C APIs for measuring and
            displaying text. If you use these APIs now, your code will
            automatically handle international text when
            internationalization is added to Tk in a future release. See
            the manual entries MeasureChar.3, TextLayout.3, and FontId.3.
          + The old C procedures Tk_GetFontStruct, Tk_NameOfFontStruct,
            and Tk_FreeFontStruct have been replaced with more portable
            procedures Tk_GetFont, Tk_NameOfFont, and Tk_FreeFont.
    4. Application embedding. It is now possible to embed one Tcl/Tk
       application inside another, using the -container option on frame
       widgets and the -use option for toplevel widgets or on the command
       line for wish. Embedding should be fully functional under Unix,
       but the implementation is incomplete on the Macintosh and PC.
    5. Tk now works correctly with Safe-Tcl: it can be loaded into safe
       interpreters using safe::loadTk.
    6. Text widgets now allow images to be embedded directly in the text
       without using embedded windows. This is more efficient and
       provides smoother scrolling.
    7. Buttons have a new -default option for drawing default rings in a
       platform-specific manner.
    8. There is a new gray75 bitmap, and the gray25 bitmap is now really
       25% on (due to an ancient mistake, it had been only 12% on). The
       Macintosh now supports native bitmaps, including new builtin
       bitmaps stop, caution, and note, plus the ability to use bitmaps
       in the application's resource fork.
    9. The destroy command now ignores windows that don't exist instead
       of generating an error.
       


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

Date: 20 Aug 1997 12:48:27 GMT
From: MBP95ER@shef.ac.uk (Ed)
Subject: Want to alter date format
Message-Id: <5tep2r$mh3$3@bignews.shef.ac.uk>

Ok, before you say anything, yes I have seen the previous posts on date 
formatting in perl, *but* the thing is I don't know *any* perl.  

I have a BBS script - the date is given in the month/day/year format, I just 
want to change it to day/month/year  

$dateStamp = `/bin/date +"%D"`; chop ($dateStamp);

Can I alter the above line, or replace it with something else to get the 
desired format?  

Thanks in advance,
Ed Ralph.




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

Date: Wed, 20 Aug 1997 14:22:54 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Ed <MBP95ER@shef.ac.uk>
Subject: Re: Want to alter date format
Message-Id: <33FAEFAE.41C6@adc.metrica.co.uk>

Ed wrote:
> 
> Ok, before you say anything, yes I have seen the previous posts on date
> formatting in perl, *but* the thing is I don't know *any* perl.
> 
> I have a BBS script - the date is given in the month/day/year format, I just
> want to change it to day/month/year
> 
> $dateStamp = `/bin/date +"%D"`; chop ($dateStamp);
> 
> Can I alter the above line, or replace it with something else to get the
> desired format?
> 
> Thanks in advance,
> Ed Ralph.

Look into the localtime() and time() functions in the perlfunc manpage
they do everything you need without having to do a `` process.

If you get stuck after looking at these then post a question with some
code you have tried.

Simon
PS: If you look at the man page for date I believe you can actually get
it to format the date the way you want anyway.


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

Date: 20 Aug 1997 13:38:18 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Want to alter date format
Message-Id: <5tes0a$juc@news-central.tiac.net>

In article <5tep2r$mh3$3@bignews.shef.ac.uk>, Ed <MBP95ER@shef.ac.uk> wrote:
>Ok, before you say anything, yes I have seen the previous posts on date 
>formatting in perl, *but* the thing is I don't know *any* perl.  
>
>I have a BBS script - the date is given in the month/day/year format, I just 
>want to change it to day/month/year  
>
>$dateStamp = `/bin/date +"%D"`; chop ($dateStamp);
>
>Can I alter the above line, or replace it with something else to get the 
>desired format?  

You can use the strftime routine which comes in the POSIX package e.g.

  use POSIX 'strftime';

  $dateStamp = strftime '%m/%d/%y', localtime;

will save you firing off another process.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Wed, 20 Aug 1997 09:52:32 -0400
From: Thad Welch <tw36027@glaxowellcome.com>
To: Ed <MBP95ER@shef.ac.uk>
Subject: Re: Want to alter date format
Message-Id: <33FAF6A0.2B9C7B89@glaxowellcome.com>

here's some code:

$t = formatTime( localtime( time ) );
print "\n $t ";

$t = formatTime( gmtime( time ) );
print "\n $t ";

sub formatTime{
 my ($sec, $min, $hour, $monthDay, $month, $year,
  $weekDay, $yearDay, $isDst ) = @_;

 my $nameMonth =
  (qw(JAN FEB MAR APR MAY JUN JUL AUG SEP OUT NOV DEC))[$month];

 return sprintf( "%2.2d-%s-%4.4d %2.2d:%2.2d:%2.2d", $monthDay,
$nameMonth, 1900+$year, $hour, $min, $sec);
}




Ed wrote:

> Ok, before you say anything, yes I have seen the previous posts on
> date
> formatting in perl, *but* the thing is I don't know *any* perl.
>
> I have a BBS script - the date is given in the month/day/year format,
> I just
> want to change it to day/month/year
>
> $dateStamp = `/bin/date +"%D"`; chop ($dateStamp);
>
> Can I alter the above line, or replace it with something else to get
> the
> desired format?
>
> Thanks in advance,
> Ed Ralph.





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

Date: Wed, 20 Aug 1997 17:18:41 +0200
From: Anders Mork <anders@comet.brussels.hp.com>
Subject: Win32 Error:  193 using Perl for Win32
Message-Id: <33FB0AD1.4781@comet.brussels.hp.com>

Hi there,

I have tried to install Perl for Win32 to use with an AOLserver and I
keep getting Win32 Error:  193 when I check the server log after having
tried to execute a perl script that works just fine from the command
line.

Where can I find a list of error messages and their meaning for Perl for
Win32 and is there anybody that has experienced the same problems with
an AOLserver?

Rgds.
Anders


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

Date: Wed, 20 Aug 1997 12:10:16 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Win95 + Perl back-quotes or fx(<system command>) assignment not working.
Message-Id: <ebohlmanEF7oH4.BJ2@netcom.com>

Scott McMahan (scott@lighthouse.softbase.com) wrote:
: This is not what happens on my machine. 

: When I use

: 	perl -e "$x=`dir`;print $x"

: I get the directory listing. When I do:

: 	perl -e "@x=`dir`;print @x"

: Some number prints out. In neither case is any shell output sent
: to the screen.

: I don't know what to tell you, other than something is different
: between the configurations. Whatever is going on has nothing to
: do with Perl per se.

Under Windows 95, dir is implemented as a built-in command in the command 
processor.  The command processor has some internal display-speed 
optimizations that cause it under some cases to directly write into 
screen memory rather than using standard output.  However, these 
optimizations can be shut off by means of some configuration variables.  
It's possible that that's the difference between your setup and the 
original poster's.

But in any case, invoking a shell to get a directory listing isn't the 
best way of going about things.



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

Date: 20 Aug 1997 10:54:38 GMT
From: dietmar@automatix.iig.uni-freiburg.de (Dietmar Janetzko)
Subject: Work-around for Server-Push
Message-Id: <5teide$r9u@n.ruf.uni-freiburg.de>

Is there any work-around (Perl Script) when you 
want to use sever-push for Non-Netscape Browsers?


Dietmar


___________________________________________________________

Dietmar Janetzko
Institute of Computer Science and Society
Friedrichstr. 50
79098 Freiburg
Germany
Tel: 0761/203-4948
Fax: 0761/203-4938
dietmar@cognition.iig.uni-freiburg.de
___________________________________________________________


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

Date: Tue, 19 Aug 1997 22:29:02 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: writing to a file
Message-Id: <u9odt5.gub.ln@localhost>

Robban (colte@hem.passagen.se) wrote:
: Hello I'm a Perl beginner running perl 5.

: When I write to a file using the append mode
: it places it at the end of the file.
: I want to replace a line in the middle of the file.
: (For updating a html page)
: Does anyone know how to accomplish this ?
       ^^^^^^^^^^^

Yes.

As a matter of fact, this Question has been Asked so Frequently, that
it has been answered in the perl FAQ, part 5, so that it would not
be posted yet again.

That idea didn't work ;-(


 ... anyway:


  "How do I change one line in a file/delete a line in a file/insert 
   a line in the middle of a file/append to the beginning of a file?"


: Thanks

If, after seeing that part of the FAQ, you still have a question,
then post it here (along with some code, we like code here).


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 895
*************************************

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