[7004] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 627 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 18 05:56:07 1997

Date: Wed, 18 Jun 97 02:00:55 -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, 18 Jun 1997     Volume: 8 Number: 627

Today's topics:
     Re: "Bizarre copy of ARRAY" message from prototype fidd (M.J.T. Guy)
     ? on Perl 5.001 and NT registry extensions <dmarelia@earthlink.net>
     ANNOUNCE:  Net::DNS 0.10 has dynamic updates (Michael Fuhr)
     ANNOUNCE: Date::DateCalc 3.1 (Steffen Beyer)
     Re: appending two files into one? <pmerle@corp.sun.com>
     Re: appending two files into one? <flg@vhojd.skovde.se>
     Re: appending two files into one? (Magnus Bodin)
     Re: Been Through Every FAQ - Point Me to the RIGHT One  (Nathan V. Patwardhan)
     Re: call perl script in c program? (Joe McCaughan)
     Re: Can't compile perl 5.004 on IRIX 6.2 (Lamont Alan Lucas)
     Re: Case Conversion (Dean Inada)
     Re: Case Conversion (Dean Inada)
     Re: Content Type (Andrew Starr)
     Re: converting mode from stat into ls style mode string (Sylvain Robitaille)
     Data extractaction from a character delimited file.. (CT2963)
     Re: Data extractaction from a character delimited file. <rootbeer@teleport.com>
     DBI: connect() different for mSQL <mschilli@blacksun.com>
     Re: declaring a list of variables (Tad McClellan)
     Editor for Perl on Unix box <raymond@sj.bigger.net>
     Re: Editor for Perl on Unix box <bri@mojo.calyx.net>
     Re: Editor for Perl on Unix box <rootbeer@teleport.com>
     Re: garbage collection and HTML::Element <rootbeer@teleport.com>
     Re: garbage collection and HTML::Element (M.J.T. Guy)
     Re: GD and HTML together (David Richards)
     Re: GD and HTML together <dada@divinf.it>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 18 Jun 1997 08:17:15 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: "Bizarre copy of ARRAY" message from prototype fiddling
Message-Id: <5o85ib$c14@lyra.csx.cam.ac.uk>

Peter Scott <Peter.J.Scott-remove-to-email@jpl.nasa.gov> wrote:
>Experimenting with prototypes on 5.003 on SunOS 4.1.3, I thought to myself,
>let's find out how I can pass two arrays to a subroutine and recover
>them.

You are almost there.   As you deduced, the arguments are passed as
references  -  both of them.   So the form you want is

sub foo (\@\@) {
my ($xref,$yref) = @_;
my @x = @$xref;
my @y = @$yref;
print "@x\n","@y\n";
}
@a = qw(a b c);
@b = qw(x y z);
foo(@a, @b);

which prints

a b c
x y z

>                             So I changed the prototype to (\@@), expecting 
>to get back "ARRAY... x y z", but instead I got:
>
>	Bizarre copy of ARRAY in aassign at - line 2.

This is a bug (still present in 5.004_01, sadly).    From perldiag:

         (P) An internal error you should never see (trappable).

     Bizarre copy of %s in %s
         (P) Perl detected an attempt to copy an internal value
         that is not copiable.

I've passed this on to perlbug.


Mike Guy


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

Date: 15 Jun 1997 18:28:14 GMT
From: "Karen Hanson" <dmarelia@earthlink.net>
Subject: ? on Perl 5.001 and NT registry extensions
Message-Id: <01bc79b9$b1735e90$a08b2299@godofnt>

I have some code that is using the registry extensions provided in the NT
3.51 resource kit. Specifically, I am trying to set a REG_BINARY value
using the NTRegSetValueEx function. The line of code in question follows:

$return=&NTRegSetValueEx($keycomp,'StandardStart',0,$REG_BINARY,$nulval);

where $nulval=0x00000000000000000000000000000000;

I've also tried using the hex value itself in the function call. What I get
in the particular registry key in question, after applying the function is:
0x30

I'm not sure what's going here. I have successfully used this function to
muck with REG_DWORD, REG_SZ, etc. but am having no luck with REG_BINARY.
Anyone seen this before?



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

Date: 15 Jun 1997 16:06:22 GMT
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: ANNOUNCE:  Net::DNS 0.10 has dynamic updates
Message-Id: <5o13tu$38f$1@nadine.teleport.com>

Net::DNS is a module for making DNS queries in Perl; the biggest change
in version 0.10 is the addition of RFC 2136 dynamic updates.  The
dynamic update code is still incomplete but should behave if you're
nice to it (please see the TODO file for a list of things I still need
to work on).  I caution, however, that you probably shouldn't use it to
maintain a production nameserver at this time -- I'm releasing this
version primarily for those individuals who'd like to check it out
on a test basis.

