help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Perl and SQL within the same buffer


From: Luca Ferrari
Subject: Perl and SQL within the same buffer
Date: Mon, 3 Oct 2022 16:18:33 +0200

Hi all,
when I edit PostgreSQL PL/Perl functions, I have a source code that
has a basic SQL mode in the outer part of a function, and Perl in the
inner part.
Is there a way to instrument Perl to recognize and use both modes and
syntax highlight? Something like what it happens when editing HTML and
PHP inside it.
An example of source code I edit:

CREATE OR REPLACE FUNCTION
pwc185.task2_plperl( text )
RETURNS text
AS $CODE$
my ( $input ) = @_;
my @output;
my $counter = 4;

for ( split( //, $input ) ) {
    push @output, 'x'
        and $counter--
        and next if ( /[a-z0-9]/i ) and $counter > 0;
    push @output, $_;
}

return join( '', @output );
$CODE$
LANGUAGE plperl;



Everything outside the $CODE$ lines is SQL, everything insde is Perl.

Any suggestion?

Thanks,
Luca



reply via email to

[Prev in Thread] Current Thread [Next in Thread]