[27288] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9037 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 9 18:05:48 2006

Date: Thu, 9 Mar 2006 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 9 Mar 2006     Volume: 10 Number: 9037

Today's topics:
        BECOME A DOT.COM MILLIONAIRE WITH ONLY  $5.99Cents or $ <invest@vosar.net>
        overginign two arrays to a package! <rbcs@gmx.net>
        Problem with bless <news@chaos-net.de>
    Re: Problem with bless xhoster@gmail.com
    Re: Problem with bless <news@chaos-net.de>
    Re: Question about sub calling other sub <news@chaos-net.de>
    Re: regexp: segmentation fault <jgibson@mail.arc.nasa.gov>
    Re: Year of day in localtime and timelocal don't match? (Anno Siegel)
    Re: Year of day in localtime and timelocal don't match? (J Moreno)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 9 Mar 2006 14:45:40 -0500
From: ISRAEL FAGBEMI<invest@vosar.net>
Subject: BECOME A DOT.COM MILLIONAIRE WITH ONLY  $5.99Cents or $1K. 
Message-Id: <GB%Pf.69974$8d1.24478@read1.cgocable.net>





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

Date: Thu, 09 Mar 2006 21:29:26 +0100
From: RBCS <rbcs@gmx.net>
Subject: overginign two arrays to a package!
Message-Id: <pan.2006.03.09.20.29.25.461000@gmx.net>

Hello, 

Why are in the package Testing all the Vars from arr1 and arr2 in the
@array1 array and the @array2 empty?

Roman

___________________________

my (@tasks);
my (@args);

my $ResultofTesting = Testing->info($par1, $par2, @arr1, @arr2);


