Re: segmentation fault

2011-12-24 Thread Motaz SAAD
On Dec 21, 5:37 pm, shlo...@shlomifish.org (Shlomi Fish) wrote:
 On Wed, 21 Dec 2011 09:48:19 -0600









 Robert Wohlfarth rbwohlfa...@gmail.com wrote:
  On Tue, Dec 20, 2011 at 11:25 AM, Motaz SAAD motaz.s...@gmail.com wrote:

   I am a beginner  in perl and I have segmentation fault in my code. the
   code run perfectly for the until the third iteration and it produce
   segmentation fault  in the inner while loop in the 3rd iteration of
   the outer while loop.
   Would you please help me with hints.
   Your help will be appreciated

  If it were me, I would add print statements inside of the loop (see
  below). When it segfaults, you see which two prints the error comes
  between. Then move those closer and closer until you find the line causing
  the error.  That narrows down the scope. It looks like you started down
  that path already...

 You can achieve the same effect much more easily and without polluting your
 code using Devel::Trace :

 *http://search.cpan.org/dist/Devel-Trace/

 There's alsohttp://search.cpan.org/dist/Devel-Trace-More/and my 
 ownhttp://search.cpan.org/dist/Devel-LineTrace/(which does something a
 bit different than the others) which may prove of use.

 Regards,

         Shlomi Fish

 --
 -
 Shlomi Fish      http://www.shlomifish.org/
 Star Trek: We, the Living Dead -http://shlom.in/st-wtld

 No one calls Xena the warrior princess “Zeena” to her face and survives.
 Luckily for you, she hasn’t visited the modern day United States yet.

 Please reply to list if it's a mailing list post -http://shlom.in/reply.

Hello,

Thanks very much, it is really helpful tool.
my script spend 10 min running until I get segmentation fault error,
but when I traced my script and it spend 2 days and still running !!!
I run tracing using -d flag (perl -d:Trace p.pl)
is this normal ?

Thanks,
Best Regards,


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Regex : Extract data between { } spanning in multplie lines

2011-12-24 Thread iand
Switching to multiline mode ~/regex/m doesnt seem to be working.

Ex file.txt:
A1 {@ a d e \n a b c}
A2 {@ 1 {2 3} \n a b c \n d e f}

I need to extract these separately :
{@ a d e a b c }
{@ 1 {2 3} \n a b c \n d e f}

