[18960] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1155 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 18 21:08:41 2001

Date: Mon, 18 Jun 2001 18:05:07 -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: <992912707-v10-i1155@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 18 Jun 2001     Volume: 10 Number: 1155

Today's topics:
        Access C String Pointers? <rob@punketc.com>
    Re: Access C String Pointers? <bart.lateur@skynet.be>
    Re: Access C String Pointers? <bart.lateur@skynet.be>
        ANNOUNCE: Acme::Inline::PERL (John McNamara)
        ANNOUNCE: PerlPoint-Converters 0.10 <perl@jochen-stenzel.de>
        ANNOUNCE: PerlPoint::Package 0.34 <perl@jochen-stenzel.de>
    Re: fork and pass message while waiting (Randal L. Schwartz)
    Re: Looking for Programmers - Numerous projects (Randal L. Schwartz)
        MAJOR perl bug (None)
    Re: MAJOR perl bug <bwalton@rochester.rr.com>
    Re: MAJOR perl bug (Michael Fuhr)
    Re: MAJOR perl bug (Steve Lamb)
    Re: MAJOR perl bug <tony_curtis32@yahoo.com>
    Re: MAJOR perl bug <bart.lateur@skynet.be>
        matching a list with a regex <bart.lateur@skynet.be>
    Re: MYSQL DBI:  $sth->execute($variable) is not working <jboes@qtm.net>
    Re: Performance Advice: CGI servers files <buggs-clpm@splashground.de>
        streaming image to your browser or saving them (None)
    Re: streaming image to your browser or saving them <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 18 Jun 2001 22:34:47 GMT
From: Rob Perelman <rob@punketc.com>
Subject: Access C String Pointers?
Message-Id: <3B2E8200.C2CAF89A@punketc.com>

I've been programming in Perl for many years, but I've recently come
across a situation I've never encountered before.  I just started
programming Perl using the Win32 modules, and I'm trying to interact
with the program Winamp.  Their API lists the following description for
a function I'm trying to call:

Retrieves (and returns a pointer in 'ret') a string that contains the
filename of a playlist entry (indexed by 'data'). Returns NULL if error,
or if 'data' is out of range.

So I'm calling that function in Perl by doing the following:

$file = Win32::GUI::SendMessage($handle, WM_USER, $index, 211);

The problem here is that $file is not the string I'm expecting -- it's
getting an integer, which is apparently a pointer.  But no matter what I
do, I can't seem to get to the string that this integer points to.  I
searched perl.com and the web trying to find a reference to someone
getting a pointer from a system call and turning it back into a string,
and I can't find anything.  Can anyone help?

--
 Rob Perelman :: rob@punketc.com
  LPT1:Presents :: http://www.lpt1.org
   Alphabet Records :: http://www.alphabetrecords.com
    Punk, Etc. [Web Construction] :: http://www.punketc.com


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

Date: Tue, 19 Jun 2001 00:40:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Access C String Pointers?
Message-Id: <rc7titoll8q1td1ufk8brtkb7spt3hbfi1@4ax.com>

Rob Perelman wrote:

>So I'm calling that function in Perl by doing the following:
>
>$file = Win32::GUI::SendMessage($handle, WM_USER, $index, 211);
>
>The problem here is that $file is not the string I'm expecting -- it's
>getting an integer, which is apparently a pointer.  But no matter what I
>do, I can't seem to get to the string that this integer points to.  I
>searched perl.com and the web trying to find a reference to someone
>getting a pointer from a system call and turning it back into a string,
>and I can't find anything.  Can anyone help?

pack/unpack with template 'P' should be a start. I don't know for sure.

