Re: Template::Simple .04 and File::Slurp .16 are on cpan

2011-04-25 Thread Chap Harrison
On Apr 25, 2011, at 3:12 AM, Uri Guttman wrote: finally, i am very proud of the code quality in those two modules. feel free to look at them, ask me questions, flame the code, etc. i have no issues with anything said about my code. I'm an advanced beginner and I'm embarrassed to say that,

Re: Template::Simple .04 and File::Slurp .16 are on cpan

2011-04-25 Thread Chap Harrison
On Apr 25, 2011, at 10:59 AM, Uri Guttman wrote: another real world template is the boilerplate in contracts and legal documents. they have the document written out and fill in all the blank parts. it is a very common concept and well worth knowing how to do it in perl. I'm fully on board

Re: Nature of this list

2011-04-23 Thread Chap Harrison
Tangential to the topic, but related to the traditional programming culture some have described -- I've programmed professionally since 1978, although I haven't come anywhere close to Randal's heights. In the early '90s I was a developer at a DBMS vendor in Kendall Square, Cambridge, which was

Re: Nature of this list

2011-04-23 Thread Chap Harrison
On Apr 23, 2011, at 12:22 PM, Shlomi Fish wrote: Just a note about etymology and semantics - it is a good idea to *never* accuse someone of lying in an online forum. But Shlomi - don't you remember? He #ifdef'd it out! :-p Hee hee. /facetious Chap -- To unsubscribe, e-mail:

Re: Nature of this list

2011-04-23 Thread Chap Harrison
On Apr 23, 2011, at 10:01 AM, Randal L. Schwartz wrote: I just realized something this morning. If you go back through my complaints here and elsewhere over the years, they fall into two main camps: (1) people who answer someone else's question badly [snip] This raises for me the

Re: Nature of this list

2011-04-19 Thread Chap Harrison
On Apr 19, 2011, at 11:17 AM, Rob Dixon wrote: On 19/04/2011 16:00, Peter Scott wrote: If anything is clear from that FAQ it is that the intention is to avoid flames on this list. Casey and Kevin appear to have stopped monitoring this group some time ago, though. I have raised the issue

Re: Nature of this list

2011-04-19 Thread Chap Harrison
On Apr 19, 2011, at 10:54 PM, Brandon McCaig wrote: On Tue, Apr 19, 2011 at 11:38 PM, Chap Harrison c...@pobox.com wrote: Then, add something to the effect that part of the purpose of the list is to acquaint beginners with the culture of advanced, professional programming

Re: Dynamic replacement of the variable

2011-04-18 Thread Chap Harrison
one person, and the only thing it affects is my loyalty. I'll continue to use Perl, and to use the list until something better comes along. I just wish that I still wanted to brag about it. Sincerely, Chap Harrison -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Re: Capturing the output of a shell command

2011-04-05 Thread Chap Harrison
On Apr 5, 2011, at 8:49 AM, Shawn H Corey wrote: You could use open: #!/usr/bin/env perl use strict; use warnings; open my $ls_fh, '-|', 'ls' or die could not open `ls`: $!\n; chomp( my @files = $ls_fh ); close $ls_fh or die could not open `ls`: $!\n; print @files\n; __END__ Is

Re: Parse Key=Val parameters with s///eg

2011-03-19 Thread Chap Harrison
On Mar 18, 2011, at 10:52 PM, Brian Fraser wrote: There is no need to do it in a single expression, other than causing your maintenance programmer some headache. Yes, that was certainly a challenge to follow! Might I conclude, then, that a lot of those Perl extensions are of dubious value,

Re: Parse Key=Val parameters with s///eg

2011-03-18 Thread Chap Harrison
On Mar 18, 2011, at 12:03 PM, C.DeRykus wrote: Neat solution. IMO, though, it's much clearer and simpler (particularly for subsequent maintainers), to identify errors up front if you can and save the time and complexity to review \G and pos() and the implication of a s/// return count

Re: Parse Key=Val parameters with s///eg

2011-03-17 Thread Chap Harrison
On Mar 17, 2011, at 1:49 PM, C.DeRykus wrote: On Mar 16, 9:58 am, c...@pobox.com (Chap Harrison) wrote: #!/usr/bin/perl use warnings; use strict; use feature :5.10; # # $line, unless empty, should contain one or more white-space-separated # expressions of the form # FOO

