develooper Front page | perl.perl5.porters | Postings from March 2000

Re: hook for qs// operator for embedded SQL?

Thread Previous | Thread Next
Joseph N. Hall
March 20, 2000 00:26
Re: hook for qs// operator for embedded SQL?
Message ID:
On Mon, 20 Mar 2000 08:15:43 +0000 (M.J.T. Guy) wrote:

* Saving two quote characters doesn't seem like a big deal.   Or perhaps
* you want to invent SQL-requests-as-objects?

Well, yes, first you could (in theory) make interpolation context-sensitive.

  @result = qs/select @cols from $table where $col = $val/

Here, @cols needs to be ,-separated, $table and $col need one kind of
interpolation, and $val needs another.  It's certainly not unreasonable
to assume that a future qs// could be smart enough to recognize this
much SQL.

As to the second, you could certainly have:

  $sqlref = qs/blah blah blah ? blah ? blah/;  # return ref in scalar
  @result = $sqlref->execute(@args);

You p5p-ers may or may not understand the significance and popularity of
SQL and Perl but from my contact with the real world, it's headed toward
"huge."  A few syntactical nods in its direction will likely make Perl
many new friends a year or two down the road.

Frankly I think it would be good to reserve the entire qc (where c is
some lowercase alpha) namespace and quote-op syntax.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About