[29479] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 723 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 6 14:19:31 2007

Date: Mon, 6 Aug 2007 11:19:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 6 Aug 2007     Volume: 11 Number: 723

Today's topics:
        Object References as a member of a bigger Object <olson_ord@yahoo.it>
    Re: Object References as a member of a bigger Object <admiralcap@gmail.com>
    Re: Object References as a member of a bigger Object anno4000@radom.zrz.tu-berlin.de
    Re: Object References as a member of a bigger Object <olson_ord@yahoo.it>
    Re: Object References as a member of a bigger Object <olson_ord@yahoo.it>
        Parent Process id. <rajendra.prasad@in.bosch.com>
    Re: Parent Process id. <spamtrap@dot-app.org>
    Re: Parent Process id. <mritty@gmail.com>
    Re: Parent Process id. <rajendra.prasad@in.bosch.com>
    Re: Parent Process id. <mritty@gmail.com>
        pgp trash troll delete Guy Macon guymacon Guy Macon guy (rlm@interlog.com.ca)
    Re: pgp trash troll delete Guy Macon guymacon Guy Macon <rlm@interlog.com.ca>
        Recompiling perl from scratch <dn.perl@gmail.com>
        Replacing a line <vedpsingh@gmail.com>
    Re: Replacing a line <glex_no-spam@qwest-spam-no.invalid>
    Re: Replacing a line <vedpsingh@gmail.com>
    Re: Replacing a line <glex_no-spam@qwest-spam-no.invalid>
    Re: Stripping some HTML code, while leaving others <bill@ts1000.us>
    Re: Using DBI, better option than importing into @array <jwcarlton@gmail.com>
    Re: Windows based perl editor? <veatchla@yahoo.com>
    Re: Windows based perl editor? <mjcarman@mchsi.com>
    Re: Windows based perl editor? <mjcarman@mchsi.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 05 Aug 2007 16:02:04 -0700
From:  "O. Olson" <olson_ord@yahoo.it>
Subject: Object References as a member of a bigger Object
Message-Id: <1186354924.173239.121030@22g2000hsm.googlegroups.com>


Hi,

	I am practicing a bit of Perl and I have hit on to a problem. I am
more into C++/Java - so I am not confident about my Perl lingo.

	I have two classes MyTime and ScheduleTask - each in packages.
ScheduleTask has two fields that should reference MyTime objects.

My problem is that in the as_text() SubRoutine of ScheduleTask I
cannot seem to be able to get the as_textTime() SubRoutine of the
MyTime objects. It tells me "Can't call method "as_textTime" without a
package or object reference ... "

Following are pieces of my Code:  (I hope I got everything here)

---------------------------------------------------------
main.pl
---------------------------------------------------------
use warnings;
use strict;
use MyTime;
use ScheduleTask;
use String::Scanf;

my $str = "04:00:00 to 04:59:00 Do_Something";
my $schedule_task = new ScheduleTask();
$schedule_task->parseTask($str);
print $schedule_task->as_text . "\n"; # Here's the problem !!!

---------------------------------------------------------
ScheduleTask.pm
---------------------------------------------------------
package ScheduleTask;

use warnings;
use strict;
use String::Scanf;
use MyTime;

sub new {
		my $inv = shift;
		my $class = ref( $inv ) || $inv;
		die "The SubRoutine new() cannot be called with any arguments\n"
unless @_ ==0;
		my $self;

		# For a new object the fields would be undefined
		$self = {
			  START_TIME   => undef,
			  STOP_TIME    => undef,
			  NAME         => undef
		};

    return bless $self, $class;
}


# Takes a string of the form "%02d:%02d:%02d to %02d:%02d:%02d %s" and
extracts the Task
sub parseTask {
	my $task = $_[0]; # Get the Task Object passed
	my $line = $_[1]; # Get the string
	print "Line = $line \n";

	my ($start_time_str, $stop_time_str, $name_str) =
String::Scanf::sscanf("%s to %s %s", $line);

	my $start_time = new MyTime()->parseTime($start_time_str);
	my $stop_time  = new MyTime()->parseTime($stop_time_str);

	# Finally collect all the above data together
	($task->{START_TIME}, $task->{STOP_TIME}, $task->{NAME}) =
($start_time, $stop_time, $name_str);

	 #print as_text() . "\n"; # This does not seem to work
}


sub as_text {
    my $self = shift; # Get the object
    my $start_time = $self->{START_TIME};
    my $stop_time = $self->{STOP_TIME};
    return $start_time->as_textTime . " to " . $stop_time-
>as_textTime . " " . $self->{NAME};

}
1;

---------------------------------------------------------
MyTime.pm
---------------------------------------------------------
package MyTime;

use warnings;
use strict;
use String::Scanf;

sub new {
		my $inv = shift;
		my $class = ref( $inv ) || $inv;
		die "Too many arguments\n" unless @_ <=3;
		my $self;

		if ( @_ == 0 ) {

		my @time = localtime( );
		$self = { HOUR   => $time[ 2 ],
			  MINUTE => $time[ 1 ],
			  SECOND => $time[ 0 ] };
		} else {
		$self = { HOUR   => $_[ 0 ],
			  MINUTE => $_[ 1 ] || 0,
			  SECOND => $_[ 2 ] || 0 };
		}

    return bless $self, $class;
}