ackage Testing;

  sub info{
    my( undef, $param1, $param2, @array1, @array2 ) = @_;



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

Date: Thu, 9 Mar 2006 21:16:33 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Problem with bless
Message-Id: <slrne11391.23g.news@maki.homeunix.net>

Hello together,

I have read perldoc perlboot and tried to practice a little.

Now I have a problem with the (redueced) script below.
When I omit "use strict" i get the output of the final print statement
as expected.
With "use strict" I get the error:
	Bareword "Sheep" not allowed while "strict subs" in use at
	./sheep.pl line 23.
	Execution of ./sheep.pl aborted due to compilation errors.

Line 23 is the second from last line.
I do not really know what the error means and I also do not know how to
change the script to make it work with "use strict".

Can anyone give me some explanation and/or point me to the applicable
section of the docs? perldoc -q "strict subs" was not helpful.

Thanks in advance and
Best regards
Martin 

and here comes the code:

#!/usr/bin/perl
use warnings;
# use strict;

{ package Animal; 
    sub name {
        my $instance = shift;
        $instance->{Name}
    }
    sub color {
        $_[0]->{Color}
    }
}
{ package Sheep;
    use vars qw(@ISA);
    @ISA = qw(Animal);
    sub sound { "baaah" };
    sub default_color { "white" }
}

my $badsheep = bless { Name => "Evil", Color => "black" }, Sheep;
print "The sheep ",$badsheep->name," is ",$badsheep->color," and says ",
$badsheep->sound, "!\n";

-- 
perl -e '$S=[[73,116,114,115,31,96],[108,109,114,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'


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

Date: 09 Mar 2006 20:17:52 GMT
From: xhoster@gmail.com
Subject: Re: Problem with bless
Message-Id: <20060309152314.662$aq@newsreader.com>

Martin Kissner <news@chaos-net.de> wrote:

> Can anyone give me some explanation and/or point me to the applicable
> section of the docs? perldoc -q "strict subs" was not helpful.

"perldoc strict", search for "bareword".  Paricularly note that
"quoted string is always ok" comment.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Thu, 9 Mar 2006 21:26:59 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Problem with bless
Message-Id: <slrne113sj.23g.news@maki.homeunix.net>

xhoster@gmail.com wrote :
> Martin Kissner <news@chaos-net.de> wrote:
>
>> Can anyone give me some explanation and/or point me to the applicable
>> section of the docs? perldoc -q "strict subs" was not helpful.
>
> "perldoc strict", search for "bareword".  Paricularly note that
> "quoted string is always ok" comment.

Thank you (also to Paul Lalli who also pointed me to "perldoc strict" in
his post)
That helped.

Best regards
Martin 

-- 
perl -e '$S=[[73,116,114,115,31,96],[108,109,114,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'


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

Date: Thu, 9 Mar 2006 19:21:25 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Question about sub calling other sub
Message-Id: <slrne10sh5.1j9.news@maki.homeunix.net>

Anno Siegel wrote :
> Martin Kissner  <news@chaos-net.de> wrote in comp.lang.perl.misc:
[...]
>> Actually when I started I had three very simliar looking subs which I
>> now put together into one. By passing flags ($action) I trigger what
>> they are supposed to do.
>
> The flag mechanism is sometimes used to avoid code duplication.  In general,
> I'd go with Randal and try to factor out the common part(s).  "In a good
> program, every routine does almost nothing".  Sometimes different tools
> for screwing a particular kind of screw in and out is a good solution.
>
> But don't use the caller instead of an explicit flag.  You create a
> dependency that doesn't have to be there.  There may be reasons to
> call the subs from other packages, or to rename the packages that are
> calling them.  In both cases, the basically unrelated subs must be
> changed.  With the other solutions, (flag or part of the sub name)
> everything happens at the place of call.

Thank you for your feedback, Anno.
Your comment has been quite helpful. I had to think about it for a few
days an while going ahead with my script I think I was able to improve
the code design keeping your advice in mind.

Best regards
Martin 

-- 
perl -e '$S=[[73,116,114,115,31,96],[108,109,114,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'


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

Date: Thu, 09 Mar 2006 13:25:19 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: regexp: segmentation fault
Message-Id: <090320061325191652%jgibson@mail.arc.nasa.gov>

In article <duo03f$oc2$2@oheron.kent.ac.uk>, S.Marion
<sm244@kent.ac.uk> wrote:

> Hello,
> 
> Thank you for your reply.
> Let me apologise if I wasn't clear enough.

Then please be clearer.

> Basically the inputs are from javap, and I want to match a particular 
> offset of a given output in the given method with the given signature.

I am not familiar with the format of the output from javap. You are not
likely to find anybody reading this newsgroup who is. You should show
us some relevant examples.

> > By the way, the (.*) after $offset is the fifth capture group.
> > 
> That's right, my mistake, got confused after moving it around.

You need to show us the exact code you are trying to use. You need to
put it into a complete program that includes some sample data that
anybody can cut-and-paste and run on their own system.

> > If you are not interested in capturing anything before that, why are you 
> > using capturing groups?
> > 
> well... simply because I have no idea how else I could say "ok jump as 
> many lines as you want until you find my offset".

You can match without capturing: 
 .* matches any number of characters
(.*) matches and captures.
(:?.*) matches and doesn't capture.

If you don't need to capture the match, don't do it.

> > I have a feeling (since I have no data, I cannot test this), anchoring 
> > the pattern, using .+ rather than .* might help.
> > 
> No unfortunately that doesn't do the trick.

What is the "trick"?

> > On the other hand, depending on what the input looks like, I might be 
> > tempted to use the .. operator.
> > 
> I'm not sure I understand what this does, but in any case it does not 
> work unfortunately :(

If you don't understand what .. does, how do you know it does not work
in your case? How does it not work? Is your Perl buggy? Or is it that
 .. you do not know what .. does?

Your segmentation fault is likely to be due to trying to apply a regex
that contains several wildcards to a very long string (tens of
thousands of lines). Each wildcard of the type .* can match numerous
substrings in your very long string. You need to devise a different
algorithm, perhaps one using index and substring to extract the
relevant parts of your string.

Here is an example that uses the flip-flop operator (..) to print lines
that appear between two strings:


Jim 39% cat marion.pl
#!/usr/local/bin/perl -w

use strict;
use warnings;
while(<DATA>) {
  print if( /^blablabla/ .. /secret/ );
}
__DATA__
bla
2000 lines
don't print this
don't print this
don't print this (etc)
what i want: secret
blablabla
10 000 lines (more than 32k)
print this
print this
print this (etc)
what i want: secret

Jim 40% perl marion.pl
blablabla
10 000 lines (more than 32k)
print this
print this
print this (etc)
what i want: secret
Jim 41%

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: 9 Mar 2006 16:12:19 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Year of day in localtime and timelocal don't match?
Message-Id: <dupk53$695$1@mamenchi.zrz.TU-Berlin.DE>

J Moreno <planB@newsreaders.com> wrote in comp.lang.perl.misc:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> 
> > Read Gunnar's reply again.  The day_of_year count starts at 0, the
> > day_of_month count starts at 1.  That goes for the return values of
> > localtime() as well as for the input parameters of timelocal() and
> > timelocal_nocheck().  You are using a day_of_year type count as
> > a day_of_month type argument.  Of course the result is off by one.
> 
> No, I don't think so.

Hmmm?  One count is zero based, the other is one based.  When you use
one for the other, you'll be off by one.  Nothing of what you wrote
contradicts that.

[...]

> So, timelocal_nocheck is clearly treating it as a day of year value,
> not a day of the month value which is being liberally interpreted, and

What is the difference between a liberally interpreted day of month
and a day of year?  Especially if the month in question is January?

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Thu, 9 Mar 2006 11:48:58 -0500
From: planB@newsreaders.com (J Moreno)
Subject: Re: Year of day in localtime and timelocal don't match?
Message-Id: <1hbxk0l.jbkb1o1vw88fhN%planB@newsreaders.com>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:

> J Moreno <planB@newsreaders.com> wrote in comp.lang.perl.misc:
-snip-
> > So, timelocal_nocheck is clearly treating it as a day of year value,
> > not a day of the month value which is being liberally interpreted, and
> 
> What is the difference between a liberally interpreted day of month
> and a day of year?  Especially if the month in question is January?

You're right, I was wrong.  It was the January that set me straight,
thanks.

It is indeed a liberally interpreted day of month, with the default
month being January.

###
use Time::Local 'timelocal_nocheck';

$\ = "\n";

print scalar localtime timelocal_nocheck  0,0,0,365, 2, 2006;
###

Outputs

Wed Feb 28 00:00:00 2007

(My mental mistake was ignoring/forgetting the default values and what
they meant.  Thanks for calling me on it).

-- 
JM
"Everything is futile." -- Marvin of Borg


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

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 V10 Issue 9037
***************************************


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