Re: Dave Cross and Bill Joy - separated at birth?
On Mon, Sep 22, 2003 at 09:44:49AM -0400, Chris Devers wrote: And Larry Wall is, of course, Weird Al Yankovich. It's just not the same since Al changed his hair and stopped wearing glasses, really. Still gives a good concert, though. dha -- David H. Adler - [EMAIL PROTECTED] - http://www.panix.com/~dha/ Honk if you love Perl! (or strawberries!) - Larry Wall
Re: Surrey.pm (was: back to the 80's)
On Thu, 18 Sep 2003 19:06, Andy Wardley wrote; How about the Weyside? Not an ale pub but a few on tap, and a nice meeting spot. Yep, that works for me. How about next thursday? Still on for tomorrow at the Weyside? Straight after work? Be about 6pm-ish for me... Anying daring enough to announce this officially on the list ? :-) -- Sam Vilain, [EMAIL PROTECTED] Chance favors the prepared mind. LOUIS PASTEUR
__DATA__ and scalars
Can anyone point me inthe right direction, on how to get variable names stored in __DATA__ to be evaluated ? I have some largish scripts with embedded SQL statements which are ugly. My idea is to store them at the end of the program under __DATA__, parse this, and then refer to them in my code. The parser module works fine, but the final string contains WHERE date = $today_date instead of WHERE date = 2003-09-22 any ideas ? Martin #!/usr/local/bin/perl use strict; use warnings; use some::Module my $today_date = '2003-09-22'; my %sql_code = parse_sqldata(\*DATA); foreach my $sql_line (keys %sql_code) { print SQL name = $sql_line\n; print $sql_code{$sql_line}\n; } __DATA__ *load_this SELECT this,that FROM my_table WHERE date = $today_date *load_that SELECT this,that FROM other_my_table WHERE date = $today_date some_module contains sub parse_sqldata { my ($data_ref) = @_; my (%sql, $found, $sql_code); while($data_ref) { chomp(); next if (/^#/); if (/^\*(\w+)$/) { if (defined $found) { $sql_code =~ s/\n$//; #remove last EOL character $sql_code =~ s/\t/ /g; #replace tabs with spaces $sql{$found} = $sql_code; $found = $sql_code = ''; } $found = $1; } else { $sql_code .= $_\n; } } continue { # process the last sql statement after the read has finished $sql_code =~ s/\n$//; $sql_code =~ s/\t/ /g; $sql{$found} = $sql_code; } return(%sql); } _ Sign-up for a FREE BT Broadband connection today! http://www.msn.co.uk/specials/btbroadband
Re: __DATA__ and scalars
Martin Bower wrote: Can anyone point me inthe right direction, on how to get variable names stored in __DATA__ to be evaluated ? I have some largish scripts with embedded SQL statements which are ugly. My idea is to store them at the end of the program under __DATA__, parse this, and then refer to them in my code. The parser module works fine, but the final string contains WHERE date = $today_date instead of WHERE date = 2003-09-22 any ideas ? Hello, Martin. Use placeholders, if your database support it. Write __DATA__ *load_this SELECT this,that FROM my_table WHERE date = ? In place of __DATA__ *load_this SELECT this,that FROM my_table WHERE date = $today_date And read `perldoc DBI `, to discover how to pass values to placeholders when querying the database. Good luck. Regards. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Luis Campos de Carvalho is Computer Scientist, PerlMonk [SiteDocClan], Cascavel-pm Moderator, Unix Sys Admin Certified Oracle DBA http://br.geocities.com/monsieur_champs/ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Re: __DATA__ and scalars
On Wed, Sep 24, 2003 at 12:32:24PM +, Martin Bower said: Can anyone point me inthe right direction, on how to get variable names stored in __DATA__ to be evaluated ? you could do something like my $data = join , DATA; eval \$date = \$data\;; which is icky but works
Re: __DATA__ and scalars
On Wednesday, September 24, 2003, at 03:04 pm, Simon Wistow wrote: On Wed, Sep 24, 2003 at 12:32:24PM +, Martin Bower said: Can anyone point me inthe right direction, on how to get variable names stored in __DATA__ to be evaluated ? you could do something like my $data = join , DATA; eval \$date = \$data\;; which is icky but works Doesn't work when $data contains any double quotes. Ideally, perl would have an evalqq function to do this sort of thing.
Re: __DATA__ and scalars
On 24 Sep 2003 at 15:20, Dave Hinton wrote: On Wednesday, September 24, 2003, at 03:04 pm, Simon Wistow wrote: you could do something like my $data = join , DATA; eval \$date = \$data\;; which is icky but works Doesn't work when $data contains any double quotes. I think Brian McCauley(sp?) has a solution to this (that he wanted to get into the Perl FAQ) using here-docs. Something like this: my $data = join '', DATA; eval \$data = UNLIKELYSTRING;\n$data\nUNLIKELYSTRING; Now single and double quotes are both allowed and variables are interpolated. And UNLIKELYSTRING (or whatever you choose as a terminator) is, presumably, less likely to occur than a single double quote. Cheers, Philip -- Philip Newton [EMAIL PROTECTED]
Re: __DATA__ and scalars
On Wed, Sep 24, 2003 at 03:20:46PM +0100, Dave Hinton said: Doesn't work when $data contains any double quotes. True. Hence the Icky. Ideally, perl would have an evalqq function to do this sort of thing. This sort of works but can't evaluate variables from other packages. -- script -- print evalqq(join ,DATA); sub evalqq { my $string = $_[0] || return undef; $string=~ s{(\\*)(\$[a-z]+)\W} { \\ x (length($1) / 2) . (!(length($1) % 2) do { no strict 'vars'; eval $2 } || $2) }eg; return $string; } __DATA__ Yo! $foo Blah 'rar' foobbb \$foo \\$foo -- end script -- -- the illusion of knowledge without any of the difficult bits
Re: __DATA__ and scalars
thanks for responses Roger..I'd like to keep the SQL in the same script, so how would the templating systems help ? don't they tend to use external templates ? (scuse my ignorance if not) whats the form if I post this on perlmonks as well ? is it considered double posting ? _ Use MSN Messenger to send music and pics to your friends http://www.msn.co.uk/messenger
Re: __DATA__ and scalars
On Wed, Sep 24, 2003 at 03:50:24PM +0100, Simon Wistow said: This sort of works but can't evaluate variables from other packages. Which is easily fixed. package Bar; use vars qw($somevar); $somevar = 'stuff with quotes'; package Bar::Quux; use vars qw($someothervar); $someothervar = 'nooch'; package main; my $foo= 'blah'; my $RARRR = fleeg with\nlinebreak; print evalqq(join ,DATA); sub evalqq { my $string = $_[0] || return undef; $string =~ s{(\\*)(\$[a-z]+(::[a-z]+)*)} { \\ x (length($1) / 2) . (!(length($1) % 2) do { no strict 'vars'; eval $2 } || $2) }ieg; return $string; } __DATA__ $Bar::somevar $Bar::Quux::someothervar Yo! $foo $RARRR $quirka Blah 'rar' foobbb \$foo \\$foo
Re: __DATA__ and scalars
Martin Bower wrote: The parser module works fine, but the final string contains WHERE date = $today_date instead of WHERE date = 2003-09-22 any ideas ? Use placeholders? See the bind_param part of the DBI doc. (That way you don't need to substitute in the variable, but pass it to DBI when you execute it'll be dropped in). Cheers ti
Re: __DATA__ and scalars
On Wed, Sep 24, 2003 at 02:41:15PM +, Martin Bower wrote: Roger..I'd like to keep the SQL in the same script, so how would the templating systems help ? don't they tend to use external templates ? (scuse my ignorance if not) Other people can tell you about other templating systems. HTML::Template can quite happily read from a __DATA__ section: my $t=HTML::Template-new(arrayref = [DATA]); Roger
is London.pm purely a social group
I have thought of starting a Southampton.pm group and thought more of the basic infrastructure required to support it... 1. Beer 2. Mail server 3. Web Page 4. Oh - members I guess!!! 5. Anyone give me some pointers on what I should be thinking about If I decide to go ahead with this Andy
Re: __DATA__ and scalars
On Wednesday, September 24, 2003, at 03:50 pm, Simon Wistow wrote: On Wed, Sep 24, 2003 at 03:20:46PM +0100, Dave Hinton said: Doesn't work when $data contains any double quotes. True. Hence the Icky. eval quotemeta( $data ); # might work? Still, Luis' suggestion to use placeholders seems most practical to me. -Steve
Re: __DATA__ and scalars
Philip Newton wrote: I think Brian McCauley(sp?) has a solution to this (that he wanted to get into the Perl FAQ) using here-docs. Something like this: my $data = join '', DATA; eval \$data = UNLIKELYSTRING;\n$data\nUNLIKELYSTRING; What's the advantage over this ? $data = eval join '', DATA; (I tend to think that this is an argument in favor of the syntax do FILEHANDLE)
Re: is London.pm purely a social group
On Wed, Sep 24, 2003 at 04:16:22PM +0100, Andy Ford wrote: I have thought of starting a Southampton.pm group and thought more of the basic infrastructure required to support it... 1. Steal Underpants 2. ... 3. Profit! Sorry, couldn't resist. -- # Earle Martin http://c2.com/cgi/wiki?EarleMartin $a=f695a9a2176a7dd1618af6649896ee10f05ea986de18af6277e9a1d8ef4696644569a1d. 8ef46961ae1e64277e9896eea7d92ea8003e9a1d8ef4696f6950;$b=8ALB6AIA4.BA2;$c= join,unpackC*,$b;$c=~s/7/2/g;@b=split,$c;foreach$d(@b){$e=hex(substr($a ,$f,$d));while(length($e)8){substr($e,0,0)=0;}print packb8,$e;$f+=$d;}
Re: is London.pm purely a social group
On Wed, Sep 24, 2003 at 04:16:22PM +0100, Andy Ford wrote: I have thought of starting a Southampton.pm group and thought more of the basic infrastructure required to support it... 1. Beer 2. Mail server 3. Web Page 4. Oh - members I guess!!! 5. Well, I think you should conflate 2 + 3 into getting your PUG signed up with Perl Mongers http://www.pm.org/. Some sort of sweetheart deal with a pub owner might turn out to your advantage: I bring you business, you give us discount. That doesn't necessarily work very well in Very Large Cities. Cheers, Damon -- Damon Allen Davison http://allolex.freeshell.org/
[ANNOUNCE] Surrey.pm Social, Thursday 25 Sep
Hi all, Due to lack of anyone else suitably brave to decide on a Pub location for Surrey.pm, the one suggestion that was seconded will hereby be the designated location for the first (to my knowledge) Surrey.pm meet. This will be at the Weyside, from approximately beer O' clock until stagger home time. For a small picture, and a link to multimap see http://www.beerintheevening.com/pubs/show.shtml/491/ That's tomorrow (IYARTMT), Thursday the 25th of September. The Weyside is in Guildford, which is as we all know the capital of Surrey and therefore the only sensible place to base Surrey.pm. Items to be discussed: a) Is the Weyside a good location for meetings, or does anyone who knows Guildford surrounding towns better than myself know of a better place? b) How often should we meet, and should it be on the last Thursday of the month, or the first Thursday before the last Friday? Straws will be drawn for the Surrey.pm `leader', though quite what duties that will entail is unknown at this time. -- Sam Vilain, [EMAIL PROTECTED] The 100 per cent American is 99 per cent an idiot GEORGE BERNARD SHAW
Re: __DATA__ and scalars
thanks all, some good responses. I loaded my hash as normal, then ran Philips suggestion at the end.nice :-) eval \$sql{$_} = HIDEHI;\n$sql{$_}\nHIDEHI foreach (keys %sql); _ E-Mails sind Ihnen nicht schnell genug? http://messenger.msn.de MSN Messenger - Kommunikation in Echtzeit
Re: is London.pm purely a social group
Andy Ford sent the following bits through the ether: Anyone give me some pointers on what I should be thinking about If I decide to go ahead with this This might be useful: How to run a successful group: http://www.pm.org/successful/ Personally I'm convinced it's about the regular meetings, Leon -- Leon Brocard.http://www.astray.com/ scribot.http://www.scribot.com/ ... Never fork with Unix, it spawns children
Re: is London.pm purely a social group
On Wednesday, Sep 24, 2003, at 16:16 Europe/London, Andy Ford wrote: I have thought of starting a Southampton.pm group and thought more of the basic infrastructure required to support it... [snip] Good god! Don't tell me there are Perl developers near Dorset! (well, nearer than London anyway) I thought I was the only one :-) Adrian