[Phoenix-pm] Running a SQL program within PERL DBI

Anthony R. Nemmer intertwingled at qwest.net
Wed Mar 15 19:29:06 PST 2006


What SPECIFICALLY is wrong with using the & to identify a subroutine 
call, if I am not using prototypes?  Are you saying that it just makes 
the code look uglier?  I always thought prototypes were a hack anyway.

Perl has always used sigils to identify various entities...
$ for scalars, @ for arrays, % for hashs, \ for references, * for 
typeglobs, & for subroutines.  If I am not using prototypes, I don't see 
what the problem is with using & to identify a subroutine call.

I understand that this may all change in Perl 6.

Tony

Metz, Bobby W, WCS wrote:
> Hey thanks for the "&" tip.  Old habit I guess since the folks I learned
> from used it in all their code and I've never read up on Perl 5 calls to
> find out otherwise.  Thought I knew what I was doing :-)
> 
> So, just "@results = mysql_mod::execute($my_sql_file);" does the trick?
> 
> Bobby
> 
> -----Original Message-----
> From: Scott Walters [mailto:scott at illogics.org]
> Sent: Wednesday, March 15, 2006 7:07 PM
> To: Metz, Bobby W, WCS
> Cc: Loo, Peter # PHX; phoenix-pm at pm.org
> Subject: Re: [Phoenix-pm] Running a SQL program within PERL DBI
> 
> 
>> use mysql_mod;
>> $my_sql_file = "blahblahblah"
>> @results = &mysql_mod::execute($my_sql_file);
> 
> Bobby, Peter,
> 
> I'd like to encourage you to drop the &, though.  You needed it in Perl
> 4;
> in Perl 5, you don't, but gives you a funky Perl 4 compatability mode
> where prototypes are disabled.  You don't want this.  It breaks things.
> 
>> foreach $line (@results)
>>  {
>>   # pattern match whatever
>>   # call other routines
>>   # etc.
>>  }
>>
>> This could save you time cut/pasting or re-writing the sqlplus call,
> 
> Yes, there's absolutely no reason why you can't put SQL in a file
> rather than hard-code it into a program.  
> 
>> redirection, or whatever, each and every time you have a new script
>> need.  Again, no point trying to parse the .sql file to perform the
>> queries in DBI...just process the output from sqlplus.
> 
> ... and I posted something that would fork off a process and run it
> in the SQL shell.
> 
>> 	As to leaving the group...give us another chance.  I agree with
>> Brock that your original problem statement wasn't well defined and I
> 
> If it makes you feel any better, I make about $5/hour >=)
> 
> -scott
> _______________________________________________
> Phoenix-pm mailing list
> Phoenix-pm at pm.org
> http://mail.pm.org/mailman/listinfo/phoenix-pm
> 
> 


-- 

I always have coffee when I watch radar!


More information about the Phoenix-pm mailing list