Net::DNS 0.10 is making its way around CPAN now; you can also get the
latest version from:

     http://www.dimensional.com/~mfuhr/perldns/

Happy resolving (and updating)!

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/




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

Date: 15 Jun 1997 16:06:52 GMT
From: sb@sdm.de (Steffen Beyer)
Subject: ANNOUNCE: Date::DateCalc 3.1
Message-Id: <5o13us$38n$1@nadine.teleport.com>

I am glad and proud to submit

                   ========================================
                     Package "Date::DateCalc" Version 3.1
                   ========================================
                       for Perl version 5.000 and higher


     Copyright (c) 1995, 1996, 1997 by Steffen Beyer. All rights reserved.
     This package is free software; you can redistribute it and/or modify
     it under the same terms as Perl itself.

to the Perl community.


Contents of this message:
-------------------------

  +  Where to find
  +  Prerequisites
  +  What's new in version 3.1
  +  This distribution contains
  +  What does it do


Where to find:
--------------

You can download this module directly from the author's web site, where you
will also find my other modules and a couple of logos illustrating what the
modules do:

    http://www.engelschall.com/u/sb/download/

You should also be able to find this module on any CPAN ftp site (CPAN =
"Comprehensive Perl Archive Network"), where the file "DateCalc-3.1.tar.gz"
should be found in any of the following directories:

    .../CPAN/authors/id/STBEY/
    .../CPAN/modules/by-category/06_Data_Type_Utilities/Date/
    .../CPAN/modules/by-module/Date/

To find a CPAN ftp site, you can either direct your web browser to

    http://www.perl.com/CPAN/modules/by-module/Date/DateCalc-3.1.tar.gz

(which will automatically redirect you to a CPAN ftp server near you) or
look into "The Perl 5 Module List" by Tim Bunce and Andreas Koenig either
on USENET in the "comp.lang.perl.modules" newsgroup or at

    http://www.perl.com/CPAN/modules/00modlist.long.html


Prerequisites:
--------------

Perl version 5.000 or higher, a C compiler capable of the ANSI C standard (!)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

What's new in version 3.1:
--------------------------

A new function named "calendar" has been added to the "Date::DateCalcLib"
module which produces a calendar for a given month and year pretty much
like the UNIX "cal" command.

You can also copy this function into your own Perl code and then modify
it, for instance to make the day numbers clickable with hyperlinks when
the calendar is used in an HTML page.

A piece of C source code named "cal.c_" has been added to this package
which demonstrates how one can use the date calculation functions library
"lib_date.c" (the core of the "Date::DateCalc" module) *STAND-ALONE*.

This piece of code is the C version of the new "calendar" function.

See at the end of the file "INSTALL" in this distribution for instructions
on how to compile and link this little demonstration utility.


This distribution contains:
---------------------------

   *   a "lib_date" C library (can be used stand-alone!)

       (files "lib_defs.h", "lib_date.h" and "lib_date.c")

          +   efficient (fast) and complete date calculations
              based on the gregorian calendar and the ISO/R
              2015-1971 and DIN 1355 standard

   *   a "Date::DateCalc" module

       (files "lib_defs.h", "lib_date.h", "lib_date.c",
        "DateCalc.xs" and "DateCalc.pm")

          +   a toolbox for any date calculation problem you
              will ever encounter

   *   a "Date::DateCalcLib" library module

       (file "DateCalcLib.pm")

          +   a library of useful date calculation applications

   *   demonstration programs

       (files "cal.c_", "demo", "demo2" and "demo_us")

          +   to help you write your own


What does it do:
----------------

The package provides a Perl interface to a C library which offers a wide
variety of date calculations based on the Gregorian calendar (the one
used in all western countries today), complying with the ISO/R 2015-1971
and DIN 1355 standards which specify things as what leap years are, when
they occur, how the week numbers are defined, what's the first day of the
week, how many weeks (52 or 53) a given year has, and so on.

Although the Gregorian calendar was only adopted 1582 by most (not all)
European countries (some countries continued to use the Julian calendar
until as late as the beginning of the 20th century!), this package allows
you to extrapolate the Gregorian calendar back until the year 1.

This module is not intended to be the most comfortable approach to every
date calculation problem there is, but instead it's meant to be a *minimal*
and *complete* (in the sense of computation theory!) set of tools to solve
any date calculation problem you might ever encounter.

Therefore, the interfaces of these routines are designed for a maximum of
flexibility and a minimum of overhead. Just like the UNIX commands "cat",
"grep" and so on which do very simple tasks but can do many useful jobs
when combined in a clever way, the routines in this package are intended
to be *elementary*, i.e., indivisible basic functions.

