What are the vestiges of Pascal left in Perl?

  • Thread starter Jean-Baptiste Mazon
  • Start date
J

Jean-Baptiste Mazon

Hi,

The perl manpage mentions the following:

Perl combines (in the author's opinion, anyway) some of the
best features of C, *sed*, *awk*, and *sh*, so people familiar
with those languages should have little difficulty with it.
(Language historians will also note some vestiges of *csh*,
Pascal, and even BASIC-PLUS.)

I could easily find a few examples of Perl features common with C,
sed, awk and sh. With a little additional research, I could find
similarities with csh and BASIC-PLUS, too.

I'm stuck about Pascal.

What vestige did the author have in mind?
 
M

Mirco Wahab

Jean-Baptiste Mazon said:
I'm stuck about Pascal.

What vestige did the author have in mind?

There are some ideas, like:

BEGIN
writeln('Hello, World!')
...
...
writeln('By bye world!')
END.

evolved to:

BEGIN {
print "Hello, World!\n"
}
...
...
END {
print "By bye world!\n";
}

Other points:

# use 'use vars' because it resembles pascals 'var'
# Perl # Pascal
use vars qw'@a1 @a2 @a3';
@a1 = 1 .. 10; # var a1: 1..10;
@a2 = 'a'..'z'; # var a2: 'a'..'z';
@a3 = 'two'..'four'; # var a3: two..four;


Of course, the latter *would not* do what you'd
expect from Pascal ;-)


Regards

M.
 
T

Tony Curtis

Mirco said:
There are some ideas, like:

BEGIN
writeln('Hello, World!')
...
...
writeln('By bye world!')
END.

evolved to:

BEGIN {
print "Hello, World!\n"
}
...
...
END {
print "By bye world!\n";
}

That seems a bit of a stretch to me. The BEGIN and END in perl are
pattern-based as in awk, not a statement block syntactic container.
 
J

Jean-Baptiste Mazon

Mirco Wahab said:
BEGIN {
print "Hello, World!\n"
}
...
...
END {
print "By bye world!\n";
}

Those really look more like awk than Pascal to me :)
# use 'use vars' because it resembles pascals 'var'
# Perl # Pascal
use vars qw'@a1 @a2 @a3';

I don't think both languages calling variables "variables" is going to
be enough for me to rank it a similarity ;-)
@a1 = 1 .. 10; # var a1: 1..10;
@a2 = 'a'..'z'; # var a2: 'a'..'z';
@a3 = 'two'..'four'; # var a3: two..four;

The range operator in list context is a very good one! Thanks!
It sounds pretty much like a conclusive "that's the one!", unless
someone can dig up another candidate of such fine quality.
 
U

usenet

Pascal, and even BASIC-PLUS.)

I'm stuck about Pascal.

Me too. Pascal was my favorite language in college and I knew it
well. When I picked up Perl, I never once thought, "hey, that's like
Pascal". There are some conceptual similarities (RECORDs are like
hashes, etc) and some obvious overlap in keywords and operators, but
otherwise Perl does not strike me as anything whatsoever like Pascal,
and I am at a loss to see any vestiges.
 
M

Mirco Wahab

Abigail said:
Mirco Wahab ([email protected]) wrote on MMMMCMLXXIX September MCMXCIII
in <URL:perls 'BEGIN' and 'END' come from awk where they perform a similar role
as in Perl.

Pascals 'BEGIN' and 'END' are Perls '{' and '}'.

Correct, I was mislead because I considered
Pascal to be *older* than awk and therefore
had these keywords earlier.

But you are right, the meaning of the keywords
in Perl is somehwow close to awk.

Thanks & Regards

Mirco
 
M

Mirco Wahab

Tony said:
That seems a bit of a stretch to me. The BEGIN and END in perl are
pattern-based as in awk, not a statement block syntactic container.

Yepp, after thinking again, this seems to be nonsense
from my side. I was mislead by Pascal being the older
language and containing this keyword pair (which has,
of course, a completely different meaning there).

Sorry & thanks

M.
 
M

Mirco Wahab

Jean-Baptiste Mazon said:
The range operator in list context is a very good one! Thanks!
It sounds pretty much like a conclusive "that's the one!", unless
someone can dig up another candidate of such fine quality.

There are, imho, some identical expressions, like:

length($string); # length(string);
index($string, 'a'); # index(string, 'a');

but I'm not-as-sure-as-before if this
is a qualifying point ;-)

(could come from BASIC)

Regards

M.
 
U

Uri Guttman

MW> Correct, I was mislead because I considered
MW> Pascal to be *older* than awk and therefore
MW> had these keywords earlier.

MW> But you are right, the meaning of the keywords
MW> in Perl is somehwow close to awk.

well, algol used BEGIN/END and PL/I also used END keywords (actually
pl/i didn't officially have keywords). most langs (other than lisp and
fortran which are so early) borrowed/stole ideas from other langs. it is
hard not to do that as most langs are created by someone using another
lang and saying, i want it to also do this feature in this way. larry
did just that as nothing he was using at the time (c, sh, awk) could do
it all and as easily as he wanted. and perl6 is doing this even more
deeply by integrating ideas from many many sources as languages have
evolved greatly since perl was created.

uri
 
M

Mirco Wahab

Abigail said:
However, I doubt that Aho, Kerninghan and Weinberger said "Hmmm, we want
to be able to define actions at the beginning of processing the input,
and at its end. Now, Pascal uses those nifty block delimiters 'BEGIN'
and 'END' - let's borrow them!'.

Thanks, I needed that ;-)

shonky.com/Pics/larson.jpg

Regards

Mirco
 
J

Joe Smith

Jean-Baptiste Mazon said:
Hi,

The perl manpage mentions the following:

Perl combines (in the author's opinion, anyway) some of the
best features of C, *sed*, *awk*, and *sh*, so people familiar
with those languages should have little difficulty with it.
(Language historians will also note some vestiges of *csh*,
Pascal, and even BASIC-PLUS.)

I could easily find a few examples of Perl features common with C,
sed, awk and sh. With a little additional research, I could find
similarities with csh and BASIC-PLUS, too.

BASIC-PLUS had a very useful idiom:

PRINT IF POS(0)

That says to output CR and LF if the terminal's print head was
not already at the left margin. I was very glad to see that
Larry Wall had adopted the

statement if condition;

syntax into Perl.

-Joe
 
B

Bart Lateur

Jean-Baptiste Mazon said:
The perl manpage mentions the following:

Perl combines (in the author's opinion, anyway) some of the
best features of C, *sed*, *awk*, and *sh*, so people familiar
with those languages should have little difficulty with it.
(Language historians will also note some vestiges of *csh*,
Pascal, and even BASIC-PLUS.)

I could easily find a few examples of Perl features common with C,
sed, awk and sh. With a little additional research, I could find
similarities with csh and BASIC-PLUS, too.

I'm stuck about Pascal.

That is odd. I see no mention of Ada. Perl has quite a few things that
appear to be borrowed from Ada (as does Oracle's stored procedure
language PL/SQL):

- "package"
- "elsif"
- originally, the package name separator: the apostrophe -- now the
double colon, but the apostrophe still works: Foo::Bar is the same as
Foo'Bar
- underscores as a soft marker in numbers: 10_000 (= 10000)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top