perl -lne 'print $1 if '~/^[A-Z0-9]+\s\{.*$/m' file.txt
I can extract data by grouping after \{ in regex but how to span over
multiple lines and make this work. Need pointers.

iand






-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Comparing Perl Hashes

2011-12-24 Thread Pradeep Patra
Hi all,
   I have a questions of comparing two hashes.

%hash1={a=2,b=3,c=4,d=5}
%hash2={a=7,b=8,c=9,d=0)

I have to ensure that from %hash2 the value is increased by 5(2-7 and
3-8) for a,b. I dont want to compare the all the values of
hash2(for exp-d=0).I want to push this to a library(preferably a
single method) so that I can reuse it. Is there a better way to do
this?.

Can anybody help me in this regard? Any source code will be of great
help.


Regards
Pradeep


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: segmentation fault

2011-12-24 Thread Shlomi Fish
Hi Motaz,

On Thu, 22 Dec 2011 10:57:48 -0800 (PST)
Motaz SAAD motaz.s...@gmail.com wrote:
 Hello,
 
 Thanks very much, it is really helpful tool.

You're welcome.

 my script spend 10 min running until I get segmentation fault error,
 but when I traced my script and it spend 2 days and still running !!!
 I run tracing using -d flag (perl -d:Trace p.pl)
 is this normal ?

Well, the -d:Trace flag slows down the execution, but it shouldn't be such a
dramatic difference. I guess you've ran into a Heisenbug:

http://en.wikipedia.org/wiki/Unusual_software_bug#Heisenbug

I'm not sure what's causing it, but I guess you can try doing manual traces
using prints.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Chuck Norris/etc. Facts - http://www.shlomifish.org/humour/bits/facts/

And the top story for today: wives live longer than husbands because they are
not married to women.
— Colin Mochrie in Who’s Line is it, Anyway?

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Comparing Perl Hashes

2011-12-24 Thread Shlomi Fish
Hi Pradeep,

On Fri, 23 Dec 2011 00:11:22 -0800 (PST)
Pradeep Patra smilesonisa...@gmail.com wrote:

 Hi all,
I have a questions of comparing two hashes.
 
 %hash1={a=2,b=3,c=4,d=5}
 %hash2={a=7,b=8,c=9,d=0)
 

This is the wrong way of initialising hash variables. You're assigning hash
references to hashes instead of even-sized lists. Try:

%hash1 = (a=2,b=3,c=4,d=5);
%hash2 = (a=7,b=8,c=9,d=0);

 I have to ensure that from %hash2 the value is increased by 5(2-7 and
 3-8) for a,b. I dont want to compare the all the values of
 hash2(for exp-d=0).I want to push this to a library(preferably a
 single method) so that I can reuse it. Is there a better way to do
 this?.
 
 Can anybody help me in this regard? Any source code will be of great
 help.

You can simply do:

sub are_hashes_ok
{
for my $key ('a', 'b')
{
if ($hash1{$key} + 5 != $hash2{$key})
{
return;
}
}
return 1;
}

Regards,

Shlomi Fish
 
 
 Regards
 Pradeep
 
 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
Funny Anti-Terrorism Story - http://shlom.in/enemy

Satan condemned Hitler for a million years of writing XSLT.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Regex : Extract data between { } spanning in multplie lines

2011-12-24 Thread David Christensen

On 12/23/2011 01:56 AM, iand wrote:

Ex file.txt:
A1 {@ a d e \n a b c}
A2 {@ 1 {2 3} \n a b c \n d e f}

I need to extract these separately :
{@ a d e a b c }
{@ 1 {2 3} \n a b c \n d e f}


http://shop.oreilly.com/product/9780596528126.do


HTH,

David


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




How to confirm user account

2011-12-24 Thread masayoshi
Hi

Please visit http://blogs.perl.org/.

If I register my account, I get the following message.


To confirm your account, please click on or cut and paste the following URL 
into a web browser:

http://blogs.perl.org/mt/mt-cp.fcgi?__mode=do_confirmreturn_to=http%3A%2F%2Fblogs.perl.org%2Femail=rockstar01%40y7mail.comblog_id=1id=1610token=**iTebiC***chWNa

If I don't use MOVABLE TYPE, Is there any CPAN module to do this?
Or I must write this with perl by myself.
I have searched CPAN, but I could not find any module to do it. _


Thanks in advance.

 
---
Inexperienced FreeBSD user: Level 4
masayoshi  Ayumi Kinoshita
http://tinyurl.com/63zg3op

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: segmentation fault

2011-12-24 Thread Adams Paul

Sent from my LG phone

Motaz SAAD motaz.s...@gmail.com wrote:

On Dec 21, 5:37 pm, shlo...@shlomifish.org (Shlomi Fish) wrote:
 On Wed, 21 Dec 2011 09:48:19 -0600









 Robert Wohlfarth rbwohlfa...@gmail.com wrote:
  On Tue, Dec 20, 2011 at 11:25 AM, Motaz SAAD motaz.s...@gmail.com wrote:

   I am a beginner  in perl and I have segmentation fault in my code. the
   code run perfectly for the until the third iteration and it produce
   segmentation fault  in the inner while loop in the 3rd iteration of
   the outer while loop.
   Would you please help me with hints.
   Your help will be appreciated

  If it were me, I would add print statements inside of the loop (see
  below). When it segfaults, you see which two prints the error comes
  between. Then move those closer and closer until you find the line causing
  the error.  That narrows down the scope. It looks like you started down
  that path already...

 You can achieve the same effect much more easily and without polluting your
 code using Devel::Trace :

 *http://search.cpan.org/dist/Devel-Trace/

 There's alsohttp://search.cpan.org/dist/Devel-Trace-More/and my 
 ownhttp://search.cpan.org/dist/Devel-LineTrace/(which does something a
 bit different than the others) which may prove of use.

 Regards,

         Shlomi Fish

 --
 -
 Shlomi Fish      http://www.shlomifish.org/
 Star Trek: We, the Living Dead -http://shlom.in/st-wtld

 No one calls Xena the warrior princess “Zeena” to her face and survives.
 Luckily for you, she hasn’t visited the modern day United States yet.

 Please reply to list if it's a mailing list post -http://shlom.in/reply.

Hello,

Thanks very much, it is really helpful tool.
my script spend 10 min running until I get segmentation fault error,
but when I traced my script and it spend 2 days and still running !!!
I run tracing using -d flag (perl -d:Trace p.pl)
is this normal ?

Thanks,
Best Regards,


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/





Testing for Missing Packages

2011-12-24 Thread Eric James Michael Ritz

Hello everyone.

Here is my question: What is the preferred way to test a system for
installed modules?  For example, I have a Perl program I would like to
distribute.  It depends on a number of modules from CPAN and I would
like an easy way to test for the existence of those modules.  I
suppose the user could always run the program and then install them
whenever he gets an error about the packages not being found, but it
feels like there should be a friendlier way to address that.

Is there a common way in Perl to say, “This program depends on these
packages and requires them to be installed before running?”  And if
so, is there a common, automated way to prompt the user to install any
of those missing packages?

Thanks in advanced and happy holidays everyone!

--
ejmr
南無妙法蓮華經


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Testing for Missing Packages

2011-12-24 Thread Shlomi Fish
Hi Eric,

On Sat, 24 Dec 2011 20:23:17 -0500
Eric James Michael Ritz lobbyjo...@gmail.com wrote:

 Hello everyone.
 
 Here is my question: What is the preferred way to test a system for
 installed modules?  For example, I have a Perl program I would like to
 distribute.  It depends on a number of modules from CPAN and I would
 like an easy way to test for the existence of those modules.  I
 suppose the user could always run the program and then install them
 whenever he gets an error about the packages not being found, but it
 feels like there should be a friendlier way to address that.
 
 Is there a common way in Perl to say, “This program depends on these
 packages and requires them to be installed before running?”  And if
 so, is there a common, automated way to prompt the user to install any
 of those missing packages?
 

Yes, there is. See:

* http://search.cpan.org/dist/Module-Build/

* http://search.cpan.org/dist/Module-Install/

* http://search.cpan.org/dist/ExtUtils-MakeMaker/

Regards,

Shlomi Fish

 Thanks in advanced and happy holidays everyone!
 
 --
 ejmr
 南無妙法蓮華經
 
 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
Freecell Solver - http://fc-solve.shlomifish.org/

You can never truly appreciate The Gilmore Girls until you’ve watched it in
the original Klingon.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/