Re: Parse Key=Val parameters with s///eg

2011-03-17 Thread Chap Harrison
On Mar 17, 2011, at 5:21 PM, Rob Dixon wrote: A s///g is 'successful' if it performs at least one substitution, in which case it will return the number of substitutions made. In your code, it will find as many key=value substrings as possible and replace them with just the value string.

Parse Key=Val parameters with s///eg

2011-03-16 Thread Chap Harrison
I'm trying to write a routine to parse a string containing a series of parameters of the form KEYWORD = VALUE or just KEYWORD (where the value defaults to 1) I was able to write it using a WHILE loop, but then thought I'd try using the 'g' option of s/// to do the iteration. It seems to

Re: Parse Key=Val parameters with s///eg

2011-03-16 Thread Chap Harrison
Oops, I misplaced the final closing parenthesis in the regex. But it doesn't seem to matter. - - - - - #!/usr/bin/perl use warnings; use strict; use feature :5.10; # # $line, unless empty, should contain one or more white-space-separated # expressions of the form # FOO # orBAZ =

Re: 1st line of perl script

2011-01-04 Thread Chap Harrison
On Jan 4, 2011, at 12:09 AM, George Worroll wrote: I would, however, recommend that you use the #!/usr/bin/perl line even on Windows. It will make things a little easier if you have to move the script over to a Unix like system. It won't cause any problems in windows, it will just get

Re: [OT] New Document: How to Start Contributing to or Using Open Source Software

2010-12-31 Thread Chap Harrison
Love conquers all - even those thorny, iconoclastic Perl gurus! Happy New Year. Chap (oops, sorry for the top-post ;-) On Dec 31, 2010, at 8:30 AM, jeff pang wrote: 2010/12/31 Raymond Wan r@aist.go.jp: If we leave it to just the people who contribute and help, then it's no longer a

Re: [OT] New Document: How to Start Contributing to or Using Open Source Software

2010-12-31 Thread Chap Harrison
is obvious. :-) Octavian - Original Message - From: Chap Harrison c...@pobox.com To: Perl Beginners beginners@perl.org Sent: Friday, December 31, 2010 6:17 PM Subject: Re: [OT] New Document: How to Start Contributing to or Using Open Source Software Love conquers all - even

Re: Real life usage

2010-12-18 Thread Chap Harrison
On Dec 18, 2010, at 10:30 AM, Francesco Di Lorenzo wrote: This message is particularly referred to serious programmer (with serious I mean the ones who do programming for work). The question is this: What role do Perl have in your work? In which particular projects you use it? Do you use

Re: smart match question

2010-11-27 Thread Chap Harrison
On Nov 27, 2010, at 7:45 AM, Téssio Fechine wrote: -- tes...@krauzer:~/Perl/Ex/ch15$ cat smart use 5.010; use strict; use warnings; my @divisors = (1, 2); say It's divisible by 2! if @divisors ~~ 2; tes...@krauzer:~/Perl/Ex/ch15$ perl smart

Re: smart match question