Moreover, the module is mainly written in C so that the C part can be used
as a stand-alone library in other applications than Perl. (!!!)

A library of useful date calculation functions is available for some special
problems like the nth weekday in a given month and year, calculating a new
date with year, month and day offsets, calculating easter sunday, and more.
(See the "Date::DateCalcLib" man page for more details!)

To give you an idea of what the "Date:DateCalc" module can do, here a list
of all the functions it exports:

  $flag = leap($year);
  $flag = check_date($year,$mm,$dd);
  $date = compress($yy,$mm,$dd);
  ($cc,$yy,$mm,$dd) = uncompress($date);
  $flag = check_compressed($date);
  $datestr = compressed_to_short($date);
  $days = calc_days($year,$mm,$dd);
  $weekday = day_of_week($year,$mm,$dd);
  $days = dates_difference($year1,$mm1,$dd1,$year2,$mm2,$dd2);
  ($year,$mm,$dd) = calc_new_date($year,$mm,$dd,$offset);
  ($days,$hh,$mm,$ss) = date_time_difference
  (
      $year1,$month1,$day1,$hh1,$mm1,$ss1,
      $year2,$month2,$day2,$hh2,$mm2,$ss2
  );
  ($year,$month,$day,$hh,$mm,$ss) = calc_new_date_time
  (
      $year,$month,$day,$hh,$mm,$ss,
      $days_offset,$hh_offset,$mm_offset,$ss_offset
  );
  $datestr = date_to_short($year,$mm,$dd);
  $datestr = date_to_string($year,$mm,$dd);
  ($week,$year) = week_number($year,$mm,$dd);
  ($year,$mm,$dd) = first_in_week($week,$year);
  $weeks = weeks_in_year($year);
  $day_name = day_name_tab($weekday);
  $month_name = month_name_tab($month);
  $weekday = decode_day($day_name);
  $month = decode_month($month_name);
  ($year,$mm,$dd) = decode_date($date);
  $days = days_in_month($year,$mm);
  $version = Date::DateCalc::Version();

For more details, see the "Date::DateCalc" man page!

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

I hope you will find this module benefitful!

Yours,
--
    Steffen Beyer <sb@sdm.de> http://www.engelschall.com/u/sb/
     "There is enough for the need of everyone in this world,
      but not for the greed of everyone." - Mahatma Gandhi
   >> Unsolicited commercial email goes directly to /dev/null <<




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

Date: Tue, 17 Jun 1997 22:25:10 -0700
From: Pierre Merle <pmerle@corp.sun.com>
To: Kirk Rogers <kirkr@trant.sp.trw.com>
Subject: Re: appending two files into one?
Message-Id: <33A77136.5931@corp.sun.com>

what about that :
u2(5.5.1)@/home/pmerle/perl % cat t.pl
#!/usr/local/uk-tools/bin/perl
 
$a=toto;
$b=titi;
$a.=$b;
print "$a\n";
u2(5.5.1)@/home/pmerle/perl % t.pl
tototiti

Pierre


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

Date: 18 Jun 97 06:20:21 GMT
From: "Fredrik Lindberg" <flg@vhojd.skovde.se>
Subject: Re: appending two files into one?
Message-Id: <01bc7baf$b2f19000$e20f10c2@odens.di.vhojd.skovde.se>

Kirk Rogers <kirkr@trant.sp.trw.com> wrote in article
<01bc7b8e$48946af0$338c0481@dna>...
> I know ill get flamed for this one but how do I append two files
together.

Hi.

If you simply wants the content of one file to follow the content of
another file you could
perhaps do something like this:

#!/usr/bin/perl -w
#
open(FILE1, "<file1") or die("Unable to open file1: $!\n");
open(FILE2, "<file2") or die("Unable to open file2: $!\n");

open(OUTFILE, ">outfile") or die("Unable to open outfile: $!\n");

while(<FILE1>) {
   print OUTFILE;
}

while(<FILE2>) {
   print OUTFILE;
}

close(FILE1);
close(FILE2);
close(OUTFILE);

__END__
 
You could also use another sneaky (?) way  like this:

#!/usr/bin/perl -w
#
system("cat file1 file2 > file3");
__END__

or implement it in perl like this:

#!/usr/bin/perl -w
#
# pcat script
#
while(<>) {
   print;
}
__END__

And then run the above like this:

perl pcat file1 file2 > file3

Hope this helps.

/Fredrik


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

Date: Wed, 18 Jun 1997 08:12:08 GMT
From: Magnus.Bodin@tychonides.se (Magnus Bodin)
Subject: Re: appending two files into one?
Message-Id: <33a79603.56573778@news1.telenordia.se>

Pierre Merle <pmerle@corp.sun.com> wrote:

>what about that :
>u2(5.5.1)@/home/pmerle/perl % cat t.pl
>#!/usr/local/uk-tools/bin/perl
> 
>$a=toto;
>$b=titi;
>$a.=$b;
>print "$a\n";
>u2(5.5.1)@/home/pmerle/perl % t.pl
>tototiti
>
>Pierre

You must open the first file in append mode, and 
write the other at the end. 
You are just appending the names.

#! /usr/bin/perl
#
# merge.pl 
#
# usage: merge.pl <file-to-append-to> <file1> [<file2>] [etc]
#
# e.g. merge.pl toto titi tata
#

$targ=shift;

print open(TARG,">>$targ");
foreach $appfile (@ARGV) {
        open(TMP,$appfile);
        while (<TMP>) { 
                print TARG $_; 
        }
        close(TMP);
}
close(TARG);



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

Date: 15 Jun 1997 07:14:38 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Been Through Every FAQ - Point Me to the RIGHT One PLEASE
Message-Id: <5o04ou$b66@fridge-nf0.shore.net>

Shelle (shelle@interaccess.com) wrote:

: 1) How to CORRECTLY install Perl modules on a Windows95 machine;

That varies per module from my minimal experience with modules and
Window 95 / NT.

: 2) How to get around the installing with the lack of "Makefile" on a 
:     Windows95 machine; and

Some modules (which don't use XS) can be copied right to the libs
directory.  Read the READMEs and INSTALL notes for each module you
intend to install.

: 3) How to compile PROPERLY on a Windows95 machine when you don't have a copy 
: of Visual Basic or C++ handy.

You don't if the compiler isn't supported.  I've heard that one can
build NTPerl with the cygnus gcc compiler, but things like dynamic
loading and xs were flaky, and even broken.  I've tried to use djgpp,
but haven't gotten too far.  I haven't had the time or patience to
fool around with it very much over the past couple of months.

: I suppose everyone but me must have been born knowing this, but every time I 
: think i have found something it requires something else which cannot be 
: installed until you have the first item installed.

Nope.  You're feelings are with a number of other Windows / NT users.
I've heard that many Windows 95 users have had success with NTPerl by
compiling on an NT machine, then zipping up the package, and
installing in on their 95 machine, but this is all speculation until I
try it myself.

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 18 Jun 1997 05:37:12 GMT
From: shiloh@best.com (Joe McCaughan)
Subject: Re: call perl script in c program?
Message-Id: <5o7s68$6f1$1@nntp2.ba.best.com>

Chun Xu (xuc@bayfront.org) wrote:
: I have two cgi programs, one written in perl, another in c.  Now, the c
: prgram need to use a subroutine in that perl script?  Is it possible to
: call a perl script in a c program?  If so, how?

: Thanks a lot.

: --chun xu

You probably need to look at the comp.lang.c (or somesuch) newsgroup
for this...

But I think the system() call should work.  Something like:

system("/path/to/perl/program.pl");

I think.

HTH,

--Joe McCaughan



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

Date: 18 Jun 1997 01:32:53 -0500
From: lamont@thrakkorzog.ece.utexas.edu (Lamont Alan Lucas)
Subject: Re: Can't compile perl 5.004 on IRIX 6.2
Message-Id: <5o7vel$mr6@thrakkorzog.ece.utexas.edu>

In article <33A6F013.167E@lmtas.lmco.com>,
Brett Denner  <Brett.W.Denner@lmtas.lmco.com> wrote:
>In the op directory, if I do this "../perl groups.t", I see this:
>
>    1..2
>    #gr1 is <100>
>    #gr2 is <cfd prop>
>    not ok 1
>    ok 2

Remove libnsl from your link path.  I'm betting that your machine is on
YP.  That was the crude yet effective fix for a similar problem I was
having with Irix 6.4.1.  

If you're still having problems, mail me at lamont@segasoft.com and I'll
send you my config.sh.

