You are here: PSPad forum > English discussion forum > Re: perl brackets match

Re: perl brackets match

Goto Page: Previous1 2 3 Next

#11 Re: perl brackets match

Posted by: pspad | Date: 2018-02-17 18:41 | IP: IP Logged

Checked in current build in Perl and it works as expected

Options: Reply | Quote | Up ^


#12 Re: perl brackets match

Posted by: massimobalestra | Date: 2018-02-17 20:08 | IP: IP Logged

I just tried with built 261 and the problem is still there with both the examples I wrote before.
Thanks

Options: Reply | Quote | Up ^


#13 Re: perl brackets match

Posted by: pspad | Date: 2018-02-17 20:33 | IP: IP Logged

massimobalestra:
I just tried with built 261 and the problem is still there with both the examples I wrote before.
Thanks

Sorry, you are right. I tested something else.

Options: Reply | Quote | Up ^


#14 Re: perl brackets match

Posted by: massimobalestra | Date: 2018-02-17 20:38 | IP: IP Logged

No problem.
Thank you for the great editor you made.

Options: Reply | Quote | Up ^


#15 Re: perl brackets match

Posted by: pspad | Date: 2018-02-19 13:33 | IP: IP Logged

massimobalestra:
I just tried with built 261 and the problem is still there with both the examples I wrote before.
Thanks

Your example:

q {` ~ ! @ # $ % ^ & * ( ) _ - + = \ | [ ] { } ' " ; : / ? . < > , } .

I found q function in the Perl doc, but it was q(...) not a q{...}
How Perl knows that q{something}something} expression is not closed by then first '}' occurence?

Options: Reply | Quote | Up ^


#16 Re: perl brackets match

Posted by: massimobalestra | Date: 2018-02-19 16:12 | IP: IP Logged

Hi Jan,
thank you for the great work you do.

The q* operators ( q, qq, qx, qw) work (as often in perl) in a little strange way. And I understand it can be quite complicated in a text editor.

Basically you put the q and then (after eventually a space) a special character. That character is used also as closing character of the quoted text.
And, yes, that character can be parentheses '( )', but also square brackets '[ ]', braces '{ }', slashes '/ /', even a exclamation mark '! !'.

The following document, for example, uses the slash.
perldoc.perl.org

So, these expressions are all equivalent and work in perl.
q {` # ~ ! @ $ % ^ & * ( ) _ - + = \ | [ ] { } ' " ; : / ? . < > , }
q (` # ~ ! @ $ % ^ & * ( ) _ - + = \ | [ ] { } ' " ; : / ? . < > , )
q /` # ~ ! @ $ % ^ & * ( ) _ - + = \ | [ ] { } ' " ; : \/ ? . < > , /
q !` # ~ \! @ $ % ^ & * ( ) _ - + = \ | [ ] { } ' " ; : / ? . < > , !

(Note that to make it work in perl I had to escape the / or the ! in the last two expressions)
If you use a character different than { the braces matching works. But if you use the braces, because of the # in the list of characters, it fails.

This example is different than the first, here the braces matching fails because of the comment character (#).

I hope this helps. If you need any help let me know.
Thank you

Options: Reply | Quote | Up ^


#17 Re: perl brackets match

Posted by: pspad | Date: 2018-02-19 16:52 | IP: IP Logged

Please explain the first line in your example. The } in the middle doesn't need to be escaped? If not, how Perl recognizes, that } doesn't ends it?

Options: Reply | Quote | Up ^


#18 Re: perl brackets match

Posted by: massimobalestra | Date: 2018-02-19 17:40 | IP: IP Logged

Yes, I know, perl is weird.
But I absolutely don't know.
I simply tried.

I open a terminal, in my case cygwin.
then I type perl <enter>
then I paste
************* text to paste *****************
my $needSpecialCharacters = 1;
if ($needSpecialCharacters) {
print
"You Need special characters.\n" .
"Special Characters are:\n" .
q {` ~ ! @ # $ % ^ & * ( ) _ - + = \ | [ ] { } ' " ; : / ? . < > , } .
"\nPlease enter at least one of them\n\n";
}
__END__
************* end text to paste **************

it works.

While if I paste
************* text to paste *****************
my $needSpecialCharacters = 1;
if ($needSpecialCharacters) {
print
"You Need special characters.\n" .
"Special Characters are:\n" .
q /` # ~ ! @ $ % ^ & * ( ) _ - + = \ | [ ] { } ' " ; : / ? . < > , / .
"\nPlease enter at least one of them\n\n";
}
__END__
************* end text to paste **************
It hangs.

I don't know why, I simply tried.

Options: Reply | Quote | Up ^


#19 Re: perl brackets match

Posted by: massimobalestra | Date: 2018-02-22 16:12 | IP: IP Logged

I tried with build 265 and seems to work for me, with both my initial examples.

Thank you very much, Jan
Massimo

Options: Reply | Quote | Up ^


#20 Re: perl brackets match

Posted by: massimobalestra | Date: 2018-06-06 21:46 | IP: IP Logged

Sorry, but there are still problems with the 'q' function in the perl syntax.

if I open a perl script and I type:

$v = q {

(Note: with the space after the =)

as soon as I type the { everything from the q (included the q) becomes invisible. Like it is written in white over a white background.
The text is still there and if I remove the space between the = and the q everything re-appears.

It is a small thing but sometimes it confuses me because often I put a space after the =.

The text disappears when I enter the { regardless if I put a space after the q or not.

I am using PsPad 5.0.0(277) 32 bit on windows 10 (64 bit).

Thank you

Options: Reply | Quote | Up ^


Goto Page: Previous1 2 3 Next





Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR