comp.lang.perl.misc
  Home FAQ Contact Sign in
comp.lang.perl.misc only
 
Advanced search
December 2006
motuwethfrsasuw
    123 48
45678910 49
11121314151617 50
18192021222324 51
25262728293031 52
2006
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.perl.misc Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Array as instance variable         


Author: robert.waters
Date: Dec 10, 2006 14:59

Hello,

I need to keep track of a list of items in my package/object;
currently, I am going about it like this:

sub new {
my $self = { _listofstuff => undef };
bless $self;
return $self;
}
sub dostuff {
my $self =shift;
for (my $i=0; $i<10 ;$i++) {
push @{$self->{_listofstuff}), "listitem";
}
}

Is there a better way? Using '$self->underscored-hash-item' is
tedious, but I am willing to deal with it; however, having to treat
this hash element as an array in order to use it as such (rather than
declaring it as an array to begin with) seems hackish. I would very
much love to just see '@listofstuff'.
Show full article (0.87Kb)
3 Comments
  FAQ 4.14 How can I compare two dates and find the difference?         


Author: PerlFAQ Server
Date: Dec 10, 2006 12:03

This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

4.14: How can I compare two dates and find the difference?

(contributed by brian d foy)

You could just store all your dates as a number and then subtract. Life
isn't always that simple though. If you want to work with formatted
dates, the "Date::Manip", "Date::Calc", or "DateTime" modules can help
you.

--------------------------------------------------------------------
Show full article (1.37Kb)
no comments
  Re: IPC::Open2 and sort         


Author: anno4000
Date: Dec 10, 2006 11:10

gmail.com> wrote in comp.lang.perl.misc:
> "grocery_stocker" gmail.com> wrote:
>> I'm sort of drawing a blank on the following statement found in the in
>> the documentation for IPC::Open2
>>
>> "Programs like sort that read their entire input stream first, however,
>> are quite apt to cause deadlock."
>>
>> The only think I can possibly think of is that sort is using the
>> standard I/O default buffering as opposed to the write() function. Am I
>> close
>
> I don't think so. I think the docs are just wrong.

It seems to me the doc supposes (but doesn't explicitly say so) the
user is trying to perform a line-by-line dialog with the program.
Show full article (1.07Kb)
1 Comment
  Re: email question         


Author: Brian McCauley
Date: Dec 10, 2006 10:00

On Dec 10, 12:06 pm, hmchkus wrote:
> Is there a perl module that can take out email attachment and HTML tag
> from original message? Thanks!!

To process MIME encoded messages try the MIME::* modules.

To remove HTML from a string see FAQ: "How do I remove HTML from a
string?"
no comments
  Re: IPC::Open2 and sort         


Author: Uri Guttman
Date: Dec 10, 2006 08:55

>>>>> "BM" == Barry Margolin alum.mit.edu> writes:
BM> However, you can still run into problems due to stdio buffering. Even
BM> if the application works in "one line in, one line out" mode, stdio may
BM> buffer the output lines. If the driving application tries to read this,
BM> it will block because the buffer hasn't been flushed. But the buffer
BM> won't be flushed until the application produces more output, which won't
BM> happen until the driving application sends more input, but this won't
BM> happen because the application is blocked in read().
BM> I recently wrote an application that uses IPC::Open2, and I resolved
BM> this by forking a child process to do the writing, while the main
BM> process went into a read loop.

i have two words for you: 'event loop'. i would never run long running
subprocesses and try to deal with their stdio without an event
loop. then you never have to worry about deadlock.

uri

--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
no comments
  Re: What GPL software have you been able to download and recompile successfully?         


Author: rhyde
Date: Dec 10, 2006 08:03

Jim Carlock wrote:
>
> The statement from the book listed above (page 3) kind of stuck
> in my mind:
>
> "Perl is an interpreted language, but it might work a little bit
> differently from other interpreted languages that you've used. Perl
> is actually both a compiler and an interpreter. When you invoke
> the Perl interpreter on a Perl script file, the file is first compiled
> and optimized, then efficiently executed."
>
> That statement tends to indicate that the whole file gets read into
> memory and then compiled, then optimized, then run. I used to
> think that Perl did it line by line, reading a line at a time.

I've always been under the impression that Perl, like many modern
languages, was first complied into an intermediate code and then the
intermediate code was interpreted.
Show full article (1.48Kb)
no comments
  Re: IPC::Open2 and sort         


Author: K-mart Cashier
Date: Dec 10, 2006 07:55

Barry Margolin wrote:
> In article <20061209190005.352$sD@newsreader.com>, xhoster@gmail.com
> wrote:
>
>> "grocery_stocker" gmail.com> wrote:
>>> I'm sort of drawing a blank on the following statement found in the in
>>> the documentation for IPC::Open2
>>>
>>> "Programs like sort that read their entire input stream first, however,
>>> are quite apt to cause deadlock."
>>>
>>> The only think I can possibly think of is that sort is using the
>>> standard I/O default buffering as opposed to the write() function. Am I
>>> close
>>
>> I don't think so. I think the docs are just wrong. What leads to
>> deadlocks is when the other processes generates output at unpredictable
>> intervals. "one line in, one line out" (like bc) and "read all the input
>> first, then produce all the output after" (like sort) are both predictable
>> and fairly robust against deadlocks (Provided, of course, that you don't do ...
Show full article (1.74Kb)
no comments
  Re: What GPL software have you been able to download and recompile successfully?         


Author: Tad McClellan
Date: Dec 10, 2006 01:41

Jim Carlock 127.0.0.1> wrote:
> Jim Carlock wrote:
>: PERL supposedly compiles programs and then runs them.
>: At least that's the way it's described in the PERL books I've
>: been reading. Java perhaps performs similiarly.

The name of the language is "Perl", not "PERL".
> "santosh" gmail.com> wrote:
>: Err, Perl interprets code, (though compilation is also available.)
>
> (Learning Perl on Win32 Systems, by Randal L. Schwartz,
> Erik Olson & Tom Christiansen, 1997, First Edition)

[ snip - Perl is a "compile-and-go" type of "interpreter". ]

While books are really nice (particularly when the author is my boss :-),
the Ultimate Authority is the docs that come with the software.

From the perlrun.pod Perl docs:

After locating your program, Perl compiles the entire program to an
internal form. If there are any compilation errors, execution of the
program is not attempted. (This is unlike the typical shell script,
which might run part-way through before finding a syntax error.)
Show full article (1.39Kb)
2 Comments