[16164] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3576 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 17:28:35 2000

Date: Mon, 10 Jul 2000 14:28:08 -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: <963264487-v9-i3576@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 10 Jul 2000     Volume: 9 Number: 3576

Today's topics:
        language (was: Mini-Faq (was: Help someone new)) (Reini Urban)
    Re: language (was: Mini-Faq (was: Help someone new)) (Abigail)
    Re: language (was: Mini-Faq (was: Help someone new)) (Bart Lateur)
    Re: language (was: Mini-Faq (was: Help someone new)) (Tad McClellan)
    Re: language (was: Mini-Faq (was: Help someone new)) (Reini Urban)
    Re: language (was: Mini-Faq (was: Help someone new)) (Reini Urban)
    Re: language (was: Mini-Faq (was: Help someone new)) (Keith Calvert Ivey)
    Re: language (was: Mini-Faq (was: Help someone new)) (Reini Urban)
        Learning Perl for NT <gmjohn@home.com>
    Re: Learning Perl for NT <wyzelli@yahoo.com>
    Re: Learning Perl for NT <gmjohn@home.com>
    Re: Learning Perl for NT <wyzelli@yahoo.com>
    Re: Learning Perl for NT (Tad McClellan)
    Re: Learning Perl for NT <flavell@mail.cern.ch>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 09 Jul 2000 13:56:39 GMT
From: rurban@sbox.tu-graz.ac.at (Reini Urban)
Subject: language (was: Mini-Faq (was: Help someone new))
Message-Id: <3968833b.94007866@news>

Tad McClellan wrote:
>I don't see how anyone can claim that Perl is not a computer language.

ask ilya. or ask for a yacc grammar. or ask for a BNF notation.

definition by implementation is just something for the moment, but not
for the future. 
especially when the parser sources get hairier every year, design
principles are subjective and there's still no proper compiler. (as 2nd
reference)
perl might be a "language", for heaven's sake even a "postmodern
computer language", but not a "computer language" per se. 

(But I still like it.)
--
Reini Urban
http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html


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

Date: 09 Jul 2000 10:43:08 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: language (was: Mini-Faq (was: Help someone new))
Message-Id: <slrn8mh4t9.tts.abigail@alexandra.delanet.com>

Reini Urban (rurban@sbox.tu-graz.ac.at) wrote on MMDIV September MCMXCIII
in <URL:news:3968833b.94007866@news>:
^^ Tad McClellan wrote:
^^ >I don't see how anyone can claim that Perl is not a computer language.
^^ 
^^ ask ilya. or ask for a yacc grammar. or ask for a BNF notation.

Well, I have no idea why one needs a yacc grammar or a BNF notation
before it's to be considered a computer language. That'a a totally
arbitrary view. But anyway, here *IS* the yacc grammar for Perl.


Abigail


/*    perly.y
 *
 *    Copyright (c) 1991-2000, Larry Wall
 *
 *    You may distribute under the terms of either the GNU General Public
 *    License or the Artistic License, as specified in the README file.
 *
 */

/*
 * 'I see,' laughed Strider.  'I look foul and feel fair.  Is that it?
 * All that is gold does not glitter, not all those who wander are lost.'
 */

%{
#include "EXTERN.h"
#define PERL_IN_PERLY_C
#include "perl.h"

#define dep() deprecate("\"do\" to call subroutines")

/* stuff included here to make perly_c.diff apply better */

#define yydebug	    PL_yydebug
#define yynerrs	    PL_yynerrs
#define yyerrflag   PL_yyerrflag
#define yychar	    PL_yychar
#define yyval	    PL_yyval
#define yylval	    PL_yylval

struct ysv {
    short* yyss;
    YYSTYPE* yyvs;
    int oldyydebug;
    int oldyynerrs;
    int oldyyerrflag;
    int oldyychar;
    YYSTYPE oldyyval;
    YYSTYPE oldyylval;
};

static void yydestruct(pTHXo_ void *ptr);

%}

%start prog

%{
#if 0 /* get this from perly.h instead */
%}

%union {
    I32	ival;
    char *pval;
    OP *opval;
    GV *gvval;
}

%{
#endif /* 0 */

#ifdef USE_PURE_BISON
#define YYLEX_PARAM (&yychar)
#endif

%}

%token <ival> '{'

%token <opval> WORD METHOD FUNCMETH THING PMFUNC PRIVATEREF
%token <opval> FUNC0SUB UNIOPSUB LSTOPSUB
%token <pval> LABEL
%token <ival> FORMAT SUB ANONSUB PACKAGE USE
%token <ival> WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR
%token <ival> LOOPEX DOTDOT
%token <ival> FUNC0 FUNC1 FUNC UNIOP LSTOP
%token <ival> RELOP EQOP MULOP ADDOP
%token <ival> DOLSHARP DO HASHBRACK NOAMP
%token <ival> LOCAL MY MYSUB
%token COLONATTR