Anyway, you ought to be able to *copy* the C string into a perl string,
with an API call (the equivalent to C's strcpy). The function name is
"RTLMoveMemory", it's in KERNEL32, and the parameters are sourcepointer
(your number, 'N'), destpointer (a prefilled perl scalar as buffer,
'P'), and number of bytes ('N'). Try something along the lines of:

	my $CopyMemory = new Win32::API("KERNEL32", "RTLMoveMemory",
	  [qw(N P N)], 'V');
	my $buffer = "\0" x 1025;
	CopyMemory->Call($file, $buffer, 1024);
	print unpack "Z", $buffer;

Untested code, though.

-- 
	Bart.


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

Date: Tue, 19 Jun 2001 00:44:38 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Access C String Pointers?
Message-Id: <538titsh4v5s7tjf45gi1ean4uvfikkg2d@4ax.com>

Bart Lateur wrote:

>	print unpack "Z", $buffer;

	print unpack "Z*", $buffer;

-- 
	Bart.


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

Date: Wed, 13 Jun 2001 22:23:39 GMT
From: jmcnamara@cpan.org (John McNamara)
Subject: ANNOUNCE: Acme::Inline::PERL
Message-Id: <3b27e7e8.2470867@news1.eircom.net>


======================================================================
NAME

    Inline::PERL - Bring the power of PERL programming to your Perl
                   programs.


======================================================================
SYNOPSIS

        use Inline::Files;
        use Inline PERL;

        greeting("PERL");

        __PERL__
        sub greeting {

            $foo = shift @_ || $_[0];

            $! = 1; # Turn buffering off

            for ($i=1, $i<=10, $i++) {
                @a[$i] = $i;
            }

            local $length = @a.length;

            print "Hello, $foo\n";
        }


======================================================================
DESCRIPTION

    Inline::PERL gives you the power of the PERL programming language
    from within your Perl programs. This gives you instant access to
    hundreds of pre-coded applications such as bulletin boards, hit
    counters and shopping carts.

    PERL is a programming language for writing CGI applications. It's
    main strength is that it doesn't have any unnecessary warnings or
    strictures. It is a direct descendent of Perl, a programming
    language which was used mainly by programmers. However, the
    original language required too much reading and thinking and so
    PERL was developed as a language which was more in tune with the
    requirements of the Internet age.


======================================================================
INSTALLATION

    This module does work and it will allow you to include PERL code
    in your Perl program. To install this module you can follow the
    usual procedure with the exception that you should use
    Makefile.PERL instead of Makefile.PL.

        perl Makefile.PERL # Note!!
        make
        make test
        make install


======================================================================
AUTHOR

    John McNamara jmcnamara@cpan.org

    My apologies to Brian Ingerson, the Inline community and, er, the
    PERL community.


======================================================================
COPYRIGHT

    © MMI, John McNamara.

    All Rights Reserved. This module is free software. It may be used,
    redistributed and/or modified under the same terms as Perl itself.





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

Date: Sun, 17 Jun 2001 18:55:09 +0200
From: Jochen Stenzel <perl@jochen-stenzel.de>
Subject: ANNOUNCE: PerlPoint-Converters 0.10
Message-Id: <3B2CE0ED.3EDA9F11@jochen-stenzel.de>


The PerlPoint-Converters Package 0.10 has been uploaded to CPAN
================================================================

This is a major release and you will need version 0.34 of the
PerlPoint-Package for this.

One of the most important changes is the handling of references to
included images, both graphics in \IMAGE tags and bullet graphics
specified via --bullet options. Due to this change you might have to
adapt pathnames in previous PerlPoint input files.

Now we use the following philosophie: PerlPoint input files and the
images referenced from these files are closely related i. e. you have
a directory where the PerlPoint input file is located and in the same
directory or in some sub-directory you keep the image files which
belong to this text. This means that the pathnames in the \IMAGE
tag should be relative to the directory where the PerlPoint file is
located. If your input file includes another PerlPoint file
(\INCLUDE ...) and this second files references some images, then
these images are relative to the home of the included input file.
(Of course it is still possible to specify all pathnames for sources
as absolute pathnames.)

The HTML files (slides) which are created by pp2html can be put into the
current working directory or in some directory which is specified via
the
--slide_dir (or --target_dir option). All the referenced images are now
automatically copied to an image directory which may be specified via
the
--image_dir option. The image dir defaults to the target dir and the
images
are referenced via relative pathnames in the <IMG SRC=....> tags in
HTML.

There is, however, another option which controls how the images are
referenced in the <IMG SRC=....> tags: --image_ref
With this option it is possible to supply logical pathnames, e. g. 
--image_ref="/server_images". This example assumes that your webserver
is configured in such a way that the logical name "/server_images" is
mapped to a common image directory on your server machine. This makes it
possible that several PerlPoint documents which will be installed on 
the server (use the --target_dir option to place the slides in some
/htdocs/xyz directory ...) can share a common base of images. The binary
image files are only copied to the --image_dir directory, when they have
not
yet been copied or when the source is newer than the target file.

Note: Images for bullets (--bullet=path/to/my/bullet.gif) must now be
specified
with absolute pathnames or relative to the current working directory
where
pp2html is called. The bullet images are als copied to the image
directory.

Ok, this sounds a little bit complicated and setting up a good looking 
presentation with the help of templates is still not so easy.
Therefore this release comes with a new set of options:

  --style=style_name
  --style_dir=style_dir_name

These options are explained (shortly) in the Usage of pp2html.
Style_dir_name
is the name of a directory which contains some sub-directories which are
called
styles. A style is a collection of template files and option files which
control
the appearance of the resulting presentation or document. Have a look at
the
styles which come with this release (directory ./pp2html_styles). If you
call
'make test', the t/test_styles.t script will create sample directories
with
these styles.


What about style sheets?
There is also a new option --style_sheet which allows to specifiy a
style sheet
which will be referenced in the header templates. This is still an
experimetal
feature and the results might not be what you expected. At the moment,
pp2html
uses some laypout tricks like <TABLE> ... </TABLE>,  <UL> ... </UL> etc.
to
influence the layout of the slides. This contradicts (in some cases) the
philosophie of a style sheet. 

Things to come:
The most important thing for the next release will be a better
documentation.
* We think of splitting it up into several parts:
  -  Getting started (Tutorial)
  -  FAQs for PerlPoint, pp2html ...
  -  Style Guide
  -  PerlPoint and pp2html Reference Manuals

* There will be more styles in the stlye collection

* Hopefully there will be a Perl/Tk based Editor for options files. The
idea is that
  this script greps for all options in the pp2html source file and
presents them in
  a Perl/Tk GUI. Context sensitive help for each option could also be
extracted
  from the program source ... No need to remember all the options and
their weird
  spellings (more than 80 in the meantime ... :-)

Regards, Lorenz Domke
---------------------------------------------------------------------------------

>>From Changes:
-------------
Revision history for PerlPoint-Converters.

Version 0.10   06/16/2001
-  Nested tags bug fixed: it was not possible to use \I, \C inside 
   a link \L tag.
   NOTE: It is still not posslble to have an \X tag in the body of
         a \L tag!
-  Require PerlPoint::Parser 0.34
-  Using new tag definition Module: PerlPoint::Tags::HTML,
PerlPoint::Tags::LaTeX
-  Comment with version numbers in each created file
-  Bugfix: \C, \I, \B, ... etc in headers was not correctly handled in
former versions
-  --box_border option (for border width of text boxes)
-  --style_sheet option (still as an experiment; the behaviour of
pp2html may change
   when style sheets are used)
-  die when wrong options have been specified
-  workaround for bug in TreeApplet: / was not possible in headers.
   now slashes are replaced with commas.
-  Empty fields in tables are now filled with "&nbsp;" so that the
border will be
   displayed
-  --style_dir and --style options
   Support for styles (pre-defined sets of template and configuration
files)
-  Bug with list indentation fixed: if the last item in a list is
shifted (i.e.
   shift_level > 1) then the following text or block was indented. Now
the
   shift_level is automatically reduced.
-  Some new Keywords which are replaced when templates are copied to the
   target directory: TOP_LEFT_TXT, TOP_MIDDLE_TXT, TOP_RIGHT_TXT,
   same for BASE, and LOGO_IMAGE_FILENAME;
   corresponding options: --top_left_txt, ...
-  Option --slide_md5: all filenames have the form 
    <slide_prefix><md5-checksum>.<slide_suffix>
-  Nested tables are now supported (see PerlPoint::Parser Docu)
-  Variables can now be used in template Files, see the
ex_std_norm-top.tpl for an
   example: VAR(AUTHOR)
-  support of hierarchical anchor names for slide headers
-  pp2latex: fix for formatting of URLs included (thanks to Alex Sigel)

>>From README:
------------

Introduction
------------
PerlPoint is a simple text format which allows easy typing of text
with headlines, bullet lists, normal text paragraphs, indented
paragraphs for code examples etc., from which slides for presentations
can be generated by a script without the need of proprietary software.
Since there is a large variety of platforms which provide web browsers,
HTML is a good choice for the output format. In principle, however, it
is possible to generate each output format whose specification is
known. At the moment there exist converters for HTML, LaTeX (alpha
software)
and SDF. The latter both may be used to generate printable output or to
provide the basis for further processing.


What's new in this version
--------------------------
This is version 0.10
You will need PerlPoint-Packet version 0.34 for this release.

Please refer to file "Changes".

NOTE: This is a major release. The handling of directories in \IMAGE
tags has changed:
      Now the image filenames must be specified relative to the calling
PerlPoint 
      file (or as absolute pathnames). 

      Filenames specified with the --bullet options must now also be
relative to
      the start directory (where pp2html is called) or relative to the
style
      directory.

      The --style, --style_dir options are new and should simplify the
handling of
      templates. You can now build a collection of pre-defined styles
which can
      easily be called with the --style option.

NOTE: Documentation is not yet perfect. This will be one of the major
issues of the
      next release which will come soon! Please keep tuned.


Installation
------------
Just get the PerlPoint-Converters-<release>.tar.gz file and unpack it in
a temp directory:

  tar zxvf PerlPoint-Converters-<release>.tar.gz 
  cd PerlPoint-Converters-<release>
  perl Makefile.PL
  make
  make test
  make install

The main program is `pp2html'. Try `pp2html --help | less' to get more 
information.

The test script `t/test_pp.t', which is invoked via `make test', runs
the input 
file `ppdoc.pp' four times through `pp2html' using four different
configuration
files.  The resulting HTML files are placed in the `ex_*'
subdirectories. These
examples contain documentation for `pp2html'.

Bug Reports
-----------
Please send bug reports and requests to <lorenz.domke@gmx.de>

Lorenz Domke

-- 
-------------------------------------------------------------------------
Lorenz Domke                                       
lorenz.domke@pixel.de
Endelhauserstr. 30     GnuPG Key-ID: BACCE490        
lorenz.domke@gmx.de
D-80686 München                                    Tel: (0 89) 5 70 33
80




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

Date: Sat, 16 Jun 2001 16:42:54 +0200
From: Jochen Stenzel <perl@jochen-stenzel.de>
Subject: ANNOUNCE: PerlPoint::Package 0.34
Message-Id: <3B2B706E.3E80791A@jochen-stenzel.de>


Hello,

PerlPoint::Package 0.34 just entered CPAN. This is a major release,
you'll need the new PerlPoint::Converters 0.10 as well.

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

What is PerlPoint::Package? From the README:

This package provides modules to write PerlPoint
translator software. The PerlPoint format, initially
designed by *Tom Christiansen*, is intended to provide
a simple and portable way to generate slides without
the need of a proprietary product. Slides can be prepared
in a text editor of your choice, generated on a any platform
where you find perl, and presented by any browser which can
render the chosen output format.

To sum it up, Perl Point Software takes an ASCII text
and transforms it into slides written in a certain
document description language. This is, by tradition,
usually HTML, but you may decide to use another
target format like XML, SGML, TeX or whatever you want.

The package comes with a reference converter
implementation pp2sdf, generating SDF from PerlPoint.

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

Changes:

* New, flexible way to declare tags by module.

* Improved performance. Parsing could be accelerated significantly.

* More paragraphs cached.

* Cache is rebuilt automatically if modified builder components
  (parser, used constants, serializer) are detected.

* Tag declared tables can be inlined now, declaring a string as
  row separator by the new option *rowseparator*. This means
  that you can write things like \TABLE{rowseparator="+++"}
  A | B | C +++ 1 | 2 | 3 \END_TABLE just as part of a text
  paragraph.

* Tables can be *nested*.

  If the converter allows to use this feature, it is now valid
  PerlPoint to write funny things like \TABLE{rowseparator="+++"}
  column 1 | column 2 | B<\TABLE{rowseparator="%%%"} n1 |
  n2 %%% n3 | n4 \END_TABLE> +++ xxxx | yyyy | zzzzz +++ uuuu |
  vvvv | wwwww \END_TABLE.

* Startup directory and source nesting level are made accessible
  via variables. Converters can "predeclare" variables (setting
  up them internally at startup time so that all users can access
  them just like variables specified explicitly in a document).

* Simplified condition interface.

  Access to user settings and variable values via interface
  functions, hiding the (perly) details:

   ? flagSet('myFlag') or varValue('var') eq 'value'

  Well, Perl is still to be seen ;-)