(oh, and dont' forget not to use `nm`).




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

Date: 18 Jun 1997 03:31:05 GMT
From: dmi@deltanet.com (Dean Inada)
Subject: Re: Case Conversion
Message-Id: <5o7kpp$ker$1@news01.deltanet.com>

In article <5o41ip$gtn@lyra.csx.cam.ac.uk> mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:
>Tom Phoenix  <rootbeer@teleport.com> wrote:
>>I'm claiming that the lc^uc method, while very clever, relies upon an
>>idiosyncracy of the way that English letters are represented in ASCII. If
>>you've got non-English letters or a non-ASCII coding, that algorithm can
>>easily fail.
>
>Not true.    As I pointed out in another posting, the exact assumption
>being made is that for all characters x, either  x eq lc(x)  or
>x eq uc(x).    I would consider a locale not satisfying this condition
>to be seriously bent.
Ok, here are some new versions fixed to match the results of Tom's method
even in a certain suspicious locale containing a character for which
neither  x eq lc(x)  nor  x eq uc(x).
[and another character for which neither  y eq lc(uc(y))  nor  y eq uc(lc(y))]

	$new = $old ^ ((lc($old)^uc($old))|(lc(lc($old))^uc(uc($old))));

	$new = $old ^ ((lc($old)^uc($old))|(lc(uc($old))^lc(uc($old))));

	$new = $old ^ ((lc($old)^$old)|(uc($old)^$old));

So now is there anywhere these revised methods fail?
Anyone know of a locale where length(uc(x)) ne length(lc(x)) ?


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

Date: 15 Jun 1997 19:34:52 GMT
From: dmi@deltanet.com (Dean Inada)
Subject: Re: Case Conversion
Message-Id: <5o1g4s$pg3$1@news01.deltanet.com>

In article <Pine.GSO.3.96.970614083429.4940V-100000@kelly.teleport.com>,
Tom Phoenix  <rootbeer@teleport.com> wrote:
>> 
>> 	$_ ^= lc($_) ^ uc($_);
>
>That's _still_ not going to work on accented characters, tyrannosaurus or
>not. 
So I tried to find a character on which that method wouldn't work by
comparing it against the method you suggested in
<Pine.GSO.3.96.970606192316.6604D-100000@kelly.teleport.com>:

>Here's a method which should work even with accented characters, if
>they're supported on your system.
>
>    $new = join '', map { &revcase($_) } split //, $old;
>    sub revcase {
>	my $ch = shift;
>	return uc($ch) if $ch eq lc($ch);
>	lc($ch);
>  }
>
>Hope this helps!
>
>-- Tom Phoenix        http://www.teleport.com/~rootbeer/
>rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
>Randal Schwartz Case:  http://www.lightlink.com/fors/

Under HP-UX the results were identical in every supported locale.
But under IRIX 6.3 there was one discrepancy with chr(0xd1) in
POSIX::setlocale(&POSIX::LC_CTYPE, "cs") and
POSIX::setlocale(&POSIX::LC_CTYPE, "sk")
(both iso8859/2)
Your method translated it to "\xf1", while mine left it unchanged. 
Strangely, both POSIX::isupper("\xd1") and POSIX::istolower("\xd1")
were true in those locales, and both lc("\xd1") and uc("\xd1") were "\xf1"
(But not in POSIX::setlocale(&POSIX::LC_CTYPE, "pl"), also 8859/2,
for which the two methods gave identical results)
Comparing the charmap files, it looks like this could possibly be due
to a typo of 0xd1 for 0xb1 in the islower table.
But even if we accept that chr(0xd1) is correctly classified as both upper
and lower case, couldn't we argue that the lc^uc method is correctly
reversing the case by transforming that character to itself?


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

Date: Wed, 18 Jun 1997 01:11:33 -0600
From: atspublic@bigfoot.com (Andrew Starr)
Subject: Re: Content Type
Message-Id: <atspublic-1806970111330001@max07-39.qni.com>

In article <33A7672C.A84@unsu.com>, Arthur Merar <amerar@unsu.com> wrote:


> I cannot seem to get this to work.  In order the for HTML to show up, I
> need 'Content-type: text/html'.  To get the gif to show up, I need
> 'Content-type: image/gif'.
> 
> When I try and use both, the image does not come out.  I just get a
> bunch of crap.
> 
> How can I output different content types within the same page?

Unless I'm missing something: (and this is rough, as I'm a beginner, so
don't copy this literally.)

#!user/bin/perl (or whatever for your system)

print "Content-type: text/html"
print "<HTML><HEAD><TITLE>Test</TITLE></HEAD>\n";
print "<BODY><IMG SRC = \"images/picture.gif\"></BODY>\n";
print "</HTML>\n";
exit;

I imagine that instead of picture.gif you could have images/makepic.cgi
which would generate the gif?

But if the same perl script producing the html is also going to produce
the image, I don't see how it can be done other than having the perl
script save the .gif to file and referring to that file. And whether it is
safe to delete the file after the </HTML> line, I don't know. Perhaps each
time the script is run, it can at least overwrite the gif from the
previous run? (Or will this cause problems if two people access the script
close enough in time?

Good luck.

-Andrew

-- 
Andrew Starr  <mailto:atspublic@bigfoot.com>
http://www.amherst.edu/~atstarr/eudora has my unoff. Eudora Site
http://www.amherst.edu/~atstarr/eudora/faq.html by Hank Zimmerman
I have no connection to Qualcomm other than being a happy customer!
If I am answering a question: please post followup questions to the newsgroup as well as mailing me a copy. For new questions, please just post to the newsgroup. Thank you.


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

Date: 16 Jun 1997 02:47:02 GMT
From: sp_robi@alcor.concordia.ca (Sylvain Robitaille)
Subject: Re: converting mode from stat into ls style mode string
Message-Id: <slrn5q9a94.5ao.sp_robi@Elvira.home>

On 12 Jun 1997 08:36:44 -0400, Tom Fawcett <fawcett.NOSPAM@nynexst.com> wrote:
>
>@modes = reverse qw(s r w x r w x r w x);
>$mode = (stat($ARGV[0]))[2];
>for $i (0 .. $#modes) { 
>   $strmode = (($mode & 1) == 0 ? "-" : $modes[$i]) . $strmode;
>   $mode = $mode >> 1;
>}
>
>print "$ARGV[0]: mode $strmode\n";
>
>That handles the basics.  There are a few mode conditions that depend on
>combinations of bits that would need more code.

Right. Much cleaner than what I was doing previously. Thanks.

-- 
----------------------------------------------------------------------
Sylvain Robitaille                          sp_robi@alcor.concordia.ca

Assistant to the System Manager
Computing Services Department
Concordia University                          Montreal, Quebec, Canada
----------------------------------------------------------------------


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

Date: 15 Jun 1997 14:38:30 GMT
From: ct2963@aol.com (CT2963)
Subject: Data extractaction from a character delimited file..
Message-Id: <19970615143801.KAA21969@ladder02.news.aol.com>

Hey there,

I have the following problem and I want to see if I can solve it in Perl.
I have a text file (20 meg) and I want to search for a partial string of
numerics, each line of the file could have any number of 10digit stings
seperated by a char(253), I basically want to pull out any of the 10digit
strings that match my criteria.

I have tried this myself but am having no luck.. Can somebody point me in
the right direction ??

Thanks


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

Date: Sun, 15 Jun 1997 16:35:03 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: CT2963 <ct2963@aol.com>
Subject: Re: Data extractaction from a character delimited file..
Message-Id: <Pine.GSO.3.96.970615162713.8945A-100000@kelly.teleport.com>

On 15 Jun 1997, CT2963 wrote:

> I have the following problem and I want to see if I can solve it in Perl.

Sure, you can solve it in Perl. Is that all you wanted to know? :-)

> I have a text file (20 meg) and I want to search for a partial string of
> numerics, each line of the file could have any number of 10digit stings
> seperated by a char(253), I basically want to pull out any of the 10digit
> strings that match my criteria.

That description of the lines of the file is a bit unclear. Could this be
what you want? 

    my($line, @found);
    while (defined($line = <FILE>)) {
	@found = split chr(253), $line;		# Maybe?
	for (@found) {
	    &process($_);
	}
    }

Or maybe the marked line should be one of these.

	@found = ($line =~ m/\xFD(\d{10})\xFD/g);

	@found = split /\D+/, $line;

	@found = split /\xFD?\D*\xFD/, $line;

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Sun, 15 Jun 1997 14:11:03 -0700
From: Michael Schilli <mschilli@blacksun.com>
Subject: DBI: connect() different for mSQL
Message-Id: <33A45A03.150F@blacksun.com>

Hi all,

I wonder why the DBI manpage (got version 0.82) says 

    DBI->connect($database, $username, $auth, $driver)

is the correct signature but for mSQL only

    DBI->connect($host, $database, '', 'mSQL')

works. Isn't DBI supposed to offer a uniform interface for _all_
databases? Or am I doing something wrong?

Any help apprechiated.

-- 
Michael


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

Date: Sat, 14 Jun 1997 08:37:16 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: declaring a list of variables
Message-Id: <cq6un5.ii.ln@localhost>

MXD38@vm.cc.purdue.edu wrote:
: Sevearl variables are being inputed to a perl.cgi via a form.

[snip]

: I tried something like the following with minimal luck:
:  
: for $i ( 1 .. 4) {
:  
: $Value[$i]=$input{'Value$i'};
                    ^       ^
                    ^       ^
:  
: }
:  
:  
: I didn't work.  Mostly because Perl is looking for a character input of 'Value$
: i'
:  
: So, does anyone know how I can pass such a set of vars?


Use double quotes instead of single quotes.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Sat, 14 Jun 1997 00:32:01 -0700
From: ray <raymond@sj.bigger.net>
Subject: Editor for Perl on Unix box
Message-Id: <33A248F1.51B3@sj.bigger.net>

Does anyone know of a good programmer's editor for Perl on a Unix box? I
am trying to find one with a graphical user interface or has at some
color-syntaxing, such as for comments and keywords. Since Perl has some
keywords that are similar to other languages, an editor in an ide for a
different computer language might work also.



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

Date: 14 Jun 1997 19:26:15 GMT
From: Sol Lightman <bri@mojo.calyx.net>
Subject: Re: Editor for Perl on Unix box
Message-Id: <5nur8n$s56@cdc2.cdc.net>

Kent Perrier <kperrier@Starbase.NeoSoft.COM> wrote:
: >Does anyone know of a good programmer's editor for Perl on a Unix box? I
: >am trying to find one with a graphical user interface or has at some
: >color-syntaxing, such as for comments and keywords. Since Perl has some
: >keywords that are similar to other languages, an editor in an ide for a
: >different computer language might work also.
: vi and emacs seem to work well for most of the people using perl.

We could do better.  Perl interpereter can dump syntax trees if
compiled with debugging support (try -D1024).  I like emacs but 
I can definitely see how it would be worth the effort to write a perl 
native editor, given that we do not have to rewrite parsing algs.

--
Brian S. Julin


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

Date: Sat, 14 Jun 1997 16:54:17 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: ray <raymond@sj.bigger.net>
Subject: Re: Editor for Perl on Unix box
Message-Id: <Pine.GSO.3.96.970614165238.4163D-100000@kelly.teleport.com>

On Sat, 14 Jun 1997, ray wrote:

> Does anyone know of a good programmer's editor for Perl on a Unix box?

Many people use vi or emacs. See what the gurus at your site use and
follow their lead, since they're the ones who can get you out of a hole
when you get stuck. :-)  Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Sun, 15 Jun 1997 14:14:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Matthew White <mwhite@csu.edu.au>
Subject: Re: garbage collection and HTML::Element
Message-Id: <Pine.GSO.3.96.970615135243.21212F-100000@kelly.teleport.com>