# Takes a string of the form "%02d:%02d:%02d" and extracts the Time
sub parseTime {
	my $time = $_[0]; # Get the Time object passed
	my $line = $_[1]; # Get the string
	print "Line = $line \n";

	($time->{HOUR}, $time->{MINUTE}, $time->{SECOND}) =
String::Scanf::sscanf("%02d:%02d:%02d", $line);

	print "Parsed Time:" . $time->as_text . "\n";
}

sub as_textTime {
    my $self = shift;
    return sprintf "%02d:%02d:%02d",
                   $self->{ HOUR }, $self->{ MINUTE }, $self-
>{ SECOND };

}
1;
---------------------------------------------------------

I am sorry for this long post - but I needed to post sufficient code
to reproduce my problem.
Thanks a lot,
O.O.



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

Date: Sun, 05 Aug 2007 18:28:08 -0700
From: Matt Madrid <admiralcap@gmail.com>
Subject: Re: Object References as a member of a bigger Object
Message-Id: <5f2dnR7TXLm05CvbnZ2dnUVZ_vyinZ2d@comcast.com>

O. Olson wrote:

I think I see what's happening....

[snip]
> 
> 
> # Takes a string of the form "%02d:%02d:%02d to %02d:%02d:%02d %s" and
> extracts the Task
> sub parseTask {
> 	my $task = $_[0]; # Get the Task Object passed
> 	my $line = $_[1]; # Get the string
> 	print "Line = $line \n";
> 
> 	my ($start_time_str, $stop_time_str, $name_str) =
> String::Scanf::sscanf("%s to %s %s", $line);
> 
> 	my $start_time = new MyTime()->parseTime($start_time_str);
> 	my $stop_time  = new MyTime()->parseTime($stop_time_str);

$start_time will be whatever the return value from MyTime::parseTime() is,
not an object. Looking at the code in MyTime::parseTime(), that return value
will be the return value from the final print statement.

> 
> 	# Finally collect all the above data together
> 	($task->{START_TIME}, $task->{STOP_TIME}, $task->{NAME}) =
> ($start_time, $stop_time, $name_str);

Now, $task->{START_TIME} is equal to 1.

> 
> 	 #print as_text() . "\n"; # This does not seem to work
> }
> 
> 
> sub as_text {
>     my $self = shift; # Get the object
>     my $start_time = $self->{START_TIME};
>     my $stop_time = $self->{STOP_TIME};
>     return $start_time->as_textTime . " to " . $stop_time-
>> as_textTime . " " . $self->{NAME};

Now you try to use $start_time as an object.

> 
> }
> 1;
> 
> ---------------------------------------------------------
> MyTime.pm
> ---------------------------------------------------------
> package MyTime;
> 
[snip]
> 
> # Takes a string of the form "%02d:%02d:%02d" and extracts the Time
> sub parseTime {
> 	my $time = $_[0]; # Get the Time object passed
> 	my $line = $_[1]; # Get the string
> 	print "Line = $line \n";
> 
> 	($time->{HOUR}, $time->{MINUTE}, $time->{SECOND}) =
> String::Scanf::sscanf("%02d:%02d:%02d", $line);
> 
> 	print "Parsed Time:" . $time->as_text . "\n";
> }


HTH..

Matt M.


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

Date: 6 Aug 2007 09:05:30 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Object References as a member of a bigger Object
Message-Id: <5ho6iqF3lfsfvU1@mid.dfncis.de>

O. Olson <olson_ord@yahoo.it> wrote in comp.lang.perl.misc:
> 
> Hi,
> 
> 	I am practicing a bit of Perl and I have hit on to a problem. I am
> more into C++/Java - so I am not confident about my Perl lingo.
> 
> 	I have two classes MyTime and ScheduleTask - each in packages.
> ScheduleTask has two fields that should reference MyTime objects.
> 
> My problem is that in the as_text() SubRoutine of ScheduleTask I
> cannot seem to be able to get the as_textTime() SubRoutine of the
> MyTime objects. It tells me "Can't call method "as_textTime" without a
> package or object reference ... "
> 
> Following are pieces of my Code:  (I hope I got everything here)

Matt Madrid has pointed out one error: The parseTask method doesn't
return an object ($task) but the return value of a print statement (1).

I have annotated some more.  I don't see how your code could even
have reached the statement that you claim showed the error.

> ---------------------------------------------------------
> main.pl
> ---------------------------------------------------------
> use warnings;
> use strict;
> use MyTime;
> use ScheduleTask;
> use String::Scanf;
> 
> my $str = "04:00:00 to 04:59:00 Do_Something";
> my $schedule_task = new ScheduleTask();
> $schedule_task->parseTask($str);
> print $schedule_task->as_text . "\n"; # Here's the problem !!!
> 
> ---------------------------------------------------------
> ScheduleTask.pm
> ---------------------------------------------------------
> package ScheduleTask;
> 
> use warnings;
> use strict;
> use String::Scanf;
> use MyTime;
> 
> sub new {
> 		my $inv = shift;
> 		my $class = ref( $inv ) || $inv;
> 		die "The SubRoutine new() cannot be called with any arguments\n"
> unless @_ ==0;
> 		my $self;
> 
> 		# For a new object the fields would be undefined
> 		$self = {
> 			  START_TIME   => undef,
> 			  STOP_TIME    => undef,
> 			  NAME         => undef
> 		};
> 
>     return bless $self, $class;
> }
> 
> 
> # Takes a string of the form "%02d:%02d:%02d to %02d:%02d:%02d %s" and
> extracts the Task
> sub parseTask {
> 	my $task = $_[0]; # Get the Task Object passed
> 	my $line = $_[1]; # Get the string
> 	print "Line = $line \n";
> 
> 	my ($start_time_str, $stop_time_str, $name_str) =
> String::Scanf::sscanf("%s to %s %s", $line);

I don't have the module String::Scanf.  The split function can replace
it here:

    my ($start_time_str, undef, $stop_time_str, $name_str) =
        split ' ', $name_str;

> 	my $start_time = new MyTime()->parseTime($start_time_str);
> 	my $stop_time  = new MyTime()->parseTime($stop_time_str);

That won't do.  It tries to call ScheduleTask::MyTime which doesn't
exist.

        My $start_time = MyTime->new->parseTime($start_time_str);

should come closer.

> 	# Finally collect all the above data together
> 	($task->{START_TIME}, $task->{STOP_TIME}, $task->{NAME}) =
> ($start_time, $stop_time, $name_str);
> 
> 	 #print as_text() . "\n"; # This does not seem to work
> }
> 
> 
> sub as_text {
>     my $self = shift; # Get the object
>     my $start_time = $self->{START_TIME};
>     my $stop_time = $self->{STOP_TIME};
>     return $start_time->as_textTime . " to " . $stop_time-
> >as_textTime . " " . $self->{NAME};
> 
> }
> 1;
> 
> ---------------------------------------------------------
> MyTime.pm
> ---------------------------------------------------------
> package MyTime;
> 
> use warnings;
> use strict;
> use String::Scanf;
> 
> sub new {
> 		my $inv = shift;
> 		my $class = ref( $inv ) || $inv;
> 		die "Too many arguments\n" unless @_ <=3;
> 		my $self;
> 
> 		if ( @_ == 0 ) {
> 
> 		my @time = localtime( );
> 		$self = { HOUR   => $time[ 2 ],
> 			  MINUTE => $time[ 1 ],
> 			  SECOND => $time[ 0 ] };
> 		} else {
> 		$self = { HOUR   => $_[ 0 ],
> 			  MINUTE => $_[ 1 ] || 0,
> 			  SECOND => $_[ 2 ] || 0 };
> 		}
> 
>     return bless $self, $class;
> }
> 
> # Takes a string of the form "%02d:%02d:%02d" and extracts the Time
> sub parseTime {
> 	my $time = $_[0]; # Get the Time object passed
> 	my $line = $_[1]; # Get the string
> 	print "Line = $line \n";
> 
> 	($time->{HOUR}, $time->{MINUTE}, $time->{SECOND}) =
> String::Scanf::sscanf("%02d:%02d:%02d", $line);

Again, split can do the job:

    @time{ qw( HOUR MINUTE SECOND)} = split /:/, $line;

> 
> 	print "Parsed Time:" . $time->as_text . "\n";
> }

The method as_text() doesn't exist in package MyTime.  It should be
as_textTime.

> 
> sub as_textTime {
>     my $self = shift;
>     return sprintf "%02d:%02d:%02d",
>                    $self->{ HOUR }, $self->{ MINUTE }, $self-
> >{ SECOND };
> 
> }
> 1;

Anno


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

Date: Mon, 06 Aug 2007 03:24:02 -0700
From:  "O. Olson" <olson_ord@yahoo.it>
Subject: Re: Object References as a member of a bigger Object
Message-Id: <1186395842.498383.113670@k79g2000hse.googlegroups.com>

Thanks Matt.

On Aug 6, 3:28 am, Matt Madrid <admiral...@gmail.com> wrote:
> >    my $start_time = new MyTime()->parseTime($start_time_str);
> >   my $stop_time  = new MyTime()->parseTime($stop_time_str);
> $start_time will be whatever the return value from MyTime::parseTime() is,
> not an object. Looking at the code in MyTime::parseTime(), that return value
> will be the return value from the final print statement.
>

I actually thought that a new object would be created with new() and
then parseTime() would be called to update that new object. That is
why I did not have parseTime() return anything.

>
> Now, $task->{START_TIME} is equal to 1.
>

	Now, when I have included a return statement in parseTime() it seems
to work.

Thanks a lot,
O.O.



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

Date: Mon, 06 Aug 2007 03:44:16 -0700
From:  "O. Olson" <olson_ord@yahoo.it>
Subject: Re: Object References as a member of a bigger Object
Message-Id: <1186397056.413158.64020@57g2000hsv.googlegroups.com>

Thanks Anno for replying again.