* pp2sdf could be significantly improved. Almost all pp2html
  tags are directly supported now - have a look at the
  impressive results!

* New basic tag \READY stops parsing instantly. Useful in
  conditional or dynamically made document parts.

* Active contents: full Perl access provided on request.

* Several bugfixes.


                            Jochen





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

Date: 18 Jun 2001 17:36:52 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: fork and pass message while waiting
Message-Id: <m1g0cxqp97.fsf@halfdome.holdit.com>

>>>>> "Kevin" == Kevin Joseph <kejoseph@hotmail.com> writes:

Kevin> I am trying to write a perl script which would fork this process and 
Kevin> pass a message back to server every 250 sec. This way IE/Netscape and 
Kevin> would not timeout and when the process has completed, it will output
Kevin> the information to the web page.

See <http://www.stonehenge.com/merlyn/WebTechniques/col20.html>.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 18 Jun 2001 17:51:56 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Looking for Programmers - Numerous projects
Message-Id: <m18zipqok3.fsf@halfdome.holdit.com>

>>>>> "alan@" == alan@  <alan@headru.sh> writes:

>> You have posted a job posting or a resume in a technical group.

alan@> So why add to the problem by replying ?

To let both the original poster and anyone watching (even delayed via
groups.google.com and other archivers) that this is disruptive
behavior.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 18 Jun 2001 16:53:29 -0700
From: pohanl@aol.com (None)
Subject: MAJOR perl bug
Message-Id: <12124e47.0106181553.59c020ff@posting.google.com>