%type <ival> prog decl format startsub startanonsub startformsub
%type <ival> remember mremember '&'
%type <opval> block mblock lineseq line loop cond else
%type <opval> expr term subscripted scalar ary hsh arylen star amper sideff
%type <opval> argexpr nexpr texpr iexpr mexpr mnexpr mtexpr miexpr
%type <opval> listexpr listexprcom indirob listop method
%type <opval> formname subname proto subbody cont my_scalar
%type <opval> subattrlist myattrlist mysubrout myattrterm myterm
%type <pval> label

%nonassoc PREC_LOW
%nonassoc LOOPEX

%left <ival> OROP
%left ANDOP
%right NOTOP
%nonassoc LSTOP LSTOPSUB
%left ','
%right <ival> ASSIGNOP
%right '?' ':'
%nonassoc DOTDOT
%left OROR
%left ANDAND
%left <ival> BITOROP
%left <ival> BITANDOP
%nonassoc EQOP
%nonassoc RELOP
%nonassoc UNIOP UNIOPSUB
%left <ival> SHIFTOP
%left ADDOP
%left MULOP
%left <ival> MATCHOP
%right '!' '~' UMINUS REFGEN
%right <ival> POWOP
%nonassoc PREINC PREDEC POSTINC POSTDEC
%left ARROW
%nonassoc <ival> ')'
%left '('
%left '[' '{'

%% /* RULES */

prog	:	/* NULL */
		{
#if defined(YYDEBUG) && defined(DEBUGGING)
		    yydebug = (PL_debug & 1);
#endif
		    PL_expect = XSTATE;
		}
	/*CONTINUED*/	lineseq
			{ newPROG($2); }
	;

block	:	'{' remember lineseq '}'
			{ if (PL_copline > (line_t)$1)
			      PL_copline = $1;
			  $$ = block_end($2, $3); }
	;

remember:	/* NULL */	/* start a full lexical scope */
			{ $$ = block_start(TRUE); }
	;

mblock	:	'{' mremember lineseq '}'
			{ if (PL_copline > (line_t)$1)
			      PL_copline = $1;
			  $$ = block_end($2, $3); }
	;

mremember:	/* NULL */	/* start a partial lexical scope */
			{ $$ = block_start(FALSE); }
	;

lineseq	:	/* NULL */
			{ $$ = Nullop; }
	|	lineseq decl
			{ $$ = $1; }
	|	lineseq line
			{   $$ = append_list(OP_LINESEQ,
				(LISTOP*)$1, (LISTOP*)$2);
			    PL_pad_reset_pending = TRUE;
			    if ($1 && $2) PL_hints |= HINT_BLOCK_SCOPE; }
	;

line	:	label cond
			{ $$ = newSTATEOP(0, $1, $2); }
	|	loop	/* loops add their own labels */
	|	label ';'
			{ if ($1 != Nullch) {
			      $$ = newSTATEOP(0, $1, newOP(OP_NULL, 0));
			    }
			    else {
			      $$ = Nullop;
			      PL_copline = NOLINE;
			    }
			    PL_expect = XSTATE; }
	|	label sideff ';'
			{ $$ = newSTATEOP(0, $1, $2);
			  PL_expect = XSTATE; }
	;

sideff	:	error
			{ $$ = Nullop; }
	|	expr
			{ $$ = $1; }
	|	expr IF expr
			{ $$ = newLOGOP(OP_AND, 0, $3, $1); }
	|	expr UNLESS expr
			{ $$ = newLOGOP(OP_OR, 0, $3, $1); }
	|	expr WHILE expr
			{ $$ = newLOOPOP(OPf_PARENS, 1, scalar($3), $1); }
	|	expr UNTIL iexpr
			{ $$ = newLOOPOP(OPf_PARENS, 1, $3, $1);}
	|	expr FOR expr
			{ $$ = newFOROP(0, Nullch, $2,
					Nullop, $3, $1, Nullop); }
	;

else	:	/* NULL */
			{ $$ = Nullop; }
	|	ELSE mblock
			{ ($2)->op_flags |= OPf_PARENS; $$ = scope($2); }
	|	ELSIF '(' mexpr ')' mblock else
			{ PL_copline = $1;
			    $$ = newCONDOP(0, $3, scope($5), $6);
			    PL_hints |= HINT_BLOCK_SCOPE; }
	;

cond	:	IF '(' remember mexpr ')' mblock else
			{ PL_copline = $1;
			    $$ = block_end($3,
				   newCONDOP(0, $4, scope($6), $7)); }
	|	UNLESS '(' remember miexpr ')' mblock else
			{ PL_copline = $1;
			    $$ = block_end($3,
				   newCONDOP(0, $4, scope($6), $7)); }
	;

cont	:	/* NULL */
			{ $$ = Nullop; }
	|	CONTINUE block
			{ $$ = scope($2); }
	;