On Aug 6, 11:05 am, anno4...@radom.zrz.tu-berlin.de wrote:
>
> Matt Madrid has pointed out one error: The parseTask method doesn't
> return an object ($task) but the return value of a print statement (1).
>
> I have annotated some more.  I don't see how your code could even
> have reached the statement that you claim showed the error.

Yes, you are right. I actually had as_text() and as_textTime() doing
the same thing in the package MyTime. I forgot to change that.


> >    my ($start_time_str, $stop_time_str, $name_str) =
> > String::Scanf::sscanf("%s to %s %s", $line);
>
> I don't have the module String::Scanf.  The split function can replace
> it here:
>
>     my ($start_time_str, undef, $stop_time_str, $name_str) =
>         split ' ', $name_str;


Thanks for pointing this out. I would like to learn the Perl way of
doing things here.


> >    my $start_time = new MyTime()->parseTime($start_time_str);
> >    my $stop_time  = new MyTime()->parseTime($stop_time_str);
>
> That won't do.  It tries to call ScheduleTask::MyTime which doesn't
> exist.
>
>         My $start_time = MyTime->new->parseTime($start_time_str);
>
> should come closer.
>

I tried to replace the following in my original code.

	#my $start_time = MyTime->new()->parseTime($start_time_str);
	#my $stop_time  = MyTime->new()->parseTime($stop_time_str);

	my $start_time = MyTime->new();
	my $stop_time  = MyTime->new();

	$start_time->parseTime($start_time_str);
	$stop_time->parseTime($stop_time_str);


This replacement works i.e. I get the expected output even when
parseTime() does not return anything as my original code posted. So
does this mean, that what is above is not equivalent to what is below.
I thought we could nest these functions calls.


> Anno

Thanks again,
O.O.





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

Date: Mon, 6 Aug 2007 13:50:59 +0530
From: "rajendra" <rajendra.prasad@in.bosch.com>
Subject: Parent Process id.
Message-Id: <f96lle$tpj$1@news4.fe.internet.bosch.com>

Hello All,

If I open an application from a command prompt, then command prompt becomes
the parent process of the application.

Is there a perl command to get the parent process id for an application?.




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

Date: Mon, 06 Aug 2007 04:27:06 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Parent Process id.
Message-Id: <m23ayx3w6d.fsf@dot-app.org>

"rajendra" <rajendra.prasad@in.bosch.com> writes:

> Is there a perl command to get the parent process id for an application?

Yes, there is a function (not a command - Perl doesn't have commands) for
that - see "perldoc -f getppid" for details.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Mon, 06 Aug 2007 03:51:42 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: Parent Process id.
Message-Id: <1186397502.286893.146490@19g2000hsx.googlegroups.com>

On Aug 6, 4:20 am, "rajendra" <rajendra.pra...@in.bosch.com> wrote:
> If I open an application from a command prompt, then command
> prompt becomes the parent process of the application.
>
> Is there a perl command to get the parent process id for an
> application?.

I assume by 'command' you mean function.  It may help you to know that
ALL built-in Perl functions are listed in the man page:
perldoc perlfunc

Within that documentation they are sorted by category type.  If you
scroll down, you will see this:

     Functions for processes and process groups
         "alarm", "exec", "fork", "getpgrp", "getppid",
         "getpriority", "kill", "pipe", "qx/STRING/", "setpgrp",
         "setpriority", "sleep", "system", "times", "wait",
         "waitpid"

Once you find the function that looks likely, 'getppid', you can then
do:
perldoc -f getppid

to read all about how to use it.

Hope this helps,
Paul Lalli



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

Date: Mon, 6 Aug 2007 20:14:28 +0530
From: "rajendra" <rajendra.prasad@in.bosch.com>
Subject: Re: Parent Process id.
Message-Id: <f97c4e$n5m$1@news4.fe.internet.bosch.com>

Is getppid () is only for UNIX platform?...


"Paul Lalli" <mritty@gmail.com> wrote in message
news:1186397502.286893.146490@19g2000hsx.googlegroups.com...
> On Aug 6, 4:20 am, "rajendra" <rajendra.pra...@in.bosch.com> wrote:
> > If I open an application from a command prompt, then command
> > prompt becomes the parent process of the application.
> >
> > Is there a perl command to get the parent process id for an
> > application?.
>
> I assume by 'command' you mean function.  It may help you to know that
> ALL built-in Perl functions are listed in the man page:
> perldoc perlfunc
>
> Within that documentation they are sorted by category type.  If you
> scroll down, you will see this:
>
>      Functions for processes and process groups
>          "alarm", "exec", "fork", "getpgrp", "getppid",
>          "getpriority", "kill", "pipe", "qx/STRING/", "setpgrp",
>          "setpriority", "sleep", "system", "times", "wait",
>          "waitpid"
>
> Once you find the function that looks likely, 'getppid', you can then
> do:
> perldoc -f getppid
>
> to read all about how to use it.
>
> Hope this helps,
> Paul Lalli
>




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

Date: Mon, 06 Aug 2007 07:56:48 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: Parent Process id.
Message-Id: <1186412208.633791.258540@19g2000hsx.googlegroups.com>

On Aug 6, 10:44 am, "rajendra" <rajendra.pra...@in.bosch.com> wrote:
> Is getppid () is only for UNIX platform?...

perldoc perlport
NAME
     perlport - Writing portable Perl
 ...
     Alphabetical Listing of Perl Functions
 ...
     getppid Not implemented. (Mac OS, Win32, RISC OS)

Paul Lalli



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

Date: Mon, 06 Aug 2007 16:39:22 GMT
From: Rectal Mania (rlm@interlog.com.ca)
Subject: pgp trash troll delete Guy Macon guymacon Guy Macon guymacon Guy Macon
Message-Id: <Z8Iti.388078$%85.50663@fe05.news.easynews.com>
Keywords: pgp trash troll delete Guy Macon guymacon Guy Macon guymacon Guy Macon



pgp trash troll delete

Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon

Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon

Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon


cordially, as always,

rm



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

Date: Mon, 06 Aug 2007 16:59:59 GMT
From: Rectal Mania <rlm@interlog.com.ca>
Subject: Re: pgp trash troll delete Guy Macon guymacon Guy Macon guymacon Guy Macon
Message-Id: <jsIti.41931$Vy2.38819@fe10.news.easynews.com>
Keywords: pgp trash troll delete Guy Macon guymacon Guy Macon guymacon Guy Macon




pgp trash troll delete

Rectal Mania (rlm@interlog.com.ca) says:
>
>pgp trash troll delete
>
>Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
>Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
>Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
>Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
>
>Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
>Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
>Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
>Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
>
>Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
>Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
>Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
>Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon Guy Macon guymacon Guy Macon
>
>
>cordially, as always,
>
>rm

cordially, as always,

rm



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

Date: Sun, 05 Aug 2007 11:21:25 -0000
From:  "dn.perl@gmail.com" <dn.perl@gmail.com>
Subject: Recompiling perl from scratch
Message-Id: <1186312885.980765.281920@i13g2000prf.googlegroups.com>


While installing DBI package, I got the error :
command failed for target Perl.o

I had first added the package perl_s-5.8.5-sol8-sparc-local , and then
I added gcc-2.95.3-sol8-sparc-local . Then I tried to install DBI.

The forum's archives suggest that I should first install gcc, and then
build perl from scratch. I tried it (ran pkgadd -d) but installing DBI
still gives the same error.

1) Should I have installed gcc first before installing perl ?
   I had installed Perl 5.8.5 first, and then gcc.