try this out...

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

my(@array)=("1","2","3","4");
my($variable);
$variable=@array;
print $variable;

The above will print out 4 (4 items in the array).

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

now do this...
my(@array)=("1","2","3","4");
my($variable)=@array;
print $variable;

The above will print out 1 (the first element in the database)!!!


This is a major bug in perl!
there is a difference between setting a scalar to an array
during declaration and one after declaration!  If you are trying
to find out the number of elements in an array and set the
scalar to the array during declaration of the scalar, you will
not the get correct answer!

the version of perl i am using is activeperl.


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

Date: Tue, 19 Jun 2001 00:09:41 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: MAJOR perl bug
Message-Id: <3B2E902F.2B1B71D6@rochester.rr.com>

None wrote:
> 
> try this out...
> 
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> 
> my(@array)=("1","2","3","4");
> my($variable);
> $variable=@array;
> print $variable;
> 
> The above will print out 4 (4 items in the array).
> 
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> 
> now do this...
> my(@array)=("1","2","3","4");
> my($variable)=@array;
> print $variable;
> 
> The above will print out 1 (the first element in the database)!!!
> 
> This is a major bug in perl!

Not so.  Try:

    my $variable=@array;

which is what you should write if you want the assignment to occur in a
scalar context.  Doing:

    my($variable)=@array;