loop	:	label WHILE '(' remember mtexpr ')' mblock cont
			{ PL_copline = $2;
			    $$ = block_end($4,
				   newSTATEOP(0, $1,
				     newWHILEOP(0, 1, (LOOP*)Nullop,
						$2, $5, $7, $8))); }
	|	label UNTIL '(' remember miexpr ')' mblock cont
			{ PL_copline = $2;
			    $$ = block_end($4,
				   newSTATEOP(0, $1,
				     newWHILEOP(0, 1, (LOOP*)Nullop,
						$2, $5, $7, $8))); }
	|	label FOR MY remember my_scalar '(' mexpr ')' mblock cont
			{ $$ = block_end($4,
				 newFOROP(0, $1, $2, $5, $7, $9, $10)); }
	|	label FOR scalar '(' remember mexpr ')' mblock cont
			{ $$ = block_end($5,
				 newFOROP(0, $1, $2, mod($3, OP_ENTERLOOP),
					  $6, $8, $9)); }
	|	label FOR '(' remember mexpr ')' mblock cont
			{ $$ = block_end($4,
				 newFOROP(0, $1, $2, Nullop, $5, $7, $8)); }
	|	label FOR '(' remember mnexpr ';' mtexpr ';' mnexpr ')' mblock
			/* basically fake up an initialize-while lineseq */
			{ OP *forop = append_elem(OP_LINESEQ,
					scalar($5),
					newWHILEOP(0, 1, (LOOP*)Nullop,
						   $2, scalar($7),
						   $11, scalar($9)));
			  PL_copline = $2;
			  $$ = block_end($4, newSTATEOP(0, $1, forop)); }
	|	label block cont  /* a block is a loop that happens once */
			{ $$ = newSTATEOP(0, $1,
				 newWHILEOP(0, 1, (LOOP*)Nullop,
					    NOLINE, Nullop, $2, $3)); }
	;

nexpr	:	/* NULL */
			{ $$ = Nullop; }
	|	sideff
	;

texpr	:	/* NULL means true */
			{ (void)scan_num("1"); $$ = yylval.opval; }
	|	expr
	;

iexpr	:	expr
			{ $$ = invert(scalar($1)); }
	;

mexpr	:	expr
			{ $$ = $1; intro_my(); }
	;

mnexpr	:	nexpr
			{ $$ = $1; intro_my(); }
	;

mtexpr	:	texpr
			{ $$ = $1; intro_my(); }
	;

miexpr	:	iexpr
			{ $$ = $1; intro_my(); }
	;

label	:	/* empty */
			{ $$ = Nullch; }
	|	LABEL
	;

decl	:	format
			{ $$ = 0; }
	|	subrout
			{ $$ = 0; }
	|	mysubrout
			{ $$ = 0; }
	|	package
			{ $$ = 0; }
	|	use
			{ $$ = 0; }
	;

format	:	FORMAT startformsub formname block
			{ newFORM($2, $3, $4); }
	;

formname:	WORD		{ $$ = $1; }
	|	/* NULL */	{ $$ = Nullop; }
	;

mysubrout:	MYSUB startsub subname proto subattrlist subbody
			{ newMYSUB($2, $3, $4, $5, $6); }
	;

subrout	:	SUB startsub subname proto subattrlist subbody
			{ newATTRSUB($2, $3, $4, $5, $6); }
	;

startsub:	/* NULL */	/* start a regular subroutine scope */
			{ $$ = start_subparse(FALSE, 0); }
	;

startanonsub:	/* NULL */	/* start an anonymous subroutine scope */
			{ $$ = start_subparse(FALSE, CVf_ANON); }
	;

startformsub:	/* NULL */	/* start a format subroutine scope */
			{ $$ = start_subparse(TRUE, 0); }
	;

subname	:	WORD	{ STRLEN n_a; char *name = SvPV(((SVOP*)$1)->op_sv,n_a);
			  if (strEQ(name, "BEGIN") || strEQ(name, "END")
			      || strEQ(name, "INIT") || strEQ(name, "CHECK"))
			      CvSPECIAL_on(PL_compcv);
			  $$ = $1; }
	;

proto	:	/* NULL */
			{ $$ = Nullop; }
	|	THING
	;

subattrlist:	/* NULL */
			{ $$ = Nullop; }
	|	COLONATTR THING
			{ $$ = $2; }
	|	COLONATTR
			{ $$ = Nullop; }
	;

myattrlist:	COLONATTR THING
			{ $$ = $2; }
	|	COLONATTR
			{ $$ = Nullop; }
	;

subbody	:	block	{ $$ = $1; }
	|	';'	{ $$ = Nullop; PL_expect = XSTATE; }
	;

package :	PACKAGE WORD ';'
			{ package($2); }
	|	PACKAGE ';'
			{ package(Nullop); }
	;

use	:	USE startsub
			{ CvSPECIAL_on(PL_compcv); /* It's a BEGIN {} */ }
		    WORD WORD listexpr ';'
			{ utilize($1, $2, $4, $5, $6); }
	;

expr	:	expr ANDOP expr
			{ $$ = newLOGOP(OP_AND, 0, $1, $3); }
	|	expr OROP expr
			{ $$ = newLOGOP($2, 0, $1, $3); }
	|	argexpr %prec PREC_LOW
	;

argexpr	:	argexpr ','
			{ $$ = $1; }
	|	argexpr ',' term
			{ $$ = append_elem(OP_LIST, $1, $3); }
	|	term %prec PREC_LOW
	;

listop	:	LSTOP indirob argexpr
			{ $$ = convert($1, OPf_STACKED,
				prepend_elem(OP_LIST, newGVREF($1,$2), $3) ); }
	|	FUNC '(' indirob expr ')'
			{ $$ = convert($1, OPf_STACKED,
				prepend_elem(OP_LIST, newGVREF($1,$3), $4) ); }
	|	term ARROW method '(' listexprcom ')'
			{ $$ = convert(OP_ENTERSUB, OPf_STACKED,
				append_elem(OP_LIST,
				    prepend_elem(OP_LIST, scalar($1), $5),
				    newUNOP(OP_METHOD, 0, $3))); }
	|	term ARROW method
			{ $$ = convert(OP_ENTERSUB, OPf_STACKED,
				append_elem(OP_LIST, scalar($1),
				    newUNOP(OP_METHOD, 0, $3))); }
	|	METHOD indirob listexpr
			{ $$ = convert(OP_ENTERSUB, OPf_STACKED,
				append_elem(OP_LIST,
				    prepend_elem(OP_LIST, $2, $3),
				    newUNOP(OP_METHOD, 0, $1))); }
	|	FUNCMETH indirob '(' listexprcom ')'
			{ $$ = convert(OP_ENTERSUB, OPf_STACKED,
				append_elem(OP_LIST,
				    prepend_elem(OP_LIST, $2, $4),
				    newUNOP(OP_METHOD, 0, $1))); }
	|	LSTOP listexpr
			{ $$ = convert($1, 0, $2); }
	|	FUNC '(' listexprcom ')'
			{ $$ = convert($1, 0, $3); }
	|	LSTOPSUB startanonsub block
			{ $3 = newANONATTRSUB($2, 0, Nullop, $3); }
		    listexpr		%prec LSTOP
			{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
				 append_elem(OP_LIST,
				   prepend_elem(OP_LIST, $3, $5), $1)); }
	;

method	:	METHOD
	|	scalar
	;

subscripted:    star '{' expr ';' '}'
			{ $$ = newBINOP(OP_GELEM, 0, $1, scalar($3)); }
	|	scalar '[' expr ']'
			{ $$ = newBINOP(OP_AELEM, 0, oopsAV($1), scalar($3)); }
	|	term ARROW '[' expr ']'
			{ $$ = newBINOP(OP_AELEM, 0,
					ref(newAVREF($1),OP_RV2AV),
					scalar($4));}
	|	subscripted '[' expr ']'
			{ $$ = newBINOP(OP_AELEM, 0,
					ref(newAVREF($1),OP_RV2AV),
					scalar($3));}
	|	scalar '{' expr ';' '}'
			{ $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3));
			    PL_expect = XOPERATOR; }
	|	term ARROW '{' expr ';' '}'
			{ $$ = newBINOP(OP_HELEM, 0,
					ref(newHVREF($1),OP_RV2HV),
					jmaybe($4));
			    PL_expect = XOPERATOR; }
	|	subscripted '{' expr ';' '}'
			{ $$ = newBINOP(OP_HELEM, 0,
					ref(newHVREF($1),OP_RV2HV),
					jmaybe($3));
			    PL_expect = XOPERATOR; }
	|	term ARROW '(' ')'
			{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
				   newCVREF(0, scalar($1))); }
	|	term ARROW '(' expr ')'
			{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
				   append_elem(OP_LIST, $4,
				       newCVREF(0, scalar($1)))); }

	|	subscripted '(' expr ')'
			{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
				   append_elem(OP_LIST, $3,
					       newCVREF(0, scalar($1)))); }
	|	subscripted '(' ')'
			{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
				   newCVREF(0, scalar($1))); }