On Sun, 15 Jun 1997, Matthew White wrote:

> "If you want to free the memory assosiated with a tree built of
> HTML::Element nodes then you will have to delete it explicitly. The
> reason for this is that perl currently has no proper garbage collector,
> but depends on reference counts in the objects. This scheme fails
> because the parse tree contains circular references (parents have
> references to their children and children have a reference to their
> parent)."

> What I don't understand is does this memory get freed once your program
> has terminated?

Yes; nothing you can do in Perl (or in any other language) should
permanently take up memory.

> I had this same problem when I taught myself C. Every book I read said
> that IF you WISHED to retrieve memory previously allocated with malloc
> then you MAY call free. What if I don't call free or do garbage
> collection.

In Perl, the only garbage collection is automatic. But if you're going to
destroy a circular data structure, just be sure to throw away any
references to it which might keep it alive. Once you've done that,
everything is fine.

> Currently I'm working on the assumption that if a program terminates
> then the OS knows it no longer wants/needs the memory it took and that
> memory is then freed to other programs.

Right.

> What if my program execs? now what does the OS do? Is this an issue?

Depends on the way exec is impletented, but it shouldn't be a problem. In
the worst case, the memory will be released when the new program quits.

> If I do have to free memory explicity in such cases how do I do it and
> what is the most effecient way of doing it? (in Perl not C).

In general, all you need to do is "break the chain". If you delete just
one reference in the circular reference, it's no longer a circle, and Perl
will take care of the rest. 

For a concrete example, to help the folks playing along at home, suppose
that you have a linked list in the shape of a ring, with the last element
pointing back at the start. If you simply discarded your link to the first
element, you'd have a ring of inaccessable items, each with a link to the
next. Since you no longer have a reference to any of them, you can't use
that memory, but Perl can't collect any of it because there's still one
reference to each item. :-(  

In this case, you start with a reference to the first element, and that
element has a reference to the second one. That reference to the second
one is the link we'll break. When you discard the link from the first to
the second (by setting it to undef, for example), Perl sees that the
second element is no longer referenced, so it deletes it. While deleting,
Perl sees that it's deleting the last reference to the third element, so
it deletes that element too. And so on. The whole chain "burns like a
fuse" until they're all destroyed. Easy, huh? Of course, if you have a
complex tree with many loops it may be tougher, but if programming were
easy, they wouldn't need anything as complex as a human to do the work!
:-)

One thing you can do if you know you'll be destroying a complex object
later is to keep a list of (references to a node from) each loop, as you
create each loop. Then it's not hard to run down the list, breaking each
loop one at a time. Of course, that's not necessary if the objects are as
simple as parent-child pairs.

Hope this helps! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 15 Jun 1997 21:37:17 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: garbage collection and HTML::Element
Message-Id: <5o1nad$59k@lyra.csx.cam.ac.uk>

Matthew White  <mwhite@csu.edu.au> wrote:
>
>Currently I'm working on the assumption that if a program terminates
>then the OS knows it no longer wants/needs the memory it took and that
>memory is then freed to other programs.