causes the assignment to occur in a list context.  See:

    perldoc perlsub

for details, particularly the section about "Private Variables via
my()".

> there is a difference between setting a scalar to an array
> during declaration and one after declaration!  If you are trying

No, you guessed at the wrong reason.  The right reason is context. 
Don't guess, rather read the docs.

> to find out the number of elements in an array and set the
> scalar to the array during declaration of the scalar, you will
> not the get correct answer!
> 
> the version of perl i am using is activeperl.
-- 
Bob Walton


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

Date: 18 Jun 2001 18:15:09 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: MAJOR perl bug
Message-Id: <9gm5id$93u@flatland.dimensional.com>

pohanl@aol.com (None) writes:

> my(@array)=("1","2","3","4");
> my($variable);
> $variable=@array;
> print $variable;
>
> The above will print out 4 (4 items in the array).

Correct.  Here are some quotes from the the perldata manual page:

"Assignment to a scalar evaluates the right-hand side in scalar
context, while assignment to an array or hash evaluates the righthand
side in list context.   Assignment to a list (or slice, which is just
a list anyway) also evaluates the righthand side in list context."

"If you evaluate an array in scalar context, it returns the length of
the array."

> now do this...
> my(@array)=("1","2","3","4");
> my($variable)=@array;
> print $variable;
>
> The above will print out 1 (the first element in the database)!!!