term	:	term ASSIGNOP term
			{ $$ = newASSIGNOP(OPf_STACKED, $1, $2, $3); }
	|	term POWOP term
			{ $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
	|	term MULOP term
			{   if ($2 != OP_REPEAT)
				scalar($1);
			    $$ = newBINOP($2, 0, $1, scalar($3)); }
	|	term ADDOP term
			{ $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
	|	term SHIFTOP term
			{ $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
	|	term RELOP term
			{ $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
	|	term EQOP term
			{ $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
	|	term BITANDOP term
			{ $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
	|	term BITOROP term
			{ $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
	|	term DOTDOT term
			{ $$ = newRANGE($2, scalar($1), scalar($3));}
	|	term ANDAND term
			{ $$ = newLOGOP(OP_AND, 0, $1, $3); }
	|	term OROR term
			{ $$ = newLOGOP(OP_OR, 0, $1, $3); }
	|	term '?' term ':' term
			{ $$ = newCONDOP(0, $1, $3, $5); }
	|	term MATCHOP term
			{ $$ = bind_match($2, $1, $3); }

	|	'-' term %prec UMINUS
			{ $$ = newUNOP(OP_NEGATE, 0, scalar($2)); }
	|	'+' term %prec UMINUS
			{ $$ = $2; }
	|	'!' term
			{ $$ = newUNOP(OP_NOT, 0, scalar($2)); }
	|	'~' term
			{ $$ = newUNOP(OP_COMPLEMENT, 0, scalar($2));}
	|	REFGEN term
			{ $$ = newUNOP(OP_REFGEN, 0, mod($2,OP_REFGEN)); }
	|	term POSTINC
			{ $$ = newUNOP(OP_POSTINC, 0,
					mod(scalar($1), OP_POSTINC)); }
	|	term POSTDEC
			{ $$ = newUNOP(OP_POSTDEC, 0,
					mod(scalar($1), OP_POSTDEC)); }
	|	PREINC term
			{ $$ = newUNOP(OP_PREINC, 0,
					mod(scalar($2), OP_PREINC)); }
	|	PREDEC term
			{ $$ = newUNOP(OP_PREDEC, 0,
					mod(scalar($2), OP_PREDEC)); }
	|	myattrterm	%prec UNIOP
			{ $$ = $1; }
	|	LOCAL term	%prec UNIOP
			{ $$ = localize($2,$1); }
	|	'(' expr ')'
			{ $$ = sawparens($2); }
	|	'(' ')'
			{ $$ = sawparens(newNULLLIST()); }
	|	'[' expr ']'
			{ $$ = newANONLIST($2); }
	|	'[' ']'
			{ $$ = newANONLIST(Nullop); }
	|	HASHBRACK expr ';' '}'			%prec '('
			{ $$ = newANONHASH($2); }
	|	HASHBRACK ';' '}'				%prec '('
			{ $$ = newANONHASH(Nullop); }
	|	ANONSUB startanonsub proto subattrlist block	%prec '('
			{ $$ = newANONATTRSUB($2, $3, $4, $5); }
	|	scalar	%prec '('
			{ $$ = $1; }
	|	star	%prec '('
			{ $$ = $1; }
	|	hsh 	%prec '('
			{ $$ = $1; }
	|	ary 	%prec '('
			{ $$ = $1; }
	|	arylen 	%prec '('
			{ $$ = newUNOP(OP_AV2ARYLEN, 0, ref($1, OP_AV2ARYLEN));}
	|       subscripted
			{ $$ = $1; }
	|	'(' expr ')' '[' expr ']'
			{ $$ = newSLICEOP(0, $5, $2); }
	|	'(' ')' '[' expr ']'
			{ $$ = newSLICEOP(0, $4, Nullop); }
	|	ary '[' expr ']'
			{ $$ = prepend_elem(OP_ASLICE,
				newOP(OP_PUSHMARK, 0),
				    newLISTOP(OP_ASLICE, 0,
					list($3),
					ref($1, OP_ASLICE))); }
	|	ary '{' expr ';' '}'
			{ $$ = prepend_elem(OP_HSLICE,
				newOP(OP_PUSHMARK, 0),
				    newLISTOP(OP_HSLICE, 0,
					list($3),
					ref(oopsHV($1), OP_HSLICE)));
			    PL_expect = XOPERATOR; }
	|	THING	%prec '('
			{ $$ = $1; }
	|	amper
			{ $$ = newUNOP(OP_ENTERSUB, 0, scalar($1)); }
	|	amper '(' ')'
			{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1)); }
	|	amper '(' expr ')'
			{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
			    append_elem(OP_LIST, $3, scalar($1))); }
	|	NOAMP WORD listexpr
			{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
			    append_elem(OP_LIST, $3, scalar($2))); }
	|	DO term	%prec UNIOP
			{ $$ = dofile($2); }
	|	DO block	%prec '('
			{ $$ = newUNOP(OP_NULL, OPf_SPECIAL, scope($2)); }
	|	DO WORD '(' ')'
			{ $$ = newUNOP(OP_ENTERSUB,
			    OPf_SPECIAL|OPf_STACKED,
			    prepend_elem(OP_LIST,
				scalar(newCVREF(
				    (OPpENTERSUB_AMPER<<8),
				    scalar($2)
				)),Nullop)); dep();}
	|	DO WORD '(' expr ')'
			{ $$ = newUNOP(OP_ENTERSUB,
			    OPf_SPECIAL|OPf_STACKED,
			    append_elem(OP_LIST,
				$4,
				scalar(newCVREF(
				    (OPpENTERSUB_AMPER<<8),
				    scalar($2)
				)))); dep();}
	|	DO scalar '(' ')'
			{ $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
			    prepend_elem(OP_LIST,
				scalar(newCVREF(0,scalar($2))), Nullop)); dep();}
	|	DO scalar '(' expr ')'
			{ $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
			    prepend_elem(OP_LIST,
				$4,
				scalar(newCVREF(0,scalar($2))))); dep();}
	|	LOOPEX
			{ $$ = newOP($1, OPf_SPECIAL);
			    PL_hints |= HINT_BLOCK_SCOPE; }
	|	LOOPEX term
			{ $$ = newLOOPEX($1,$2); }
	|	NOTOP argexpr
			{ $$ = newUNOP(OP_NOT, 0, scalar($2)); }
	|	UNIOP
			{ $$ = newOP($1, 0); }
	|	UNIOP block
			{ $$ = newUNOP($1, 0, $2); }
	|	UNIOP term
			{ $$ = newUNOP($1, 0, $2); }
	|	UNIOPSUB term
			{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
			    append_elem(OP_LIST, $2, scalar($1))); }
	|	FUNC0
			{ $$ = newOP($1, 0); }
	|	FUNC0 '(' ')'
			{ $$ = newOP($1, 0); }
	|	FUNC0SUB
			{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
				scalar($1)); }
	|	FUNC1 '(' ')'
			{ $$ = newOP($1, OPf_SPECIAL); }
	|	FUNC1 '(' expr ')'
			{ $$ = newUNOP($1, 0, $3); }
	|	PMFUNC '(' term ')'
			{ $$ = pmruntime($1, $3, Nullop); }
	|	PMFUNC '(' term ',' term ')'
			{ $$ = pmruntime($1, $3, $5); }
	|	WORD
	|	listop
	;

