Re: Module subclassing (solved)

2005-10-24 Thread Peter Rabbitson
> I am trying to subclass Math::Currency to change the default bstr() and > move it to a different function, so my numbers are not formatted by > default (I am unable to just strip existing formatting in a certain > situation). > ... > However any arithmetics fails with an "Unknown round mode ''

Re: Module subclassing

2005-10-24 Thread Peter Rabbitson
> [snipped helpful code] > : And all is well if I create a new number and print it back, > : both bstr() and fmtstr() work just as expected. However any > : arithmetics fails with an "Unknown round mode ''" error. I > : looked at Math::Currency which is a rather simple module > : and I still can't

Module subclassing

2005-10-23 Thread Peter Rabbitson
Hi list, I am trying to subclass Math::Currency to change the default bstr() and move it to a different function, so my numbers are not formatted by default (I am unable to just strip existing formatting in a certain situation). Here is what I did: package Tools::Currency; use base qw(Math::C

XML::Simple + Math::Currency / Math::BigInt problem

2005-10-17 Thread Peter Rabbitson
Hello list. After I converted some parts of my program to use Math::Currency I faced the inconvenience of my XML generators not working anymore. 20 minutes of jumping up and down with the debugger yielded that the following dumbed down example: use Math::Currency; use XML::Simple; my $number

Re: BEGIN block question

2005-10-03 Thread Peter Rabbitson
On Sun, Oct 02, 2005 at 12:34:53PM -0700, John W. Krahn wrote: > > To sum what up? What who is saying? What previous e-mail? Crap... I apologize, the email was way too long so I stripped it entirely, being sure that the list will se Jendas reply. It was very thorough so I am posting it below:

Re: BEGIN block question

2005-10-02 Thread Peter Rabbitson
Just to sum it up, so I make sure I got what you are saying. From the previous e-mail I understand that: * Right after the use xxx statement is parsed the corresponding module which is 'use'd is fully parsed AND executed. This execution includes any top level code not enclosed in subroutines an

BEGIN block question

2005-10-02 Thread Peter Rabbitson
Hello list, I have some trouble understanding why a BEGIN block behaves the way it does. Here are two files to demonstrate: == test = #!/usr/bin/perl use warnings; use strict; use test2 qw($var); our $var2 = 'second'; BEGIN { print "I see $var but don't see $var2\n"; } ===

Re: Comparing an array with hash keys

2005-09-30 Thread Peter Rabbitson
> ... or grep > > my @storage_array = grep { exists $original_hash{$_} } @original_array; > Disregard that, didn't read the question/answer well enough. Bummer... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Comparing an array with hash keys

2005-09-30 Thread Peter Rabbitson
On Fri, Sep 30, 2005 at 10:08:51AM -0400, Jeff 'japhy' Pinyan wrote: > On Sep 30, Mark Martin said: > > >I want to compare the elements of an array with the keys in a hash. If > >matches are found, I want to store the values associated with the > >matched keys in an array for future processing :

fork() question

2005-09-24 Thread Peter Rabbitson
I think I am getting the idea of fork() all wrong. Here is an example: my $pid = fork(); if ($pid) { # should apply to parent only? exit; } sleep 1; print "Test\n"; exit; 'Test' does not print. If I remove the 'sleep 1' - it prints. From what I understood fork creates two identical p

Re: Math::Currency compilation failure

2005-09-20 Thread Peter Rabbitson
> Hello list, > I am trying to install Math::Currency from cpan and I can not make > anything out of the error message I get. Any advice would be > appreciated. > > Peter > > > > CPAN.pm: Going to build J/JP/JPEACOCK/Math-Currency-0.40.tar.gz > > Checking if your kit is complete...

Math::Currency compilation failure

2005-09-20 Thread Peter Rabbitson
Hello list, I am trying to install Math::Currency from cpan and I can not make anything out of the error message I get. Any advice would be appreciated. Peter CPAN.pm: Going to build J/JP/JPEACOCK/Math-Currency-0.40.tar.gz Checking if your kit is complete... Looks good Writing Make

Re: Can't figure out Error.pm

2005-09-18 Thread Peter Rabbitson
On Sun, Sep 18, 2005 at 07:14:16AM -0700, Peter Scott wrote: > On Sun, 18 Sep 2005 01:43:42 -0500, Peter Rabbitson wrote: > > > sub get_values { > > > > #fail right away > > throw DBException ("Sorry, bank is empty"); > > } > > >

Can't figure out Error.pm

2005-09-17 Thread Peter Rabbitson
I am trying to incorporate cleaner exception handling in my code. Here is a small illustration (meaningless) of what most of my code looks like: package main; use warnings; use strict; my $average = Computer::get_average(); unless ($average) { print "$Computer::ERROR\n"; } 1; package Com

Assignment modifiers

2005-09-17 Thread Peter Rabbitson
I stumbled upon a script with the following assignment: ... = v(numeric value); I tried to see how it works and the following: my $a = v65; print $a; produces ascii 65 (capital A) Where can I read more about these assignment modifiers? Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For a

Re: Question about data storage

2005-09-15 Thread Peter Rabbitson
On Thu, Sep 15, 2005 at 04:57:28PM -0500, Walter Hunnel wrote: > Not perl, but as a DBA: > Thanks for answering! > Unless you are getting the data as XML or have to change the data to XML > for some other reason, I would not move to XML just for the cleanup you > are asking about. I was consi

Question about data storage

2005-09-15 Thread Peter Rabbitson
Hello perlers, This is somewhat of a database related question, but it is as much related to programming practices, so excuse me if this is not the apporpriate list. I am collecting and processing online orders from several different sources. Each source is queried periodically, information abou

UNIVERSAL class like functionality for non-OO?

2005-09-04 Thread Peter Rabbitson
Hello list, Is there a clean and elegant way to make a subroutine available to all namespaces/packages? Something like the UNIVERSAL class for objects, but for non-OO environment. I need to embed a logging facility into a multimodule project, so I want to have a certain function (say log_msg()

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

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: 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: 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: 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: 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

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: 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

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: 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;

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: > > >

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: 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

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]

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

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],

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: 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

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: 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,

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: 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]

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: 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

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

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: 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

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: 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-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
>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 );

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: 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

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: 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]

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; > $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

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: 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

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-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: 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
> 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

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-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?

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: 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

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: 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

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: 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 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

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: 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

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: 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

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

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

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

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: 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 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: 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: 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: 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: 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: 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

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: 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

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

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

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

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

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

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 >

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: 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: 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

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: 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

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 >

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:

  1   2   >