Correct.  You're assigning to a list of variables, so @array is
evaluated in list context.  Each element in @array will be assigned
to a variable in your list.  Since your list has only one variable,
only the first element in @array is assigned.  If you had done this:

my ($variable1, $variable2) = @array;

then $variable1 would contain "1" and $variable2 would contain "2".

> This is a major bug in perl!

It's not a bug, it's a feature :-)

> there is a difference between setting a scalar to an array
> during declaration and one after declaration!  If you are trying
> to find out the number of elements in an array and set the
> scalar to the array during declaration of the scalar, you will
> not the get correct answer!

No, there's a difference between evaluating an array in scalar
context and list context:

$variable = @array;     # scalar context
my $variable = @array;  # scalar context

($variable) = @array;     # list context
my ($variable) = @array;  # list context

Whether the assignment happens at the same time as the declaration is
irrelevant.  The two scalar context statements above should give
the same results (4), while the two list context statements should
also give the same results (1).

See the perldata manual page for more information about the difference
between scalar and list context.  If you can't find it on your system,
you can find it here:

http://www.perl.com/pub/doc/manual/html/pod/perldata.html

Hope this clears things up.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


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

Date: Tue, 19 Jun 2001 00:18:43 -0000
From: grey@despair.dmiyu.org (Steve Lamb)
Subject: Re: MAJOR perl bug
Message-Id: <slrn9it6j3.2hp.grey@teleute.dmiyu.org>

On 18 Jun 2001 16:53:29 -0700, None <pohanl@aol.com> wrote:
>now do this...
>my(@array)=("1","2","3","4");
>my($variable)=@array;
>print $variable;

>The above will print out 1 (the first element in the database)!!!

{grey@antelope:~} perl
my(@array) = (1,2,3,4);
my $variable = @array;
print("$variable\n");
4

>This is a major bug in perl!

    No, this is a perfectly valid explination in perl and one of the many
reasons I have moved away from it.

>there is a difference between setting a scalar to an array
>during declaration and one after declaration!  If you are trying
>to find out the number of elements in an array and set the
>scalar to the array during declaration of the scalar, you will
>not the get correct answer!

    You got the correct answer.  In the latter case my is taking the array you
have constructed with () and mapped the elements from @array onto the
variables in the anonymous array you fed my.

    To test this, try the following:

{grey@antelope:~} perl
my(@array) = (1,2,3,4);
my($one,$two,$three,$four) = @array;
print("$one $two $three $four\n");
1 2 3 4

{grey@antelope:~} perl
my(@array) = (1,2,3,4);
my $one, $two, $three, $four = @array;
print("$one $two $three $four\n");
   4

    As I said, it is this contextual behavior that is driving me away from
perl since parens sometimes need to be used for grouping in logic yet they can
also alter the form of the data you're passing.  But that isn't a bug, that is
the language.

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
         ICQ: 5107343          | main connection to the switchboard of souls.
    To email: Don't despair!   |  -- Lenny Nero, Strange Days
-------------------------------+---------------------------------------------


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

Date: 18 Jun 2001 19:18:48 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: MAJOR perl bug
Message-Id: <87k829uxsn.fsf@limey.hpcc.uh.edu>

>> On 18 Jun 2001 16:53:29 -0700,
>> pohanl@aol.com (None) said:

> my(@array)=("1","2","3","4");
> my($variable);
> $variable=@array;
> print $variable;
> 
> The above will print out 4 (4 items in the array).
> 
> my(@array)=("1","2","3","4");
> my($variable)=@array;
> print $variable;

> The above will print out 1 (the first element in the
> database)!!!

> This is a major bug in perl!  there is a difference
> between setting a scalar to an array during declaration
> and one after declaration!  If you are trying to find
> out the number of elements in an array and set the
> scalar to the array during declaration of the scalar,
> you will not the get correct answer!

Assignment 1 is a scalar context (so you get the number of
array elements).  Assignment 2 is a list context (so you
might think of the variable list (...) on the LHS overlaid
on the array, thus "$variable" is in the same position as
the first element of @array, and thus gets the value "1").

[ Taking this kind of sensationalist and somewhat
  antagonistic tone isn't going to get you very far in
  clp.misc.  Reducing the number of "!"s might be an idea
  too. ]

Or is this a troll I've fallen for?

hth
t
-- 
Just reach into these holes.  I use a carrot.


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

Date: Tue, 19 Jun 2001 01:01:22 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: MAJOR perl bug
Message-Id: <739tit48uherf8s2i629vpoa31ar8ulfcp@4ax.com>

None wrote:

>This is a major bug in perl!
>there is a difference between setting a scalar to an array
>during declaration and one after declaration!

No it's not. It's a "scalar" vs. "list" context thing.

Add these to yours:

	my $variable = @array;	# 4

	($variable) = @array;	# 1

-- 
	Bart.


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

Date: Tue, 19 Jun 2001 00:58:33 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: matching a list with a regex
Message-Id: <ib8tito5kdf1j4ffi8jt0c1kb07crc9c3u@4ax.com>

Is there a simple way that I'm missing, to match a string containing a
list of items, without repeating the pattern?

For example, uppose an item can be a number or a string:

	\d+
or
	"[^"]*"

Items are separated by one comma, preceded with an opening paren,
followed by a closing paren. No comma is allowed at the start or at the
end of the list.

It should match:

	(123,"abc",10)
or
	(123)
or even
	()

but not
	(,123)
or
	(123,)


This is a working solution:

	/\((?:(?:\d+|"[^"]*")(?:,(?:\d+|"[^"]*"))*)?\)/

but the repetition of the term pattern is ugly, especially since my real
pattern will be more complex than this. Ideally, I'd want something that
is only half as big as this one...

-- 
	Bart.


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

Date: Mon, 18 Jun 2001 20:03:51 -0400
From: Jeff Boes <jboes@qtm.net>
Subject: Re: MYSQL DBI:  $sth->execute($variable) is not working.
Message-Id: <tf5tit0bv2mbded6lkkhlis3e0om7v3145@4ax.com>

At some point in time, ctcgag@hotmail.com wrote:

>frm@writeme.com (Frank M) wrote:
>
>>  $sortby = $ENV{'QUERY_STRING'};
>>  #Column given by the user (like Employees.FirstName)
>
>>  my $sql_statement = "SELECT Employees.FirstName, Employees.LastName,
>> PhoneNumbers.*
>>  FROM Employees, PhoneNumbers
>>  WHERE Employees.UserName = PhoneNumbers.UserName
>>  ORDER BY ?";
>>
>>  my $sth = $dbh->prepare($sql_statement);
>>  $sth->execute($sortby) or die "Can't execute SQL statement :
>> $dbh->errstr";
>>
>> The Query gets the info from the database, but the sort method does
>> not work.  I am not sure if $sortby is even being passed to the ORDER
>> BY ? at all.  What could be causing this?
>

Uh-uh. You can't drop in part of a SQL statement this way, only parameters which
become part of an expression. So, while you can do:

my $sth = $dbh->prepare(q!SELECT * FROM TABLE_A WHERE COL_A = ?!);
$sth->execute(123);

you could not do

$sth->execute("2*COL_B");

Instead, you want to do this:

my $sql_statement = "SELECT Employees.FirstName, 
 Employees.LastName, PhoneNumbers.*
 FROM Employees, PhoneNumbers
 WHERE Employees.UserName = PhoneNumbers.UserName
 ORDER BY ";  # note trailing blank
my $sth = $dbh->prepare($sql_statement . $sortby);



--
~~~~~~~~~~~~~~~~|It is by caffeine alone I set my mind in motion, 
Jeffery Boes    |It is by the beans of Java that thoughts acquire speed, 
jboes@qtm.net   |The hands acquire shaking, the shaking becomes a warning, 
UIN 3394914     |It is by caffeine alone I set my mind in motion. 


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

Date: Tue, 19 Jun 2001 00:33:02 +0200
From: buggs <buggs-clpm@splashground.de>
Subject: Re: Performance Advice: CGI servers files
Message-Id: <9glvgc$53m$00$1@news.t-online.com>

flash wrote:

> try using perlcc or perl2exe

Yeah, Baby, yeah.
That will *really* help when you have 20 Meg files ;)
Oh, and you top-posted.

Buggs 


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

Date: 18 Jun 2001 17:05:20 -0700
From: pohanl@aol.com (None)
Subject: streaming image to your browser or saving them
Message-Id: <12124e47.0106181605.171f10d7@posting.google.com>

The following is code that will allow you to stream data to a
person's browser (if displayable image it will be displayed)...

sub streamImage {
  my($filename,$directory)=@_;
  my($filesize)= -s "$directory/$filename";
  chdir $directory;
  print "Content-type: application/octet-stream\n";
  print "Content-Disposition: inline; filename=$filename\n";
  print "Content-Length: $filesize\n";
  print "Content-Description: Display:$filename\n\n";
  $| =1;
  open(IN,"$filename");
  binmode(IN);
  binmode(STDOUT);
  print <IN>
  close IN;
}


the following will prompt the user to save the image (or file)

sub saveImage {
  my($filename,$directory)=@_;
  my($filesize)= -s "$directory/$filename";
  chdir $directory;
  print "Content-type: application/octet-stream\n";
  print "Content-Disposition: attachment; filename=$filename\n";
  print "Content-Length: $filesize\n";
  print "Content-Description: Display:$filename\n\n";
  $| =1;
  open(IN,"$filename");
  binmode(IN);
  binmode(STDOUT);
  print <IN>
  close IN;
}


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

Date: Tue, 19 Jun 2001 00:14:10 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: streaming image to your browser or saving them
Message-Id: <3B2E9131.4B6439E6@rochester.rr.com>

None wrote:
> 
> The following is code that will allow you to stream data to a
> person's browser (if displayable image it will be displayed)...
> 
> sub streamImage {
>   my($filename,$directory)=@_;
>   my($filesize)= -s "$directory/$filename";
>   chdir $directory;
>   print "Content-type: application/octet-stream\n";
>   print "Content-Disposition: inline; filename=$filename\n";
>   print "Content-Length: $filesize\n";
>   print "Content-Description: Display:$filename\n\n";
>   $| =1;
>   open(IN,"$filename");
>   binmode(IN);
>   binmode(STDOUT);
>   print <IN>
>   close IN;
> }
> 
> the following will prompt the user to save the image (or file)
> 
> sub saveImage {
>   my($filename,$directory)=@_;
>   my($filesize)= -s "$directory/$filename";
>   chdir $directory;
>   print "Content-type: application/octet-stream\n";
>   print "Content-Disposition: attachment; filename=$filename\n";
>   print "Content-Length: $filesize\n";
>   print "Content-Description: Display:$filename\n\n";
>   $| =1;
>   open(IN,"$filename");
>   binmode(IN);
>   binmode(STDOUT);
>   print <IN>
>   close IN;
> }
That doesn't even compile.
-- 
Bob Walton


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1155
***************************************


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