myattrterm:	MY myterm myattrlist
			{ $$ = my_attrs($2,$3); }
	|	MY myterm
			{ $$ = localize($2,$1); }
	;

myterm	:	'(' expr ')'
			{ $$ = sawparens($2); }
	|	'(' ')'
			{ $$ = sawparens(newNULLLIST()); }
	|	scalar	%prec '('
			{ $$ = $1; }
	|	hsh 	%prec '('
			{ $$ = $1; }
	|	ary 	%prec '('
			{ $$ = $1; }
	;

listexpr:	/* NULL */ %prec PREC_LOW
			{ $$ = Nullop; }
	|	argexpr    %prec PREC_LOW
			{ $$ = $1; }
	;

listexprcom:	/* NULL */
			{ $$ = Nullop; }
	|	expr
			{ $$ = $1; }
	|	expr ','
			{ $$ = $1; }
	;

my_scalar:	scalar
			{ PL_in_my = 0; $$ = my($1); }
	;

amper	:	'&' indirob
			{ $$ = newCVREF($1,$2); }
	;

scalar	:	'$' indirob
			{ $$ = newSVREF($2); }
	;

ary	:	'@' indirob
			{ $$ = newAVREF($2); }
	;

hsh	:	'%' indirob
			{ $$ = newHVREF($2); }
	;

arylen	:	DOLSHARP indirob
			{ $$ = newAVREF($2); }
	;

star	:	'*' indirob
			{ $$ = newGVREF(0,$2); }
	;

indirob	:	WORD
			{ $$ = scalar($1); }
	|	scalar %prec PREC_LOW
			{ $$ = scalar($1);  }
	|	block
			{ $$ = scope($1); }

	|	PRIVATEREF
			{ $$ = $1; }
	;

%% /* PROGRAM */

/* more stuff added to make perly_c.diff easier to apply */

#ifdef yyparse
#undef yyparse
#endif
#define yyparse() Perl_yyparse(pTHX)

-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


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

Date: Sun, 09 Jul 2000 15:02:16 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: language (was: Mini-Faq (was: Help someone new))
Message-Id: <396a9287.1010784@news.skynet.be>

Reini Urban wrote:

>Tad McClellan wrote:
>>I don't see how anyone can claim that Perl is not a computer language.
>
>ask ilya. or ask for a yacc grammar. or ask for a BNF notation.

>perl might be a "language", for heaven's sake even a "postmodern
>computer language", but not a "computer language" per se. 

Gee, we just had the opposite discussion here, that HTML and XML are
computer languages too, because computer languages are not limited to
programming languages.

Now you're tell me Perl is not only not a programming language, but not
even a computer language either?

-- 
	Bart.


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

Date: Sun, 9 Jul 2000 10:16:01 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: language (was: Mini-Faq (was: Help someone new))
Message-Id: <slrn8mh291.rnq.tadmc@magna.metronet.com>

On Sun, 09 Jul 2000 13:56:39 GMT, Reini Urban <rurban@sbox.tu-graz.ac.at> wrote:
>Tad McClellan wrote:
>>I don't see how anyone can claim that Perl is not a computer language.
                                                      ^^^^^^^^^^^^^^^^^
>
>ask ilya. 


I have never seen Ilya say that Perl was not a computer language.
                                               ^^^^^^^^

I have seen Ilya say many times the Perl is not a programming language.
                                                  ^^^^^^^^^^^


>or ask for a yacc grammar. 


A yacc grammar is not a required condition for a "computer language".


>or ask for a BNF notation.


A BNF grammar is not a required condition for a "computer language".


[ snip stuff relating to what some call "programming languages" ]


>perl might be a "language", for heaven's sake even a "postmodern
>computer language", but not a "computer language" per se. 


Yes it is.

Even lowly HTML is a "computer language".

If you use the right HTML syntax, a computer recognizes it,
and does something (semantics) in response.


It all depends on the definition of the terms used. And I'm
not going to continue with this line, as it is not germane
to describing the hierarchy of comp.lang.perl.misc.


>(But I still like it.)


Me too.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 09 Jul 2000 16:49:59 GMT
From: rurban@sbox.tu-graz.ac.at (Reini Urban)
Subject: Re: language (was: Mini-Faq (was: Help someone new))
Message-Id: <3968ad04.104704346@news>

Abigail wrote:
>Reini Urban (rurban@sbox.tu-graz.ac.at) wrote on MMDIV September MCMXCIII
>in <URL:news:3968833b.94007866@news>:
>^^ Tad McClellan wrote:
>^^ >I don't see how anyone can claim that Perl is not a computer language.

>^^ ask ilya. or ask for a yacc grammar. or ask for a BNF notation.
>
>Well, I have no idea why one needs a yacc grammar or a BNF notation
>before it's to be considered a computer language. That'a a totally
>arbitrary view. But anyway, here *IS* the yacc grammar for Perl.

thanks. so it looks like a computer language to me.
--                                         
Reini


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

Date: Sun, 09 Jul 2000 16:47:43 GMT
From: rurban@sbox.tu-graz.ac.at (Reini Urban)
Subject: Re: language (was: Mini-Faq (was: Help someone new))
Message-Id: <3968ac99.104597022@news>

Bart Lateur wrote:
>Gee, we just had the opposite discussion here, that HTML and XML are
>computer languages too, because computer languages are not limited to
>programming languages.
>Now you're tell me Perl is not only not a programming language, but not
>even a computer language either?

exactly :)
--                                         
Reini


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

Date: Sun, 09 Jul 2000 20:15:07 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: language (was: Mini-Faq (was: Help someone new))
Message-Id: <3968dc43.1635813@nntp.idsonline.com>

rurban@sbox.tu-graz.ac.at (Reini Urban) wrote:

>perl might be a "language", for heaven's sake even a "postmodern
>computer language", but not a "computer language" per se.

I don't understand your logic here.  If Perl is a language and
it's used by computers, why wouldn't it be a computer language?
And aren't postmodern computer languages a subset of computer
languages?  Are you writing in some private language that only
seems to be English?

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Mon, 10 Jul 2000 10:02:08 GMT
From: rurban@sbox.tu-graz.ac.at (Reini Urban)
Subject: Re: language (was: Mini-Faq (was: Help someone new))
Message-Id: <39699c49.39653699@news>

Keith Calvert Ivey wrote:
>rurban@sbox.tu-graz.ac.at (Reini Urban) wrote:
>>perl might be a "language", for heaven's sake even a "postmodern
>>computer language", but not a "computer language" per se.
>
>I don't understand your logic here.  If Perl is a language and
>it's used by computers, why wouldn't it be a computer language?
>And aren't postmodern computer languages a subset of computer
>languages?  Are you writing in some private language that only
>seems to be English?

I was in flame mood. Sorry.
--                                         
Reini


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

Date: Sun, 09 Jul 2000 20:55:53 GMT
From: "Monty Johnston" <gmjohn@home.com>
Subject: Learning Perl for NT
Message-Id: <tF5a5.13630$oj6.89731@news1.rdc1.tx.home.com>

Can someone tell me why this won't work.  I keep getting the following error
no matter what I do.  The file does exist.  Here is the error:

can't open wordslist:No such file or directory at c:\perl\my perl
programs\helloworld.plx line 22.

Here is the code:

init_words();
print "What is your name? ";
$name = <STDIN>;
chomp ($name);
if ($name =~ /^erik\b/i) { # ok to compare this now
    print "Hello, Erik!  How good of you to be here!\n";
} else {
    print "Hello, $name!\n"; # ordinary greeting
    print "What is the secret word? ";
    $guess = <STDIN>;
    chomp ($guess);
    while (! good_word($name,$guess)) {
       print "Wrong, try again. What is the secret word? ";
       $guess = <STDIN>;
       chomp ($guess);
    }
}

## subroutines from here down

sub init_words {
    open (WORDSLIST, "wordslist.txt") ||
 die "can't open wordslist:$!";
    while (defined ($name = <WORDSLIST>)) {
 chomp ($name);
 $word = <WORDSLIST>;
 chomp ($word);
 $words{$name} = $word;
    }
    close (WORDSLIST);
}

sub good_word {
    my($somename,$someguess) = @_; # name the parameters
    $somename =~ s/\W.*//; # get rid of everything after the space
    $somename =~ tr/A-Z/a-z/; # lowercase everything
    if ($somename eq "erik") { # should not need to guess
        return 1; # return value is true
} elsif (($words{$somename} || "groucho") eq $someguess) {
        return 1; # return value is true
} else {
        return 0; # return value is false
}
}

--
Monty Johnston (Super Genius)
gmjohn@home.com

Somedays you're the windshield, somdays you're the bug.




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

Date: Mon, 10 Jul 2000 09:45:22 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Learning Perl for NT
Message-Id: <hz8a5.3$m9.1365@vic.nntp.telstra.net>

Monty Johnston <gmjohn@home.com> wrote in message
news:tF5a5.13630$oj6.89731@news1.rdc1.tx.home.com...
> Can someone tell me why this won't work.  I keep getting the following
error
> no matter what I do.  The file does exist.  Here is the error:
>
> can't open wordslist:No such file or directory at c:\perl\my perl
> programs\helloworld.plx line 22.
>
> sub init_words {
>     open (WORDSLIST, "wordslist.txt") ||
>  die "can't open wordslist:$!";

It is most likely that Perl is not trying to open wordslist.txt where
you think it is.

Try specifying the full local path in the open statement above:

open (WORDSLIST, 'c:/perl/whatever/wordslist.txt') or die "Can't open
c:/perl/whatever/wordslist.txt : $!";

Wyzelli




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

Date: Mon, 10 Jul 2000 01:48:57 GMT
From: "Monty Johnston" <gmjohn@home.com>
Subject: Re: Learning Perl for NT
Message-Id: <dY9a5.13716$oj6.92399@news1.rdc1.tx.home.com>

I had tried using the full path name to the file earlier and that had not
worked.  Your example gave me an idea.  I was using double quotation marks
(as shown in the book) when I changed then to single quotation marks and
used the full path name it worked fine.  Thanks for your help.  I am sure I
will be posting more questions.

"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:hz8a5.3$m9.1365@vic.nntp.telstra.net...
> Monty Johnston <gmjohn@home.com> wrote in message
> news:tF5a5.13630$oj6.89731@news1.rdc1.tx.home.com...
> > Can someone tell me why this won't work.  I keep getting the following
> error
> > no matter what I do.  The file does exist.  Here is the error:
> >
> > can't open wordslist:No such file or directory at c:\perl\my perl
> > programs\helloworld.plx line 22.
> >
> > sub init_words {
> >     open (WORDSLIST, "wordslist.txt") ||
> >  die "can't open wordslist:$!";
>
> It is most likely that Perl is not trying to open wordslist.txt where
> you think it is.
>
> Try specifying the full local path in the open statement above:
>
> open (WORDSLIST, 'c:/perl/whatever/wordslist.txt') or die "Can't open
> c:/perl/whatever/wordslist.txt : $!";
>
> Wyzelli
>
>




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

Date: Mon, 10 Jul 2000 12:20:51 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Learning Perl for NT
Message-Id: <3Raa5.8$m9.1761@vic.nntp.telstra.net>

Monty Johnston <gmjohn@home.com> wrote in message
news:dY9a5.13716$oj6.92399@news1.rdc1.tx.home.com...
> I had tried using the full path name to the file earlier and that had
not
> worked.  Your example gave me an idea.  I was using double quotation
marks
> (as shown in the book) when I changed then to single quotation marks
and
> used the full path name it worked fine.  Thanks for your help.  I am
sure I
> will be posting more questions.
>

That would be because you were using the full path with backslashes
within double quotes, and a backslash is not a backslash within double
quotes.

Note that aside from using single quotes, - no interpolation and no
misinterpretation of the backslash, I also used the forward slash, which
Perl interprets nicely even on win32 systems.

If you need the double quotes (for when the filename or path is stored
in a variable) then you need to escape the backslash  (with a backslash)
so your path becomes "c:\\perl\\stuff\\file.txt".  As you can see, using
the forward slash is simpler.

Wyzelli




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

Date: Sun, 9 Jul 2000 21:59:22 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Learning Perl for NT
Message-Id: <slrn8mibfq.sio.tadmc@magna.metronet.com>


[ Please put your comments *following* the quoted text that you
  are commenting on.
]


On Mon, 10 Jul 2000 01:48:57 GMT, Monty Johnston <gmjohn@home.com> wrote:

>I had tried using the full path name to the file earlier and that had not
>worked.  Your example gave me an idea.  I was using double quotation marks
>(as shown in the book) 


Did the book show any backslash characters in the double quoted string?

If the book didn't, and you do, then copy/paste may not work.

Different data may require different processing.


>when I changed then to single quotation marks and
>used the full path name it worked fine.


The easiest solution would be to use regular, forward slashes
in your paths instead of backslashes, and avoid using the 
command interpreter (DOS shell).


[ snip Jeopardy quoted text ]


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 10 Jul 2000 12:22:56 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Learning Perl for NT
Message-Id: <Pine.GHP.4.21.0007101218470.12548-100000@hpplus03.cern.ch>

On Mon, 10 Jul 2000, Wyzelli wrote:

> Try specifying the full local path in the open statement above:
> 
> open (WORDSLIST, 'c:/perl/whatever/wordslist.txt') or die "Can't open
> c:/perl/whatever/wordslist.txt : $!";

Yes, but better: define the full path to the file, in an obvious
place near the beginning of the script, and then use that in the
program.

No point in coding the same piece of data twice (quite likely with
different typos in each) in some obscure place in the depths of the
code.

Seems a small thing, but it makes programs so much more maintainable.
And onlookers get a much quicker overview of which files and other
resources are referenced by the program.



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3576
**************************************


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