2) How do I uninstall perl 5.8.5 and then re-install it 'from
scratch'?
3) For gcc-3.3.2, it is suggested that we should first install
libgcc-3.4.6
and libiconv-1.11 packages but no such suggestion is made for
gcc-2.95.3 . Should libgcc and libiconv be installed anyway?

When I login as root, variable LD_LIBRARY_PATH is not set. Should
it be set to any value when compiling DBI module?

Thanks in advance.



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

Date: Mon, 06 Aug 2007 14:35:04 -0000
From:  Ved <vedpsingh@gmail.com>
Subject: Replacing a line
Message-Id: <1186410904.568977.86700@i13g2000prf.googlegroups.com>

Hi all,
I have to replace commented line in a list of  " .cpp" file .
Line  looks like this:
//#define BBPRxChanRouteFileLoadInput 1

i.e. The line format :
//#define (FileName)FileLoadInput 1
 is to be replaced with
#define (FileName)FileLoadInput 1

I have written a code using Tie::File which is mentioned below.
I want to do two things:

1) Remove trailing .cpp in $dir ?

2) What to do in this to get (/ //#define $dirFileLoadInput 1 /)   in
the for loop ?


For above example file name in my.rxfiles is:
BBPRxChanRoute.cpp

Thanks in advance
Ved
#######################################################


#!/usr/local/bin/perl
use strict;
use warnings;
use Tie::File;

my $dir_list = 'my.rxfiles'; #contains list of .cpp files
    open my $fh,'<',$dir_list or die "Cannot read $dir_list: $!\n";
    while (my $dir = <$fh>) {
     chop $dir;
     my $file = "$dir";
      chomp $file;
     if (-e $dir) {
       process_one_file($dir);
     } else {
       warn "File $dir does not exist; skipping\n";
     }
   }

   #Using core module Tie::File to process a file in this subroutine
   sub process_one_file {
     my $dir = shift;
     print "Processing $dir\n";
      tie my @array, 'Tie::File', $dir  or die "tie error $dir: $!
\n" ;
      for (@array) {
          if (/\//#define $dirFileLoadInput 1/)  #what to do here ??
	   {
            $_ = #define $dirFileLoadinput 1 ;
            last;
           }
        }
   }



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

Date: Mon, 06 Aug 2007 10:17:32 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Replacing a line
Message-Id: <46b73b8d$0$493$815e3792@news.qwest.net>

Ved wrote:
> Hi all,
> I have to replace commented line in a list of  " .cpp" file .
> Line  looks like this:
> //#define BBPRxChanRouteFileLoadInput 1
> 
> i.e. The line format :
> //#define (FileName)FileLoadInput 1
>  is to be replaced with
> #define (FileName)FileLoadInput 1
> 
> I have written a code using Tie::File which is mentioned below.
> I want to do two things:
> 
> 1) Remove trailing .cpp in $dir ?

perldoc -f rename

> 
> 2) What to do in this to get (/ //#define $dirFileLoadInput 1 /)   in
> the for loop ?

> #!/usr/local/bin/perl
> use strict;
> use warnings;
> use Tie::File;
> 
> my $dir_list = 'my.rxfiles'; #contains list of .cpp files
>     open my $fh,'<',$dir_list or die "Cannot read $dir_list: $!\n";
>     while (my $dir = <$fh>) {
>      chop $dir;
>      my $file = "$dir";
>       chomp $file;

Why have $dir and $file? Use more descriptive variable
names.

open( my $cpp_files, '<', $dir_list )
	or die "Cannot read $dir_list: $!\n";
while ( my $cpp_file = <$cpp_files> )
{
	chomp $cpp_file;
	if ( -e $cpp_file )
	{
		process_one( $cpp_file );
	}
	else { ...}
}

>      if (-e $dir) {
>        process_one_file($dir);
>      } else {
>        warn "File $dir does not exist; skipping\n";
>      }
>    }
> 
>    #Using core module Tie::File to process a file in this subroutine
>    sub process_one_file {
>      my $dir = shift;

Since you're processing a 'file' not a 'dir'ectory, name your
variables accordingly:

my $file = shift;

print "Processing $file\n";
etc.

>      print "Processing $dir\n";
>       tie my @array, 'Tie::File', $dir  or die "tie error $dir: $!
> \n" ;
>       for (@array) {
>           if (/\//#define $dirFileLoadInput 1/)  #what to do here ??
> 	   {
>             $_ = #define $dirFileLoadinput 1 ;
>             last;

You only want to modify the first one?

>            }
>         }
>    }
> 

	for( @array )
	{
		# Need to escape the $
		if( m{^//#define \$dirFileLoadInput 1$} )
		{
			s{^//}{};
			last;
		}
	}

Documentation on regular expressions:

	perldoc perlretut


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

Date: Mon, 06 Aug 2007 08:36:03 -0700
From:  Ved <vedpsingh@gmail.com>
Subject: Re: Replacing a line
Message-Id: <1186414563.049255.151080@x40g2000prg.googlegroups.com>

> >       for (@array) {
> >           if (/\//#define $dirFileLoadInput 1/)  #what to do here ??
> >       {
> >             $_ = #define $dirFileLoadinput 1 ;
> >             last;
>
> You only want to modify the first one?
>
> >            }

No, I want to modify all
Thanks for the reply.



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

Date: Mon, 06 Aug 2007 11:52:48 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Replacing a line
Message-Id: <46b751e0$0$10306$815e3792@news.qwest.net>

Ved wrote:
>>>       for (@array) {
>>>           if (/\//#define $dirFileLoadInput 1/)  #what to do here ??
>>>       {
>>>             $_ = #define $dirFileLoadinput 1 ;
>>>             last;
>> You only want to modify the first one?

I should have said "the first occurrence of that line in the file."

>>
>>>            }
> 
> No, I want to modify all

If you want to modify all occurrences, then remove the 'last;'

perldoc -f last

You could shorten it a lot, using a few command line options (untested):

perl -pi -e 's{^//#define \$dirFileLoadInput 1$}{#define 
\$dirFileLoadInput 1}g' `cat file_containing_cpp_files`

Or a bit shorter as:

perl -pi -e 's{^//}{} if m{^//#define \$dirFileLoadInput 1$}' `cat 
file_containing_cpp_files`


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

Date: Sun, 05 Aug 2007 07:40:16 -0700
From:  Bill H <bill@ts1000.us>
Subject: Re: Stripping some HTML code, while leaving others
Message-Id: <1186324816.964694.317690@19g2000hsx.googlegroups.com>

On Aug 2, 12:44 am, s...@netherlands.co wrote:
> On Wed, 01 Aug 2007 20:39:08 -0700, Jason <jwcarl...@gmail.com> wrote:
> >I have a textarea field (it's actually a contenteditable field, but it
> >doesn't matter to Perl), and want to allow pre-authorized HTML code to
> >go through, but no un-authorized code.
>
> >I'm allowing them to choose between 4 or 5 font faces, 4 font sizes,
> >bold, italics, underline, and a group of colors. I do NOT, however,
> >want them to use <H1> or CSS.
>
> >This is really only a problem (so far) when someone copies an entire
> >article from a website. I had this posted today:
>
> ><H1 class=headline> # not OK
> ><FONT face=Arial>Investigators Search for Missing Cary Boy</FONT> # OK
> ></H1> # not OK
> ><br>
> ><DIV style="DISPLAY: none"> # not OK
> ><br>
> ><P class=byline> # <P> would be OK, but not class=byline
>
> >The article copied didn't originate from my site, of course, so the
> >CSS is irrelevant. Unless, of course, they stumble upon a class that I
> >did name; then there could be a real problem!
>
> >So, what's the most logical way of removing the "bad" code, but
> >leaving the "good"?
>
> >The only thought I had was to replace "good" HTML with UBB-style code:
> >$post =~ s/<font face=Arial>/[font face=Arial]/gi;
> >$post =~ s/<font face=Verdana>/[font face=Verdana]/gi;
>
> >and so on. Then, strip all of the remaining HTML:
> >$post =~ s/<.*?>//gs;
>
> >Then, convert the UBB code back to HTML:
> >$post =~ s/[font face=Arial]/<font face=Arial>/gi;
> >$post =~ s/[font face=Verdana]/<font face=Verdana>/gi;
>
> >This seems TERRIBLY cumbersome, though; especially when you consider
> >all of the color codes that I'll have to potentially match. I know
> >there's a better way, I just haven't thought of it yet.
>
> >Any ideas? TIA,
>
> >Jason
>
> I don't know what your calling a problem.
> "removing the "bad" code, but leaving the "good"
>
> Do you mean you accept direct uploads of quoted html, to be posted on your site
> for viewing (ie: downloaded html to a renderer)?
>
> I guess its easier to allow the poster to just upload, but, you should be
> a little proactive, and supply an input form, replete with only your allowable
> attributes.
>
> Just my opinion.
>
> Sln- Hide quoted text -
>
> - Show quoted text -

Jason

I have the same issue, taking html text from a content editable field,
and making pdf's out of it. I only want certain html tags, others I
dont want. What I did, and it is a brute force method which could
probably be improved with a hammer, is make 2 arrays, one called html,
one called text, and have all the content in a string.

Here it is in psuedo code:

$count = 0;

while($string ne "")
{
$a = index($string,"<");
$text[$count] = substr($string,0,$a);
$string = substr($string,$a);
$a = index($string,">");
$html[$count] = substr($string,0,$a);
$string = substr($string,$a);
$count++;
}


What you end up with is 2 arrays. $html[?] is the html tag, $text[?]
is the text to display. This will let you look at the html and see if
you want to do anything with it. For instance if you dont want the
<H1> tag:

for($i = 0;$i < @html;$i++)
{
if ($html[$i] ne "<H1>" || $html[$i] ne "</H1>")
{
    print $html[$i];
}
print $text[$i];
}


Again - all this code could be improved with a hammer, but since it is
very simple it is easy to see what is happening.

Bill H



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

Date: Sun, 05 Aug 2007 17:15:30 -0700
From:  Jason <jwcarlton@gmail.com>
Subject: Re: Using DBI, better option than importing into @array
Message-Id: <1186359330.316544.222030@22g2000hsm.googlegroups.com>

On Aug 4, 7:39 am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> On 2007-07-30 21:30, Jason <jwcarl...@gmail.com> wrote:
>
> > I've posted a few times now that I'm rebuilding a message board
> > program to use MySQL instead of flat text files. I'm relatively new to
> > MySQL, though, so I'm having fun with the challenges along the way.
>
> > The database has 2 tables: one to hold subjects, and one to hold all
> > of the posts. The subjects table has around 17000 rows, while the
> > posts table has around 600,000.
>
> > The most current problem is SPEED! From sheer lack of knowledge, I'm
> > importing the subjects table into an array in the beginning of the
> > script, then using a for loop throughout the program to access that
> > array. But the program is running pretty slow, and I'm sure that the
> > bottleneck is with this array.
>
> This first thing you have to do when you try to make your program faster
> is to profile it. If you don't know WHAT exactly is slow, you can only
> guess, and you'll probably guess wrong and spend a lot of time improving
> the performance by one percent.
>
> There are tools for profiling, like Devel::DProf or Apache::DProf, but
> for starters, you can just use time (possibly with Time::HiRes to get
> sub-second resolution) and print, like this:
>
> > Here is the code that I'm using:
>
> use Time::HiRes qw(time);
>
> my $t0 = time;
>
> > # Push subjects into Perl array
> > my $filelist = $dbh->selectall_arrayref("SELECT `id`, `lastmodified`,
> > `subject` FROM $forum_subjects ORDER BY lastmodified DESC");
>
> > my @filenames;
> > for my $row (@$filelist) {
> >   my ($id, $lastmodified, $subject) = @$row;
> >   push(@filenames, $id . "|:|" . $lastmodified . "|:|" . $subject);
> > }
>
> my $t1 = time();
> print STDERR "retrieved subject list in ", $t1 - $t0, " seconds\n";
>
> $t0 = time();
>
>
>
> > # In the "view subject" section, loop through last 20 indexes of
> > @filenames
> > # 0 and 20 are dynamic in the real script
> > for ($count=0; $count < 20; $count++) {
> >   ($id, $lastmodified, $subject) = split(/\|:\|/, $filenames[$count]);
>
> >   my $topiclist = $dbh->selectall_arrayref("SELECT `id`, `subject`,
> > `postdate`, `username`, `email`, `comment` FROM $forum_posts WHERE
> > id=" . $dbh->quote($id) . " ORDER BY postdate ASC");
>
> >   print ...
> > }
>
> $t1 = time();
>
> print STDERR "displayed 20 postings in ", $t1 - $t0, " seconds\n";
>
> This will tell you whether you spend most time in the first or the
> second part of your program. Naturally, you start improving the part
> where it spends most time ...
>
> It also gives you numbers to compare so you don't have to rely on
> subjective feeling of speed. "I think it is now faster than last week"
> is not a good measurement. If you see in your log files that last week
> it took between 8 and 11 seconds, and now you're down to 5 to 6 seconds,
> you know that you've made progress.
>
>         hp
>
> --
>    _  | Peter J. Holzer    | I know I'd be respectful of a pirate
> |_|_) | Sysadmin WSR       | with an emu on his shoulder.
> | |   | h...@hjp.at         |
> __/   |http://www.hjp.at/|      -- Sam in "Freefall"


That's extremely helpful, Peter. Thank you very much for such great
details! I've been measuring my success by the average server load,
and while it's greatly improved with this transition, I'm sure that I
can make it better.

- Jason



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

Date: Sun, 05 Aug 2007 14:03:59 -0500
From: l v <veatchla@yahoo.com>
Subject: Re: Windows based perl editor?
Message-Id: <13bc7osrsg6th6c@news.supernews.com>

Clenna Lumina wrote:
> l v wrote:
>> Bill H wrote:
>>> I have been using Edit (in a dos box) on Windows for editing perl for
>>> the past 8 years or so, and though it is fine for me, I think it is
>>> time to step up to a windows based editor. Can anyone recommend a
>>> good windows based perl editor?
>>>
>>> My wish list for what the editor would be able to do is:
>>>
>>> 1. Allow me to run the program I am editting in a dos box (using
>>> active state perl)
>>> 2. Have multiple undos
>>> 3. Create multiple back up files as I save changes (a form of version
>>> control so I can step back to a previous "version" if what I did
>>> doesnt work right).
>>> 4. Syntax hilighting
>>> 5. Multiple programs open at the same time
>>> 6. Some form of project structure to allow me to group all the files
>>> together
>>>
>>> Most of these "wishes" come from the MS Visual C++ editor I used to
>>> use before discovering perl.
>>>
>>> Searching the internet I came across Perl Express (http://perl-
>>> editor.perl-express.com/) but am leary of downloading programs I find
>>> on the internet without knowing if they are safe.
>>>
>>> I am not sure if this would influence your recommendtions but the
>>> majority (99%) of the perl I write is used on web servers.
>>>
>>> Any / all suggestions are appreciated.
>>> Bill H
>>>
>> PerlBuilder from www.solutionsoft.com (not free) is a good lightweight
>> perl IDE.  No need to define a project to edit a standalone single
>> perl script.  Would love to have Komodo.
>>
>> A very nice fee editor is Notepad++.
> 
> I believe he meant "free" and not "fee", as they do not charge a fee to 
> use it :)
> 

I made a typo -  A very nice *free* editor is Notepad++.

-- 

Len


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

Date: Sun, 05 Aug 2007 19:42:11 GMT
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: Windows based perl editor?
Message-Id: <nKpti.34732$Xa3.19814@attbi_s22>

On 8/2/2007 9:36 PM, sln@netherlands.co wrote:
> On Thu, 02 Aug 2007 19:28:36 -0700, Bill H <bill@ts1000.us> wrote:
>> Can anyone recommend a good windows based perl editor?
>>
>> My wish list for what the editor would be able to do is:
>>
>> 1. Allow me to run the program I am editting in a dos box (using
>>    active state perl)
>> 2. Have multiple undos
>> 3. Create multiple back up files as I save changes (a form of version
>>    control so I can step back to a previous "version" if what I did
>>    doesnt work right).
>> 4. Syntax hilighting
>> 5. Multiple programs open at the same time
>> 6. Some form of project structure to allow me to group all the files
>>    together
> 
> Ultra-Edit32 is your best bet, it won't do most of what you wan't but
> you can see closures. Plus the colors are nice if your on drugs.

s/won't do most/can do all/;

Item 1 requires setting up a user tool. Everything else is built in.

-mjc


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

Date: Sun, 05 Aug 2007 19:53:19 GMT
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: Windows based perl editor?
Message-Id: <PUpti.52044$Fc.47561@attbi_s21>

On 8/3/2007 12:47 AM, sln@netherlands.co wrote:
> On Thu, 02 Aug 2007 22:03:48 -0700, skywriter14 <sumonsmailbox@gmail.com> 
> wrote:
> 
>> Can anyone refer to anything as good as these? I have heard good things 
>> about Ultra Edit and an IDE from ActiveState. But they are not free, right?

UltraEdit is pay software but it's fairly inexpensive. The ActiveState IDE
you're thinking of is probably Komodo. I haven't heard many good things about it.

> Ultra Edit does a good job syntax checking while you type it.

UE does syntax *highlighting*. It doesn't do syntax checking at all. (But it's
easy to set up a user tool for "perl -Mstrict -Mdiagnostics -cw <file>")

> So, ahh, what was the question? Oh, Ultra Edit. Download the trial version 
> from thier web site. Go to crackz.com, get the simple code, then open up all
> the features. If you like it, go back to Ultra Edits web site and BUY it! 
> Thats the way its done down home.

The UltraEdit trial is fully functional but time-limited. The trial period is
either 30 or 45 days, I can't recall offhand. So there's no need for cracks
(which you shouldn't be advocating anyway).

-mjc



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 723
**************************************


home help back first fref pref prev next nref lref last post