2010-11-27 Thread Chap Harrison
On Nov 27, 2010, at 9:01 AM, Chap Harrison wrote: On Nov 27, 2010, at 7:45 AM, Téssio Fechine wrote: Why @divisors ~~ 2 is not true? No idea - it seems to work fine for me: - - - /Users/chap/private/perl$ cat smart use 5.010; use strict; use warnings; my @divisors = (1, 2

Re: smart match question

2010-11-27 Thread Chap Harrison
Yes. The smart match operator was commutative only in version 5.10 of perl. The change was made in the very next release - version 5.10.1. Just wondering now -- does ... @divisors ~~ 2 ... have any meaning now? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Re: given-when problem

2010-11-26 Thread Chap Harrison
On Nov 26, 2010, at 1:10 PM, Téssio Fechine wrote: given($ARGV[0]) { when(/fred/i) { say 'Name has fred in it'; continue } when(/^Fred/) { say 'Name starts with Fred'; continue } when('Fred') { say 'Name is Fred' } default { say I don't see a Fred } }

Re: Managing two versions of Perl

2010-11-19 Thread Chap Harrison
On Nov 19, 2010, at 3:18 AM, Shlomi Fish wrote: On Friday 19 November 2010 06:14:19 Chap Harrison wrote: Perlbrew was mentioned, but it doesn't seem to be unanimously considered a good solution to my problem. Where do you see people speak against perlbrew? See brian d foy's reply at: http

Re: Managing two versions of Perl

2010-11-19 Thread Chap Harrison
On Nov 19, 2010, at 8:03 AM, Brian Fraser wrote: On Fri, Nov 19, 2010 at 7:18 AM, Shlomi Fish shlo...@iglu.org.il wrote: Where do you see people speak against perlbrew? Not the OP, but here you go: http://www.effectiveperlprogramming.com/blog/750/comment-page-1#comment-78 Thanks!

Re: Managing two versions of Perl

2010-11-19 Thread Chap Harrison
On Nov 19, 2010, at 9:55 AM, Chap Harrison wrote: On Nov 19, 2010, at 8:03 AM, Brian Fraser wrote: http://www.effectiveperlprogramming.com/blog/750/comment-page-1#comment-78 Thanks! Also by brian d foy, I see. And he provides a link ... http://www.effectiveperlprogramming.com/blog/92

Managing two versions of Perl

2010-11-18 Thread Chap Harrison
Hi folks, The current version of Ubuntu Linux I'm using comes with Perl 5.10.1, but I want to install and develop under 5.12.2. From what I've read in Perlmonks and Stackoverflow, it's not difficult to install a separate version - all it needs is its own directory. But I'm a little unclear

Re: Bit testing

2010-11-14 Thread Chap Harrison
On Nov 14, 2010, at 4:36 AM, C.DeRykus wrote: And now it seems a little bit inelegant to redefine the closure each time through the loop. for my $flags ( ... ) { my $mask = sub { return ($flags $_[0]) == $_[0] }; given( $flags ) { when ( $mask-($one_and_three)

Linux::Inotify2 - getting a list of watched objects

2010-11-12 Thread Chap Harrison
Hi folks, I don't see any way, through the Inotify2 interface at least, of getting a list of the 'watch' objects that an 'inotify2' object contains. I can use Data::Dumper to see the structure of an inotify2 object ... $VAR1 = bless( { 'w' = { '1' =

Bit testing

2010-11-11 Thread Chap Harrison
I'm almost embarrassed to ask this, but I can't figure out a simple way to construct a switch ('given') statement where the 'when' clauses involve bit-testing. Here's the only way I've figured out to build a switch statement that does the trick. It seems unusually wordy, which makes me think

Database table load utility

2010-11-07 Thread Chap Harrison
Hi folks, I'm in the thinking stages of creating a table-load utility, which reads a tab-separated CSV file and inserts or updates rows in a relational table (probably Oracle). I don't think that will be too hard, having used Perl DBI/DBD modules in the past. What's different is that

Re: Database table load utility

2010-11-07 Thread Chap Harrison
, I realize that this is not specifically a Perl problem at this point, so I guess I'll need to research some Unix-y ways of handling this. On Nov 7, 2010 7:17 PM, Chap Harrison c...@pobox.com wrote: Hi folks, I'm in the thinking stages of creating a table-load utility, which reads a tab

Re: Database table load utility

2010-11-07 Thread Chap Harrison
. Pretty neat. Cheers and thanks! Chap On Nov 8, 2010 12:04 AM, Ishwor Gurung ishwor.gur...@gmail.com wrote: Hi. On 8 November 2010 15:46, Chap Harrison c...@pobox.com wrote: On Nov 7, 2010, at 6:47 PM, shawn wilson wrote: its Unix, I'd use cron as its probably already running. And do

Flip-flop conversations using Socket

2010-09-02 Thread Chap Harrison
Following the guidelines I found in numerous examples on the web, I wrote a simple Client-Server app in Perl. However, it appears that the send buffer does not get flushed until the connection is closed. That's fine for one-way data transfer, but I need the server to be able to receive some

Re: Flip-flop conversations using Socket

2010-09-02 Thread Chap Harrison
On Sep 2, 2010, at 3:51 PM, Uri Guttman wrote: don't use that. use IO::Socket which is higher level and much easier to use. It sure is! Thank you. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Simple, synchronous interaction with a local server process

2010-06-26 Thread Chap Harrison
On Jun 26, 2010, at 7:34 AM, Jenda Krynicky wrote: Did you try DBD::ODBC? I do believe there are still ODBC drivers for dBaseIV installed on your computer so this should work. What problems did not you have? I *think* the problem is that dBaseIV drivers cost money. The company that I

Simple, synchronous interaction with a local server process

2010-06-23 Thread Chap Harrison
-- As can be inferred from the qx above, a synchronous protocol is fine. Sure do appreciate it! Chap Harrison -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Using Archive::Zip to compress two directories into a single zip file

2010-06-02 Thread Chap Harrison
Well, I suppose I've missed a subtlety along the way here. I have two directories: /path/to/existing/directory/foo/ /path/to/existing/directory/bar/ And I want to archive these two directories into a zip file named archive.zip. Here's what I did, using the synopsis of Archive::Zip in CPAN as

How to move a directory to another location on the same filesystem/volume?

2010-05-23 Thread Chap Harrison
Hi, I can't believe I'm having such a hard time with this. I just want a platform-independent way of copying a directory 'A' and its contents into another directory 'B' (as a subdirectory of B, named A). Not crossing filesystems or devices. Various online sources have said you copy

Re: How to move a directory to another location on the same filesystem/volume?

2010-05-23 Thread Chap Harrison
Whoof! Thanks, Shlomi - I guess Copy-Recursive has what I need. I had no idea it would be such a can of worms. Chap On May 23, 2010, at 10:57 PM, Shlomi Fish wrote: Hi Chap, On Monday 24 May 2010 04:09:52 Chap Harrison wrote: Hi, I can't believe I'm having such a hard time

Patching a binary file

2010-05-09 Thread Chap Harrison
Hi, I need to search a binary file using a regex, and replace a 20-byte string with another 20-byte string (binary). The FAQ talks about perl -pi -e 's/foo/bar/g' myfile, but given that I'm dealing with binary, and that I want to do this from within a larger script, that is less than

Re: Patching a binary file

2010-05-09 Thread Chap Harrison
On May 9, 2010, at 11:57 AM, John W. Krahn wrote: This *may* work -- UNTESTED: use Fcntl ':seek'; my $filename = 'binary_file'; open my $FH, '+:raw', $filename or die Cannot open '$filename' $!; read $FH, my $data, -s $FH or die Cannot read from '$filename' $!; length $data == -s $FH or

Re: OSX Snow Leopard - cpan doesn't know where .cpan/ is

2010-01-08 Thread Chap Harrison
On Jan 8, 2010, at 10:25 AM, Jim Gibson wrote: You can install modules without using CPAN. Download the distribution file from: http://search.cpan.org/CPAN/authors/id/A/AD/ADAMK/File-HomeDir-0.89.tar.gz Unpack it in any directory. Go to the top-level directory (File-HomeDir-0.89).

Re: OSX Snow Leopard - cpan doesn't know where .cpan/ is

2010-01-08 Thread Chap Harrison
So here's what I ended up doing: The original problem was that, when I executed 'cpan', it immediately told me that (a) it would have to go through its configuration process, (b) the default location of '.cpan' was /Users/chap/Library/Application Support/.cpan/, and (c) would I like to

OSX Snow Leopard - cpan doesn't know where .cpan/ is

2010-01-07 Thread Chap Harrison
Hello, My CPAN directory in Mac OS X 10.6 is /Users/chap/.cpan/ (where I think it has been since time began). The 'cpan' command apparently doesn't know to look there, because it complains, creates /Users/chap/Library/Application Support/.cpan/, and then offers to start a complete CPAN

Reinstalling Perl

2009-06-22 Thread Chap Harrison
Hi, For a couple of reasons I want to re-install Perl: -- I need to see if I can do it at one go, since I put the the original installation together over a period of months. -- I'm hoping that, by also reinstalling all my CPAN modules, I may cure an increasing amount of flakiness with CPAN.

split() and trailing empties

2009-06-19 Thread Chap Harrison
I'm astonished I haven't encountered this until now (or at least, noticed it until now): by default, split() silently doesn't return trailing empty strings! I've since learned about setting the LIMIT parameter to -1. Thinking now that I should revisit every split() I've ever written. There

Inconsistent results from keys %hash

2009-06-15 Thread Chap Harrison
Hi, I was trying to find out why $input_field{$colname} wasn't returning anything when $colname = Attendance_Comment, and discovered this odd behavior: DB41 p join /, keys %input_field /Attendance_Code/SchoolID/Att_Date/Student_Number DB42 p join \n, keys %input_field Attendance_Comment

Re: Inconsistent results from keys %hash

2009-06-15 Thread Chap Harrison
Wow - okay, I guess it all makes sense now. Input was from DOS file, and I hadn't set $/ ! So the unchomped \x0d was remaining with the final field and making havoc, esp. with printing. But if you're interested: Here is snippet of code that builds the @colnames array, reads input, and

Re: Copying a named hash to an anonymous hash

2009-06-13 Thread Chap Harrison
On Jun 13, 2009, at 1:54 AM, Chas. Owens wrote: If you need to make a deep copy a data structure you should use the dclone function from the Storable[1] module: use Storable qw/dclone/; Thanks! I did find something Randal Schwartz had posted somewhere that did the trick for me - sub

Re: Request for code feedback

2009-06-13 Thread Chap Harrison
On Jun 13, 2009, at 4:07 PM, David Christensen wrote: Chas. Owens wrote: the only True Way is to use tabs for indent levels and spaces for alignment, this allows the user to set his or her indentation to whatever he or she wants by modifying how many spaces a tab displays. [72 columns

Copying a named hash to an anonymous hash

2009-06-12 Thread Chap Harrison
I've created a complex, nested data structure that is, at its outermost level, a hash: %qa. It collects QA statistics for a school. Now I want to be able to process multiple schools in one run, so I've created another hash, %sch_qa, whose key is School Name and whose value is a ref to

Re: Specifying input file on #! line

2009-06-07 Thread Chap Harrison
On Jun 4, 2009, at 8:10 PM, Raymond Wan wrote: Chap Harrison wrote: I've read perldoc perlrun but find it pretty confusing. Things I've tried unsuccessfully are: #!/usr/bin/perl /dev/clipboard #!/usr/bin/perl /dev/clipboard #!/usr/bin/perl -- /dev/clipboard The body of the script always

Specifying input file on #! line

2009-06-04 Thread Chap Harrison
I'm writing a collection of filters that read from the CygWin / Windows system copy buffer (/dev/clipboard) and write to STDOUT. I can certainly write Perl to open this file and read from it, but I wondered if there was a way to put it into the shebang line. I don't have any reason to

Re: Shortening the ?: construct

2009-04-18 Thread Chap Harrison
On Apr 18, 2009, at 5:29 AM, Peter Scott wrote: Well, if you're able to upgrade to 5.10: my $foo = $very_long_expression // n/a; THAT'S what I was remembering. Thanks. Mac OS X Leopard is at 5.8 but I assume someone's found a way to install and use 5.10 without interfering with what

Shortening the ?: construct

2009-04-17 Thread Chap Harrison
. Anyone know of a shortcut? Thanks, Chap Harrison Perl 5.8.8 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Database row sets: working with ref to array-of-refs to array

2009-04-01 Thread Chap Harrison
this in one statement, which perhaps isn't advisable, nesting join() functions, but I'm failing thoroughly. Could anyone show me the way (or dissuade me; whatever)? Thank you, Chap Harrison -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h

Re: Database row sets: working with ref to array-of-refs to array

2009-04-01 Thread Chap Harrison
On Apr 1, 2009, at 2:04 PM, Chas. Owens wrote: If I understand you correctly, you want a map[1] that feeds a join[2]: #!/usr/bin/perl use strict; use warnings; my @aref = ( [qw/a1 b1 c1/], [qw/a2 b2 c2/], [qw/a3 b3 c3/], ); print join(, , map { ($_-[0]=$_-[2]) }

Re: Accepting terminal input with pre-loaded editable value

2009-03-30 Thread Chap Harrison
On Mar 30, 2009, at 6:31 AM, Rodrick Brown wrote: Sounds like something as basic as print Question to ask: ; $value=INPUT; is what your looking for? No, I'm looking for a limited version of the editing capabilities that modern command line interfaces have; namely, the ability to preload

Re: Accepting terminal input with pre-loaded editable value

2009-03-30 Thread Chap Harrison
$prompt = $rec{city}) =~ s/(?!^)([A-Z])/ $1/g; $prompt .= , $rec{state} $rec{zip}; What is the above substitution doing? Thanks again - this is wonderful. Chap Harrison -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http

Accepting terminal input with pre-loaded editable value

2009-03-29 Thread Chap Harrison
This may be beyond the beginner level I don't know. I'd like to prompt the user to type in a City, State, and Zip in one line. It's free-form, in that it's just for display, but I can make a pretty decent suggestion based upon data I've previously gathered. If I've gathered

Re: First attempt at writing simple Module

2009-03-26 Thread Chap Harrison
On Mar 25, 2009, at 1:16 AM, Chas. Owens wrote: You need to add the variables you want exported to either @EXPORT (the mandatory list of things to export) or @EXPORT_OK (this list of things to export on demand). The biggest complication is your desire to pass in a variable. This means that we

Re: Include functionality in Perl?

2009-03-25 Thread Chap Harrison
Thanks - I have ordered, and now received, not only Intermediate Perl but Perl Best Practices. Yum. Chap On Mar 24, 2009, at 12:05 AM, David Christensen wrote: Chap Harrison wrote: Now I'm writing a suite of tools that will share a lot of the same functionality, and the right thing to do

First attempt at writing simple Module

2009-03-24 Thread Chap Harrison
to compilation errors. $ Could anyone tell me what subset of Perl modules I need to be concerned with, and what basic structure to follow, to accomplish this? 'testmod' is the main program; Dummy.pm is the module Thanks very much, Chap Harrison testmod: -- #!/usr/bin/perl use

Include functionality in Perl?

2009-03-23 Thread Chap Harrison
, please show me the way - if I need to learn about modules now, so be it! :-) Chap Harrison -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Include functionality in Perl?

2009-03-23 Thread Chap Harrison
! Best, Chap Harrison -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Late interpolation of a scalar variable inside a string

2009-03-14 Thread Chap Harrison
I want to compute a file pathname based on a template at runtime, when I know the value of a variable that the template uses. In other words, the template for the path name looks like this... /foo/bar/$project/here ...and I want to evaluate this expression once I have set the value of

Re: Late interpolation of a scalar variable inside a string

2009-03-14 Thread Chap Harrison
On Mar 14, 2009, at 5:24 PM, John W. Krahn wrote: Why not use sprintf() and '/foo/bar/%s/here' as the template: On Mar 14, 2009, at 5:19 PM, Chas. Owens wrote: * Search CPAN for template modules until you find one with the features you want, this one looks fairly close to what you want:

Re: Assigning an array to a dereferenced hash slice - syntax!

2009-03-13 Thread Chap Harrison
On Mar 13, 2009, at 7:52 AM, Jenda Krynicky wrote: That's prettymuch it, except that it's not an array of aliases, but LIST of aliases. The difference is subtle, but important. See http://perldoc.perl.org/perlfaq4.html#What-is-the-difference- between-a-list-and-an-array%3f and

Re: Assigning an array to a dereferenced hash slice - syntax!

2009-03-12 Thread Chap Harrison
On Mar 12, 2009, at 12:52 AM, Chas. Owens wrote: On Thu, Mar 12, 2009 at 01:27, Chap Harrison c...@pobox.com wrote: It's still not intuitive to me why we FIRST convert the hash to an array, and THEN ask for keys - keys being hash-ish, rather than array-ish sorts of things. (I've said

Assigning an array to a dereferenced hash slice - syntax!

2009-03-11 Thread Chap Harrison
Hello, I have a hash of hashes, and I'm trying to bulk-assign some key/value pairs to the referenced hash, using a technique I read on the perlmonks list (hash slices, see link below). I've never been good at working out syntax where complex data structures are concerned, and this eludes

Re: Assigning an array to a dereferenced hash slice - syntax!

2009-03-11 Thread Chap Harrison
On Mar 11, 2009, at 11:51 PM, Chas. Owens wrote: Dereference the hashref as an arrayref then ask for the keys: #!/usr/bin/perl use strict; use warnings; my %hash = ( adams = {} ); my @keys = qw/a ar af aw/; my @values = (1, 19, 13, 11); @{$hash{adams...@keys} = @values; use

Re: Module to parse CSV string

2006-07-20 Thread Chap Harrison
On Jul 20, 2006, at 1:30 AM, Todd W wrote: Theres also Text::CSV_XS which is configurable (and faster than Text::CSV). Specifically, note the quote_char and escape_char arguments to the constructor... So there is - thanks! I discovered that one record has a field containing \r, which

Module to parse CSV string

2006-07-19 Thread Chap Harrison
Hi, I'm looking for a module or a perl code snippet to parse optionally- quoted, comma-separated values. The most obvious candidate, Text::CSV, won't do the job for two reasons: -- it only recognizes double-quotes as the quote character. My input uses single-quotes. -- including the quote

Re: asking for y or n

2004-12-15 Thread Chap Harrison
On Dec 15, 2004, at 10:30 AM, Jay wrote: you can also use the cpan shell or perl -MCPAN to get information on installed modules, Is there a command to the cpan interface will produce a list of all installed modules? Neither the 'h' command nor 'perldoc cpan' indicate anything, that I can see.

Re: asking for y or n

2004-12-15 Thread Chap Harrison
Check out recipe 12.22 from the Perl Cookbook, called pmdesc. It should also be available for download from O'Reilly and other places. Also look into the CPANPLUS module from cpan. Thanks, Jay. pmdesc isn't pretty, but it gives the answers. :-) Chap -- To unsubscribe, e-mail: [EMAIL PROTECTED]

Re: Perl regrp 101

2004-12-03 Thread Chap Harrison
On Dec 3, 2004, at 10:10 AM, David Gilden wrote: ## This Does what _not_ do what I would expect -- return the first 3 characters of type '\w' $tmp =Joe Smore1qazxswedcvfrtgbnhytujmkilptyot5000; $tmp =~ s/(^\w{3})(.*)/$1/; print $tmp\n; FWIW, the above prints Joe on my Mac 10.3.6 / Perl

Re: Reading external file. Open files from listing and do a search and replace then continue...

2004-12-01 Thread Chap Harrison
On Nov 30, 2004, at 7:19 PM, Lawrence Statton wrote: So, in the spirit of Holiday Blessings and Peace on Earth, Goodwill Toward Man that is tradition between November and January, when we can get back to our regularly scheduled program of hatred and global domination, let's declare it Be Kind To

Re: Search Tab-delimited file for Null fields

2004-11-29 Thread Chap Harrison
This time I'm trying to read through a tab-delimited text file with the first row containing headers. I want to print out any field/column name where the entire field is null (meaning there is no value for that field for any record in the file). [snip] I'm thinking that if I read each column

Re: Printing to a file

2004-10-26 Thread Chap Harrison
Wait a minute there. I'm not learning programming. I've been a perl programmer for 7 years and have written hundreds of more complex programs than this and have written to thousands of files in my time. I just needed another pair of eyes to possibly point out what I was doing wrong. Also,

Trouble with m///g

2004-09-30 Thread Chap Harrison
Hi, I'm trying to extract all four-digit numbers from a string in one fell swoop, but I can't seem to come up with the proper regexp. This is my first time using /g in a match so maybe there's a trick I'm missing. For example, the string aa 444 - should yield

Re: Trouble with m///g

2004-09-30 Thread Chap Harrison
, but that means it will want to find an ending delim on iteration n, followed by a beginning delim on iteration n+1. On Sep 30, 2004, at 9:41 AM, Hanson, Rob wrote: I think this might work. /\b\d{4}\b/ Rob -Original Message- From: Chap Harrison [mailto:[EMAIL PROTECTED] Sent: Thursday, September

Re: Trouble with m///g

2004-09-30 Thread Chap Harrison
On Sep 30, 2004, at 9:55 AM, Wiggins d Anconia wrote: Out of curiousity based on your description shouldn't it return, ::::::: Or do you really mean, you are trying to capture all 4 digit strings that are not in a string of longer digits? You need to be very

Re: Trouble with m///g

2004-09-30 Thread Chap Harrison
On Sep 30, 2004, at 10:41 AM, Jan Eden wrote: my @a = ($foo =~ m'(?!\d{4})\d{4}(?!\d)'g); Careful, you mistyped the original proposition: my @a = ($foo =~ m'(?!\d)\d{4}(?!\d)'g); Oops, sorry - I copied that into the email from Wiggins' reply, but actually tested with Dave Gray's. Didn't notice

Re: GetOptions problems

2004-09-30 Thread Chap Harrison
On Sep 30, 2004, at 10:35 AM, cats wrote: yes i know i can not spell, im a dislexic moron If you're like other dyslexics I've known, you're probably (a) not a moron and (b) exceptionally brilliant in other areas. Thanks for the reminder. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For