>Could someone point me to more information on this as I don't want to
>"litter in the park".

The relevant discussion is in the section " Two-Phased Garbage Collection"
of the perlobj man page.   (Not terribly easy to find  -  the magic phrase
is "global destruction".)    Here is the relevant extract, but the bottom
line is "Don't worry about it.   Perl will Do The Right Thing."


     When an interpreter thread finally shuts down (usually when
     your program exits), then a rather costly but complete
     mark-and-sweep style of garbage collection is performed, and
     everything allocated by that thread gets destroyed.  This is
     essential to support Perl as an embedded or a
     multithreadable language.  For example, this program
     demonstrates Perl's two-phased garbage collection:

         #!/usr/bin/perl
         package Subtle;

         sub new {
             my $test;
             $test = \$test;
             warn "CREATING " . \$test;
             return bless \$test;
         }

         sub DESTROY {
             my $self = shift;
             warn "DESTROYING $self";
         }

         package main;

         warn "starting program";
         {
             my $a = Subtle->new;
             my $b = Subtle->new;
             $$a = 0;  # break selfref
             warn "leaving block";
         }

         warn "just exited block";
         warn "time to die...";
         exit;

     When run as /tmp/test, the following output is produced:

         starting program at /tmp/test line 18.
         CREATING SCALAR(0x8e5b8) at /tmp/test line 7.
         CREATING SCALAR(0x8e57c) at /tmp/test line 7.
         leaving block at /tmp/test line 23.
         DESTROYING Subtle=SCALAR(0x8e5b8) at /tmp/test line 13.
         just exited block at /tmp/test line 26.
         time to die... at /tmp/test line 27.
         DESTROYING Subtle=SCALAR(0x8e57c) during global destruction.

     Notice that "global destruction" bit there?  That's the
     thread garbage collector reaching the unreachable.


Mike Guy


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

Date: 15 Jun 1997 05:18:48 GMT
From: dr@ripco.com (David Richards)
Subject: Re: GD and HTML together
Message-Id: <5nvtvo$6n2$1@gail.ripco.com>

In article <EBsvKF.6uA@nonexistent.com>, Abigail <abigail@fnx.com> wrote:
>cwt1959@rit.edu (cwt1959@rit.edu) wrote on 1384 September 1993 in
><URL: news:866343446.13041@dejanews.com>:
>++ A little background here: I successfuly "printed" the USA map along with
>++ an "X" (to indicate where a person lives on the GIF map) when I put in the
>++ coordinates of X,Y in the program manually. (Using Win32 GD.pm)
>
>I would just do:
>http://tiger.census.gov/cgi-bin/mapgen/.gif?lat=36&lon=-96&wid=50&ht=24&iht=230&iwd=400&mark=X,Y,marker,label
>
>No need to reinvent the wheel.

A valid point, but every time I've written pages that depend on an outside
site's features and functionality (government or otherwise), they've moved,
gone down, or just gotten horribly slow because _everybody_else_ decided
to do the same thing.

_IF_ the source code for their mapgen was publically available, _THEN_
writing your own would be reinventing the wheel...
--
David Richards                             Ripco, since Nineteen-Eighty-Three
My opinions are my own, IRS withstanding   Public Access in Chicago
Proud to be the 5,000th least-important    Shell/SLIP/PPP/UUCP/ISDN/Leased
usenet-abuser, by the unofficial GSUA.     (773) 665-0065 !Free Usenet/E-Mail!


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

Date: Sun, 15 Jun 1997 11:26:42 +0200
From: Aldo Calpini <dada@divinf.it>
To: cwt1959@rit.edu
Subject: Re: GD and HTML together
Message-Id: <33A3B552.1DB41DBC@divinf.it>

Hi Chad,

what you're trying to do is not possible at all. A script can't return
content-type: text/html, print out some text, then simply switch to
content type image/gif and print out an image. The easiest way to solve
your problem is to make 2 scripts, the first one that prints out HTML,
the second one (called as source of an image) that prints out the image.
Eg.:

#----script1.pl
require("cgi-lib.pl");
print &PrintHeader;
print "<HTML>...";
# print whatever HTML you want to print, then:
print "<IMG SRC=\"script2.pl\">";

#----script2.pl
use GD;
print "Content-type: image/gif";
# print the image here...

Otherwise, you can also print out graphical text with GD (and it's much
faster). HTH.

Bye,
Aldo Calpini
---/\-----------------------------------------------------------
--/  \--------------------------------- mailto:dada@divinf.it --
-<dada>-- POPULUS VULT DECIPI, -------- mailto:sis@divinf.it ---
--\  /------- ERGO DECIPIATUR --------- http://sis.divinf.it ---
---\/-----------------------------------------------------------


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

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 627
*************************************

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