Re: Variable name substitution (probably a question on references)

2004-10-10 Thread Peter Rabbitson
ays it is fairly easy. So help me or shoot me :) P.S. I personally think use strict complains just way too much, to a point where you lose all the elegance that coding in perl calls for. Peter P.P.S. Sorry for the double message, did not reply to list. On Sun, Oct 10, 2004 at 09:34:13PM

Re: Variable name substitution (probably a question on references)

2004-10-10 Thread Peter Rabbitson
> It would still IMHO be much better to do something like: > > %cards = ( > 4 => {name => 'Visa'}, > 5 => {name => 'MasterCard'}, > 6 => {name => 'Discover'}, > 3 => {name => 'AmEx'}, > ); > > foreach my $cardid (keys %cards) { > foreach my $property (@props) { > $

Re: Variable name substitution (probably a question on references)

2004-10-10 Thread Peter Rabbitson
> Since you > > 1) are not very convincing in explaining why it would be necessary to > use soft references, and > > 2) argue against enabling strictures, and with that make Perl help you > get your code right, > > you'll find that few people here are inclined to help you. > > (You can always r

Copying a hash-of-hashes

2004-12-29 Thread Peter Rabbitson
Hello List, To explain the problem I am having, I wrote a simple snipet that doesn't do anything meaningful other than illustrating the behaviour I want to avoid: my %hoh = ( 1 => { a => 5, b => 5 }, 2 => 5 ); my @res = &RANDO

WWW::Mechanize java navigation

2005-02-24 Thread Peter Rabbitson
Hello list. I had very good luck using the WWW::Mechanize object for various automated data collectors until I stumbled over http://www.mymerchantview.net. As you can imagine the problems begin when I do my first ->follow_link after which the script blows with something about unsupported java. What

Re: standardising spellings

2005-02-24 Thread Peter Rabbitson
On Thu, Feb 24, 2005 at 06:01:50PM -, Dermot Paikkos wrote: > Hi, > > I have a list of about 650 names (a small sample is below) that I > need to import into a database. When you look at the list there are > some obvious duplicates that are spelt slightly differently. I can > rationalize so

Re: WWW::Mechanize java navigation

2005-02-24 Thread Peter Rabbitson
pported On Thu, Feb 24, 2005 at 02:20:29PM -0600, [EMAIL PROTECTED] wrote: > Have you installed Crypt::SSLeay for https:// ? > Could you print the header at least with your code? > > > - Original Message - > From: "Peter Rabbitson" <[EMAIL PROTECTED]> >

Re: WWW::Mechanize java navigation

2005-02-24 Thread Peter Rabbitson
On Thu, Feb 24, 2005 at 03:11:08PM -0600, [EMAIL PROTECTED] wrote: <---snip whole bunch of misunderstaning---> > You have your answer then.. I guess. > >From FAQ=WWW::Mechanize; > > How can I get WWW::Mechanize to execute this JavaScript? > You can't. JavaScript is entirely client-based, and

Multifile project question

2005-03-01 Thread Peter Rabbitson
Hi everyone. I have a question regarding splitting large projects into multiple files to add at least a little convenience when further maintenance is needed. Consider this more than trivial example to be a program of 4000 lines: print '> '; my $input = ; chomp $input; if ($input =~ /^\d+$/) {

Invocation environment detection

2005-03-05 Thread Peter Rabbitson
How would I implement a simple detection mechanism, to be able to run the same script from he commnd line and from cgi, having the script behave differently depending on the invocation? (e.g. change the content type and other formatting stuff) Thanks Peter -- To unsubscribe, e-mail: [EMAIL PROT

Re: Invocation environment detection

2005-03-05 Thread Peter Rabbitson
What if I want it to be able to run under everything: * CGI (html output) * Linux tty (text only output) * ActivePerl (text only output + some workarounds for braindead OS) (Sorry, forgot to CC) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: mail question

2005-03-08 Thread Peter Rabbitson
As stated earlier on the list I believe, I would not use an external program call. Instead use the MIME::Lite - clean and simple: my $mail = MIME::Lite->new (From => $from_email, To => $to_email, Subject => 'Test',

Re: mail question

2005-03-09 Thread Peter Rabbitson
; ); > > thanks. > > amy > > > On Tue, 8 Mar 2005 19:53:12 -0500, Peter Rabbitson <[EMAIL PROTECTED]> wrote: > > As stated earlier on the list I believe, I would not use an external program > > call. Instead use the MIME::Lite - clean and simple: >

PDF creation

2005-03-09 Thread Peter Rabbitson
I would like to hear opinions (pros/cons) about the two apparently available methods for realatively easy PDF output creation - PDF::Create and PDF::API2. I figured I might listen to people that have used them with or without luck, before figuring out which one (or neither) would give me better

Re: regular expression help

2005-03-10 Thread Peter Rabbitson
> Simplest is change the {2} to {1,2} for all your entries. Now you > mush have from 1 to 2 digits. > Wags ;) I think what he really wants is to throw a fit when there is a leading zero for which your solution won't cut it. Here is how I see it: $field =~ /^[1-9]\d?\.[1-9]\d?\.[1-9]\d?$/ --

Multiple variable initialization

2005-03-11 Thread Peter Rabbitson
Is there a quick way to initialize a number of variables at once? Something like my ($var1, $var2, $var3); but instead of having undef in all of them, let's say I want to have 1 in each. Any takers? Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL P

Re: Multiple variable initialization

2005-03-11 Thread Peter Rabbitson
On Fri, Mar 11, 2005 at 12:45:10PM -0800, Wagner, David --- Senior Programmer Analyst --- WGO wrote: > Peter Rabbitson wrote: > > Is there a quick way to initialize a number of variables at once? > > Something like > > > > my ($var1, $var2, $var3); > my (

Re: Multiple variable initialization

2005-03-11 Thread Peter Rabbitson
On Fri, Mar 11, 2005 at 04:09:12PM -0500, Todd W wrote: > > "Peter Rabbitson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On Fri, Mar 11, 2005 at 12:45:10PM -0800, Wagner, David --- Senior > Programmer Analyst --- WGO wrote: > > >

lost in multidimension

2005-03-11 Thread Peter Rabbitson
I've been writing a failry complicated data collector with structures as deep as 7 levels, and everything worked very nice for me, until I started cleaning the subroutine interfaces, so they would pass references back and forth instead of working on global vars. The following is a sample code:

Re: lost in multidimension

2005-03-11 Thread Peter Rabbitson
On Fri, Mar 11, 2005 at 04:42:14PM -0800, Wagner, David --- Senior Programmer Analyst --- WGO wrote: > Peter Rabbitson wrote: > > I've been writing a failry complicated data collector with structures > > as deep as 7 levels, and everything worked very nice for me, until I >

Re: lost in multidimension

2005-03-12 Thread Peter Rabbitson
On Sat, Mar 12, 2005 at 11:12:49AM -0500, Jeff 'japhy' Pinyan wrote: > On Mar 11, Peter Rabbitson said: > > >>>_NASTY_SUB (\%{$batches{$current_batch}}); > > > >my %cards = %{clone (\%{$sources{${$batch_ref}{by_method}}{card_de

Reference name

2005-03-14 Thread Peter Rabbitson
The answer to this question is probably beyond trivial but I can't figure it out. Say we have the following situation: my %hash = ( abcd => { a1 => 1, a2 => 2, a3 => 3 } ); another_nasty_sub (\%{$hash{abcd}}); How can I access the

Re: Reference name

2005-03-14 Thread Peter Rabbitson
On Mon, Mar 14, 2005 at 05:32:01PM -0800, Tim Johnson wrote: > > Did you try enumerating the keys of %hash? > > foreach my $outerKey(sort keys %hash){ >print "$outerKey\n"; >foreach my $innerKey(sort keys %{$hash{$outerKey}}){ > print "\t$innerKey\n"; >} > } I guess I have to e

Re: Reference name

2005-03-14 Thread Peter Rabbitson
> And once again, you've written some round-about referencing code: ... I'll get it some day. As far as dereferencing with ->, which I asked earlier but I never got an answer to. For example are $sources{${$batch_ref}{by_method}}{card_def} and $sources->($batch_ref->by_method)->card_def equi

Re: Math::BigInt

2005-03-16 Thread Peter Rabbitson
AFAIK perl will handle up to 15 (14 to be exact) precision without any helpers like Math::BigFloat. Then you just use sprintf ('%.Xf', $var) where X is the precision you want. Keep in mind that standard rounding is enforced (.4 - .5 as breakpoint) Peter > Hello, > > My goal is to divide two

Re: WWW::Mechanize java navigation (Answer)

2005-03-17 Thread Peter Rabbitson
On Thu, Feb 24, 2005 at 12:45:01PM -0500, Peter Rabbitson wrote: > Hello list. I had very good luck using the WWW::Mechanize object for various > automated data collectors until I stumbled over > http://www.mymerchantview.net. As you can imagine the problems begin when I >

ActivePerl repositories

2005-03-17 Thread Peter Rabbitson
I have a general question concerning module availability for ActiveState Perl. I asked on this list several month ago where to get the DateTime suite modules, and somebody pointed me to a certain repository at the University of Winnipeg. Now I am in need of HTTP::Cookies and instead being pinpoi

XML::Twig

2005-03-20 Thread Peter Rabbitson
Here goes my next question (I apologize for being such a nag). After extensive reading on XML processing technologies I figured for my application of XML files with hundreds of same-level branches XML::Twig is the answer. Note that I do not do *any* XML output - I am just and only processing intere

Module questions (perhaps a module creation mini-tutorial)

2005-03-25 Thread Peter Rabbitson
Hello list, I am trying to make my own modules for some tasks, and I am trying to grasp the basics before I go any further. Here is a dumb test module that I wrote just to see how things are done - it takes an array of 3 values and adds them together, returning the values on request. ### 3-e

simple server app

2005-03-29 Thread Peter Rabbitson
Hi everyone, Here is my situation. I have a windows system which continuosly runs a perl script, which utilizing Win32::Process and Win32::Setupsup is controlling a windows only app and when triggered makes it spit export files to a samba network share. From there on my main process which runs off

Win32::Setupsup menu item enumeration

2005-03-30 Thread Peter Rabbitson
Hi everyone, I got stuck with the inability of Setupsup::EnumChildWindows or Setupsup::GetWindowProperties to generate a list of available choices in a regular menu (the one you get when you do 'open file' for example). I do not know a thing about MFC, and perl/windows integration is not as well do

Re: Uniq from array ?

2005-03-30 Thread Peter Rabbitson
> > Not that I see why this came up in the first place... > How funny... By very same talking you can bring a gun to a social meeting and 10 minutes later yell "Huh?! WTF did this come from?!". Anyway my 2c - I myself use the unix.org.ua archives quite a bit, which does not prevent me from

modules - lost again

2005-04-01 Thread Peter Rabbitson
This is to extend my question earlier about modules. Most of the OOP concepts are very nicely explained in perlboot kindly pointed out by Japhy (thank you!), however I stumbled against a problem. I don't know if I am not looking at it correctly, or the idea I want to implement is entirely ill.

Re: modules - lost again

2005-04-02 Thread Peter Rabbitson
> Examine your concept of "reside in". You appear to be confused with > modules that use the Exporter. You don't. I believe you'll find that > you use SomeOther::Module *before* using Configuration in the main program, > which means that the assignments haven't taken place yet. > A-ha! Some da

Re: modules - lost again

2005-04-02 Thread Peter Rabbitson
> > And if I am, and specifying explicit imports for each module is beneficial > > - > > Not for reason of speed. For reason of maintainability. You should only > import names you are going to use, and then do so explicitly, so that a > maintenance programmer doesn't look at the program wonder

Re: datetime comparisons

2005-04-05 Thread Peter Rabbitson
On Tue, Apr 05, 2005 at 04:12:31PM +0300, John wrote: > hello all > > i am wondering a there is a module that do comparisons > between two different datetime stamps > > for example > > 2/4/2005:15:20:20 and 4/4/2005:12:09:23 > > which date is bigger (namely earliest) > I was down this road so

Re: How can I take subarray without second array (drop other elements)?

2005-04-07 Thread Peter Rabbitson
> don't want to use second array (they are can be very big). After print I > don't need @array anymore. > Erm... if you really don't need the array anymore, why don't you just deflate it by splicing on itself? @array = splice (@array, N, 100); Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED

Re: How can I take subarray without second array (drop other elements)?

2005-04-07 Thread Peter Rabbitson
> But this operation means copying an array? Even at return the result > from function. > And if the array and/or length are very big, it will take a long time > and CPU usage. > Or I am wrong? > The gurus will correct me, but as far as I understand we do a splice on the initial array, take 10

RE unfriendly error

2005-04-10 Thread Peter Rabbitson
I am getting this: [EMAIL PROTECTED]:~$ perl -e "'123456-123456' =~ /^ (\d{2}){3} (?: - (\d{2}){3} )? $/x ? print 'yep' : print 'nope';" Panic opt close in regex m/^ (\d{2}){3} (?: - (\d{2}){3} )? $/ at -e line 1. Google does not turn much if anything about this error... Why is this happening? I

Re: multidimensional arrays

2005-04-10 Thread Peter Rabbitson
> >$array[0] = split(' ','apples trucks'); this is equivalent to: my @tokens = split(' ','apples trucks'); $array[0] = scalar @tokens; Thus you get 2 which is the size of the array returned by split, which you are not retaining by any means. What you want to do is this: @{$array[0]} = split('

Re: RE unfriendly error

2005-04-11 Thread Peter Rabbitson
> brackets; it does not _capture_ 3 times. Only literally present/countable > brackets capture. Geee... I guess you are right :) Furthermore the following works without complaining about ?: perl -e "print 'ouch' unless ('123456-123256' =~ /^(\d{2})(\d{2})(\d{2})(?:-(\d{2})(\d{2})(\d{2}))?$/ );

Re: Match a pattern

2005-04-19 Thread Peter Rabbitson
On Tue, Apr 19, 2005 at 03:32:22PM +0300, Offer Kaye wrote: > On 4/19/05, lio lop wrote: > > I need to print the text between two words > > that are in different > > lines. > > > If you have: This is a nasty, multilined chunk of text and you want to get everything

PDF::API2

2005-04-20 Thread Peter Rabbitson
Hi everyone, Today I am stuck with PDF::API2. Although seeming very powerful, the module documentation is horridly lacking. I was able to figure a great deal of what I need by directly examining the source, however some issues are left unsolved: 1. Is there a way to get the (x,y) pos and maybe mor

Feed Net::FTP an in-memory file

2005-04-21 Thread Peter Rabbitson
Hello everyone, Very simple: I need to generate a file and upload it to ftp. Currently I am wrapping the file together, writing it out to a temp file on disk, calling $ftp->put($tmp_file) on it, and unlinking it. Is there a way to skip the write to disk? The put() method seems to expect a path

Re: Feed Net::FTP an in-memory file

2005-04-21 Thread Peter Rabbitson
On Thu, Apr 21, 2005 at 10:56:16AM -0500, JupiterHost.Net wrote: > > > Peter Rabbitson wrote: > > >Hello everyone, > > Hello, > > >Very simple: I need to generate a file and upload it to ftp. Currently I > >am wrapping the file together, writing it

Question about || (was REGEXP removing - il- - -b-f and - il- - - - f)

2005-04-27 Thread Peter Rabbitson
> also > "or die" is more preferable than "|| die" Why is that? :) I was actually going to post a question about ambiguity syntax later, but here it is anyway. Are the following 4 equivalent? 1) if ($b) { $a = $b; } else { $a = $c; } 2) $a = $b or $c; 3) $a = $b || $c; 4) $a = $b ? $b : $

Re: Question about || (was REGEXP removing - il- - -b-f and - il- - - - f)

2005-04-27 Thread Peter Rabbitson
On Wed, Apr 27, 2005 at 09:06:39AM -0500, Peter Rabbitson wrote: > Also there was an example on the web that completely threw me off. Although > this works: > > local ($/); > Sorry about this last one, I undrestand the idea of local for globs, I just thought that local

bulky regex

2005-04-27 Thread Peter Rabbitson
Hello everyone, This is the first time I was able to get a complex regex actually working as I expect, but I wanted someone to comment on it, in case I am overlooking something very major. I am trying to throw away a certain string out of random text. The occurences might be as follows: Free U

Re: bulky regex

2005-04-27 Thread Peter Rabbitson
On Wed, Apr 27, 2005 at 12:16:05PM -0500, Peter Rabbitson wrote: > description =~ s/ #take away free ground shipping text > > (?: #non-capturing block for | inclusion >(^)#start of string > | #or >(?<=\S)#lookbehin

Re: bulky regex

2005-04-27 Thread Peter Rabbitson
On Wed, Apr 27, 2005 at 01:31:08PM -0400, Jay Savage wrote: > > Don't make things so complicated. You want to find some words and > replace them with nothing. You don't care where in the string the > pattern appears. Therefore, you don't have to predict where in the The word 'ups' is not manda

Re: bulky regex

2005-04-27 Thread Peter Rabbitson
On Wed, Apr 27, 2005 at 01:50:57PM -0400, Jay Savage wrote: > You can drop the stuff from the end, too. If 'ups' is optional and > the spacing is variable, then of course handle that with * > > $description =~ > s/\s*free\+(?:ups)*\s*ground\s+shipping\s*[!]*\s*//i; # or /ig if > needed > >

Re: REGEXP removing - il- - -b-f and - il- - - - f

2005-04-29 Thread Peter Rabbitson
> I think really good programmers write "nice" readable programs > (scripts), so begginers should understand that sooner. I think, that's > why better using "or" instead "||". Come-on guys! Read your mails. John Krahn spent the time to write a wonderful explanation why || simply DOES NOT WORK when

propagated error reporting

2005-05-02 Thread Peter Rabbitson
Hello everyone, I once again have a broad question about implementing a certain capability. Consider we have the following: main program -> uses modules A & B | | execute exported sub from A (A uses C & D) | | | execute exported sub from C

Re: How to follow a Java script link

2005-05-05 Thread Peter Rabbitson
On Thu, May 05, 2005 at 11:40:52AM -0500, Sergio Ulises Sanchez Buelna wrote: > Hello all > > I am trying to harvest a set of information from a search service that gives > the results of the search by pages. > I am interested in ALL of the results. > I can activate the search and obtain the fir

Re: The last element

2005-05-07 Thread Peter Rabbitson
On Sat, May 07, 2005 at 04:13:12PM -0700, amr wrote: > How can I call the last element in the array? > > I try the pop and it does the job but I think there is another way? > If my @a = (1, 2, 3, 4); then: my $last = pop @a; is the same as my $last = $a[-1]; and

Re: Errors on processing 2GB XML file by using XML:Simple

2005-05-13 Thread Peter Rabbitson
> I keep receiving virtual memory error and program runtime error while using > XML:simple to process a 2GB XML file on Windows 2000. I have changed > virtual memory to 4 GB but still no use, so I wonder if anyone could offer > some help? Or is there any better module to process a 2GB XML file?

Create Excel spreadsheets

2005-05-13 Thread Peter Rabbitson
I am about to start on a project that will be creating various excel files. Cpan yields quite a number of posibilities, among which Spreadsheet::WriteExcel looks most promising. I just wanted to hear some opinions on the best tool for the job before I delve into a certain inetrface. The resulti

Re: Errors on processing 2GB XML file by using XML:Simple

2005-05-16 Thread Peter Rabbitson
> I have tried to use XML:Twig to parse a 2GB XML file instead of using > XML:Simple, but I still got an error "The memory couldn't be written". My > Perl is the latest and my RAM is 1GB. Are you issuing a $twig->purge at the end of each handler? Without it memory is not implicitly released (no

Re: Errors on processing 2GB XML file by using XML:Simple

2005-05-16 Thread Peter Rabbitson
> Basically, the XML file has two key parallelled nodes: and > . If there is a child existing in , > node will be existing for showing more detailed information > about the content of this such as and . > > However, not every node has one or more child, so I need > to write a loop to fi

Re: Errors on processing 2GB XML file by using XML:Simple

2005-05-16 Thread Peter Rabbitson
On Mon, May 16, 2005 at 01:33:15PM +, Nan Jiang wrote: > While I think and are not randomly intermixed as > nodes are generated in relevant categories such as -> > -> and then if the has > children which means it is a final category, then nodes > appeared immediatly below the with

Re: Time::localtime help

2005-05-16 Thread Peter Rabbitson
> printf("The current date is %04d-%02d-%02d\n", $now->year+1900, > ($now->mon)+1, $ > now->mday); > > It outputs the date in such a format: "The current date is 2005-05-16". > I would like the name of the month(ex. 'May') displayed instead of 05. > What is the easiest way to do this? > The mos

Re: Errors on processing 2GB XML file by using XML:Simple

2005-05-17 Thread Peter Rabbitson
> Your codes look great and it works perfectly with only some minor problems > which might due to the XML file itself (I think). However, compared your > codes with mine, there are something I'd like to ask you if you don't mind. Not that much :) > 1) what's the main difference on memory load b

Determine structure size

2005-05-17 Thread Peter Rabbitson
Is there a way to determine how much a certain data structure costs in terms of memory? In other words is there some built in command or module that takes a reference to a nested data structure and gives a ball park idea of how much memory this structure takes. Thanks Peter -- To unsubscribe

Re: Removing multiple spaces

2005-05-17 Thread Peter Rabbitson
> $str =~ s/ / /i; > $str =~ s/ / /i; > $str =~ s// /i; > $str =~ s/ / /i; > $str =~ s/ / /i; > $str =~ s/ / /i; > $str =~ s// /i; > $str =~ s/ / /i; > $str =~ s/ / /i; is the same as: $str =~ s/\s{2,10}/ /; Read perldoc perlre, especially the part

HTTP Upload of a filehandle

2005-05-17 Thread Peter Rabbitson
Could somebody point me to a resource of how to upload a file using LWP via a data string or a filehandle such a string (I don't want to create a temp file on disk just to delete it after the upload). Thank you Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail

Re: Removing multiple spaces

2005-05-17 Thread Peter Rabbitson
> >>$str =~ s/ / /i; > > > >is the same as: > > > >$str =~ s/\s{2,10}/ /; > > Not quite. The \s character class includes more than just the ' ' > character. > My bad :D -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Errors on processing 2GB XML file by using XML:Simple

2005-05-18 Thread Peter Rabbitson
> I know the answer of second question after reading a quick reference of > twig... You know the answer to your first question as well - you've been looking at it the whole day :) > >I have examined the XML file and all with children are > >followed by their own s. If there is a without > >

Re: Errors on processing 2GB XML file by using XML:Simple

2005-05-19 Thread Peter Rabbitson
> I have to say that I'm very lucky because the document keeps a very well > defined order of and ... Not really, think how much programming effort would it take to generate a file where and corresponding would be intermixed :) > The last question about my approach is, I found a good place

foreach loop current index

2005-05-20 Thread Peter Rabbitson
Hello, When perl executes a foreach loop, it creates some kind of array of all the iterators and then goes over them one by one. Is the current index pointer accessible from inside the loop? I was unable to find anything related in perlvar. Thanks for the input Peter P.S. I know it is trivi

Re: foreach loop current index

2005-05-20 Thread Peter Rabbitson
>foreach $item ( @list ) { > sub( $item ); >} > Are you sure this is not a typo? I've never seen a sub statement taking a list argument... Besides this is what I get if I run it anyway: [EMAIL PROTECTED]:~$ cat 123 @list = qw(a bc c); foreach $item ( @list ) { sub( $item );

Re: foreach loop current index

2005-05-20 Thread Peter Rabbitson
> When perl executes a foreach loop, it creates some kind of array of all the > iterators and then goes over them one by one. Is the current index pointer > accessible from inside the loop? I was unable to find anything related in > perlvar. I think I should clarify myself a little. Here is an

Re: foreach loop current index

2005-05-20 Thread Peter Rabbitson
On Sat, May 21, 2005 at 12:11:42AM -0400, Chris Devers wrote: > On Fri, 20 May 2005, Peter Rabbitson wrote: > > > my @lsit = qw(a b c d); > > my %indexes; > > > > my $current_index = 0; > > > > foreach my $element (@list) { > > $indexes{$elem

Re: foreach loop current index

2005-05-21 Thread Peter Rabbitson
> The reason this has not been built into the language is that there would > be an overhead associated with each loop to maintain this variable. The > Perl5 team felt that this was not acceptable given that most loops do > not need this information and, and you have noted, it's trivial to do > the

Re: efficiency of hash of hashes/lists

2005-05-23 Thread Peter Rabbitson
On Mon, May 23, 2005 at 01:40:08PM -0400, Zhenhai Duan wrote: > I tried hash (where the members of a group are joined with ":"), and hash > of hash. It happended that hash of hash is slower than single hash. > > Hash: > $groups{$g1} = "$member1:$member2"; > > > Hash of hash > $groups{$g1}{$memb

absolute path of current process

2005-05-26 Thread Peter Rabbitson
Is this: my $path = [File::Spec->splitpath (File::Spec->rel2abs ($0))]->[1]; the only OS independent (unix/win32) way to determine the absolute path of the directory which contains the current process, or there is a less cryptic way that I am overlooking? P.S. I know the above will not work if

Re: absolute path of current process

2005-05-26 Thread Peter Rabbitson
On Thu, May 26, 2005 at 05:38:50AM -0500, Peter Rabbitson wrote: > Is this: > > my $path = [File::Spec->splitpath (File::Spec->rel2abs ($0))]->[1]; > > the only OS independent (unix/win32) way to determine the absolute path of > the directory which contains the cur

Re: absolute path of current process

2005-05-28 Thread Peter Rabbitson
On Thu, May 26, 2005 at 02:26:29PM +0300, Offer Kaye wrote: > On 5/26/05, Peter Rabbitson <[EMAIL PROTECTED]> wrote: > > Is this: > > > > my $path = [File::Spec->splitpath (File::Spec->rel2abs ($0))]->[1]; > > > > the only OS independent (unix/win3

Database independent code

2005-05-28 Thread Peter Rabbitson
Hello, I need to implement some database access in my code, and my knowledge of databases is pretty basic (mostly MySQL ans flat un-indexed tables). Can somebody point me to advanced tutorials on database independent code? For example I can't find a way to tell what methods from DBI and family can

Re: Hash of Arrays, p. 276

2005-05-28 Thread Peter Rabbitson
> Please look at the definition and initialization of the hash. It is a hash > of array references, isn't it? Why does > $HoA{"flintstone"}[0] work, why is not it: $HoA{"flintstone"}->[0] > perldoc perlref Section: Using References Paragraph 3 $array[$x]->{"foo"}->[0]

XML::Twig exception handling

2005-06-03 Thread Peter Rabbitson
Hello, I am interfacing an XML file with a database, much like the last example at http://www.xmltwig.com/xmltwig/tutorial/yapc_twig_s5.html What I am actually doing is checking if the table already got such a record, if so - updating it, otherwise inserting it, but this is not relevant. Either

Re: XML::Twig exception handling

2005-06-03 Thread Peter Rabbitson
> Either way I can't figure out how to raise an exception in the insert_row > subroutine so that the parsefile() will die as well. Since I am working with > records totalling several gigabytes, I am checking every SQL operation by > evaling them with RaiseError turned on. This doesn't help me much,

DBI + XML::Twig conflict (?)

2005-06-05 Thread Peter Rabbitson
I have a strange problem where a database handle is being destroyed for no apparent reason. My initial idea was to parse some xml, and translate it into a database. Deleting line after line of code I came up with this short meaningles program which exhibits the same behavior as its real-life si

Re: DBI + XML::Twig conflict (?)

2005-06-05 Thread Peter Rabbitson
> > If I run the real program I end up stuffing about 480 out of roughly 510 > > products into a designated table and then the handle goes out to lunch with > > the same error message. > > What's the error message? > Ups... I guess I missed that: ~$ ./test > /dev/null Issuing rollback() for dat

Re: DBI + XML::Twig conflict (?)

2005-06-05 Thread Peter Rabbitson
> Thank you. No guarantees, but try setting 'InactiveDestroy' when you > create the DB handle. XML::Twig uses a fork/exec call in 'parseurl' to > retrieve the URL in one process and to parse the XML in the other. When > the retrieval is complete one of the processes closes with an 'exit'. I > think

Re: sorting array full of hash references

2005-06-07 Thread Peter Rabbitson
On Tue, Jun 07, 2005 at 10:40:43PM -0400, Jeremy Kister wrote: > I'm stumped on how to sort an array based on a hash refrences's key in > each element of my array. > > this is dumbed down code of what I have: > my @array; > while(my $row = $sth->fetchrow_arrayref){ > my %hash = (id => $row->[0],

DBI + forking (was: DBI + XML::Twig conflict)

2005-06-11 Thread Peter Rabbitson
Just to sum up the discussion as it was extremely helpful and educational: > > Hm... I get it and I don't get it... Who keeps the sub _dummy - the parent > > or the child? I need to use DBI in it so I guess InactiveDestroy must be set > > to true there. How do I find out who is who not at the time

Change the format of $@

2005-06-11 Thread Peter Rabbitson
Hello, Consider: perl -e 'eval { die "Error message:\nVerbose error message:" }; print $@;' Error message: Verbose error message: at -e line 1. ^ Is there an easy way to get rid of the marked part? Thanks Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED]

Re: What does this error message mean?

2005-06-12 Thread Peter Rabbitson
>print "g++ $ARGV[i] \n"; > Argument "i" isn't numeric in array element at > ./cedit01 line 61. It is exactly what it says - the string 'i' is not numeric and you are using it as an @ARGV index. Perhaps you meant $ARGV[$i]. Furthermore the whole c-loop construct is not very appropriate as p

usage of do {}

2005-06-30 Thread Peter Rabbitson
Hello everyone, Here and there on the web I encounter claims that the do {} operator is depreciated. However I find it convenient to do things like: eval { some stuff } or do { some multiline error handling }; is this a bad practice? Thanks Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED

Re: usage of do {}

2005-06-30 Thread Peter Rabbitson
On Thu, Jun 30, 2005 at 09:05:00AM -0600, Wiggins d'Anconia wrote: > Peter Rabbitson wrote: > > Hello everyone, > > Here and there on the web I encounter claims that the do {} operator is > > depreciated. However I find it convenient to do things like: > > >

Re: usage of do {}

2005-06-30 Thread Peter Rabbitson
> Just as a side note... this is really a stylistic or idiomatic argument. Precisely right. That once again is a bad example I guess :) It is just dictated by the way all the rest of the error handling is done. For example: sub check_table { my ($dbh, $table) = @_; $table = lc $table;

Yet another question on perl modules

2005-07-06 Thread Peter Rabbitson
Hello everyone, Most modules I run across have a BEGIN block containing some variable declarations, module loaders etc. Although I understand what BEGIN is (code being evaluated immediately after it is parsed), I miss the point of the excercise. For example: package csv_generator; use Text::C

Re: Yet another question on perl modules

2005-07-06 Thread Peter Rabbitson
On Thu, Jul 07, 2005 at 02:22:34AM -0400, Casey West wrote: > This is a confusing question, but I think the answer is that a BEGIN > block would come into play before any of these things are executed. > > -- > Casey West > > Sorry :) Question is: why would I want to use a BEGIN block in the

DBI insert vs update question

2005-07-10 Thread Peter Rabbitson
Hello everyone, I want someone to share his expertise on the following: Suppose we have a table with some data that periodically must be synced with an external source, which provides only partial information (e.g. it might provide all the fields for a new record, but might provide only a single

Re: DBI insert vs update question

2005-07-10 Thread Peter Rabbitson
On Sun, Jul 10, 2005 at 06:23:19PM +0300, Octavian Rasnita wrote: > Can't you use the replace sql query? > > Use it like you use "insert". It will insert new rows where there are no > rows, and do an update where there are rows... > Negative. REPLACE is just a shortcut for DELETE FROM... INESERT

Re: DBI insert vs update question

2005-07-10 Thread Peter Rabbitson
> I'm sure others will give you more informed answers.. But why can't > you create multiple statement handlers under the same connection? > Because you can't. One connection holds only one prepared statement (at least in MySQL). If you prepare $statement2 on the same $dbh, $statement1 automati

Re: searching an array reference

2005-07-16 Thread Peter Rabbitson
> I'd like to search that array and push to it if a value isn't there. > At the moment I'm dereferencing the array, searching/pushing it and > the passing it back to the class as an array ref again. So this mean > copying the array. Code: > > my @used_images = @{$_[0]->{_used_images}}; > foreach (

Re: array of hashes of arrays...

2005-08-15 Thread Peter Rabbitson
On Mon, Aug 15, 2005 at 04:08:22PM -0500, The Ghost wrote: > How can I do this correctly? > > > foreach my $col (@columns) { > my %{$col} = ( # <-- I have a problem here, I want > the hash to be named whatever "$col" is > string => "$col", >

Re: Forcing array context

2005-08-20 Thread Peter Rabbitson
On Sat, Aug 20, 2005 at 08:44:34PM +0530, Binish A R wrote: > How can I force array context ... > like > > # echo hello: world | perl -lne '$aref = split(/:/, $_); print $aref' > > but thatz giving the length of the array ... I want $aref to be a reference > ... > How is that possible ?? Very

Re: Forcing array context

2005-08-20 Thread Peter Rabbitson
> perldoc -q "What is the difference between a list and an array" As a side note to the POD above - although lists can not change sizes they are addressable just like arrays. In other words the following two statements are equivalent: my @slice = @{ [ (split /\|/, 'a|b|c|d|e') ] }[1,3]; my @s

  1   2   >