[28456] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9820 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 8 18:05:58 2006

Date: Sun, 8 Oct 2006 15:05:08 -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           Sun, 8 Oct 2006     Volume: 10 Number: 9820

Today's topics:
        about FAQ4.5 and substr <cmic@caramail.com>
    Re: about FAQ4.5 and substr <rvtol+news@isolution.nl>
    Re: about FAQ4.5 and substr <someone@example.com>
    Re: Complex regular expression anno4000@radom.zrz.tu-berlin.de
    Re: Complex regular expression <ced@blv-sam-01.ca.boeing.com>
    Re: Complex regular expression <ced@blv-sam-01.ca.boeing.com>
    Re: Distributed multitasking, POE, communication <benmorrow@tiscali.co.uk>
        Google calendar interaction ethandbrown@gmail.com
        Help with test program joubertb@gmail.com
    Re: Help with test program <hjp-usenet2@hjp.at>
        new CPAN modules on Sun Oct  8 2006 (Randal Schwartz)
        Perl/OpenGL textures support weer1@gmx.net
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <tadmc@augustmail.com>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <nospam-abuse@ilyaz.org>
        print line number <news12@8439.e4ward.com>
    Re: print line number <1usa@llenroc.ude.invalid>
    Re: print line number <abigail@abigail.be>
    Re: print line number <news12@8439.e4ward.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 8 Oct 2006 06:26:56 -0700
From: "cmic" <cmic@caramail.com>
Subject: about FAQ4.5 and substr
Message-Id: <1160314016.782241.236800@m7g2000cwm.googlegroups.com>

Hello
The FAQ 4.54, about converting from hex to dec uses the following
method :
$dec = unpack("N", pack("H8", substr("0" x 8 . "DEADBEEF", -8)));

 I don't understand the usefulleness of the substr thing, because

$dec = unpack("N", pack("H8", "DEADBEEF"));

works OK too.



Could anyone explain, please.

THX

--
              
cic a Perl hacker wanabee 8-)



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

Date: Sun, 8 Oct 2006 15:52:05 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: about FAQ4.5 and substr
Message-Id: <egb7e9.j0.1@news.isolution.nl>

cmic schreef:

> The FAQ 4.54, about converting from hex to dec uses the following
> method :
>     $dec = unpack("N", pack("H8", substr("0" x 8 . "DEADBEEF", -8)));
> I don't understand the usefulleness of the substr thing, because
>     $dec = unpack("N", pack("H8", "DEADBEEF"));
> works OK too.

The "DEADBEEF" is an example, try "BEEF".

-- 
Affijn, Ruud

"Gewoon is een tijger."




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

Date: Sun, 08 Oct 2006 21:32:26 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: about FAQ4.5 and substr
Message-Id: <K7eWg.3008$P7.169@edtnps90>

cmic wrote:
> Hello
> The FAQ 4.54, about converting from hex to dec uses the following
> method :
> $dec = unpack("N", pack("H8", substr("0" x 8 . "DEADBEEF", -8)));
> 
>  I don't understand the usefulleness of the substr thing, because
> 
> $dec = unpack("N", pack("H8", "DEADBEEF"));
> 
> works OK too.

If you replace the literal string "DEADBEEF" with a variable that may have
zero or more hexadecimal digits then '"0" x 8 . ' prepends eight zeros to
ensure that the string is at least eight characters long and substr() ensures
that the resulting string is exactly eight characters long.



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: 8 Oct 2006 01:40:53 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Complex regular expression
Message-Id: <4or395FfuqkvU1@news.dfncis.de>

Charles DeRykus  <ced@blv-sam-01.ca.boeing.com> wrote in comp.lang.perl.misc:
> jayanthigk2004@yahoo.com wrote:
> > Is it possible to write a regular expression for this ?
> > 
> > Pattern: 999-99-999
> > 
> > 
> > Where 9 is any number from 0 to 9

[...]

> maybe I'm missing something but seems like `index' should do it once 
> you've eliminated the irrelevant leading/trailing *'s:
> 
> my $pat = '999-99-999';
> 
> my ( $no_star = $some_str ) =~ s/\A\*//;  $no_star =~ s/\*\z//;
> print "match: $some_str" if  index( $pat, $no_star ) == 0;

Not when "9 is any number from 0 to 9".

Anno


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

Date: Sun, 8 Oct 2006 03:48:26 GMT
From: Charles DeRykus <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Complex regular expression
Message-Id: <J6st8p.Ezp@news.boeing.com>

anno4000@radom.zrz.tu-berlin.de wrote:
> Charles DeRykus  <ced@blv-sam-01.ca.boeing.com> wrote in comp.lang.perl.misc:
>> jayanthigk2004@yahoo.com wrote:
>>> Is it possible to write a regular expression for this ?
>>>
>>> Pattern: 999-99-999
>>>
>>>
>>> Where 9 is any number from 0 to 9
> 
> [...]
> 
>> maybe I'm missing something but seems like `index' should do it once 
>> you've eliminated the irrelevant leading/trailing *'s:
>>
>> my $pat = '999-99-999';
>>
>> my ( $no_star = $some_str ) =~ s/\A\*//;  $no_star =~ s/\*\z//;
>> print "match: $some_str" if  index( $pat, $no_star ) == 0;
> 
> Not when "9 is any number from 0 to 9".
> 

Hm,, I'm not sure why that'd invalidate this approach. If  $pattern were 
123-45-6789 for instance, this still works AFAICT.

-- 
Charles DeRykus





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

Date: Sun, 8 Oct 2006 04:14:03 GMT
From: Charles DeRykus <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Complex regular expression
Message-Id: <J6suFD.FLI@news.boeing.com>

Charles DeRykus wrote:
> anno4000@radom.zrz.tu-berlin.de wrote:
>> Charles DeRykus  <ced@blv-sam-01.ca.boeing.com> wrote in 
>> comp.lang.perl.misc:
>>> jayanthigk2004@yahoo.com wrote:
>>>> Is it possible to write a regular expression for this ?
>>>>
>>>> Pattern: 999-99-999
>>>>
>>>>
>>>> Where 9 is any number from 0 to 9
>>
>> [...]
>>
>>> maybe I'm missing something but seems like `index' should do it once 
>>> you've eliminated the irrelevant leading/trailing *'s:
>>>
>>> my $pat = '999-99-999';
>>>
>>> my ( $no_star = $some_str ) =~ s/\A\*//;  $no_star =~ s/\*\z//;
>>> print "match: $some_str" if  index( $pat, $no_star ) == 0;
>>
>> Not when "9 is any number from 0 to 9".
>>
> 
> Hm,, I'm not sure why that'd invalidate this approach. If  $pattern were 
> 123-45-6789 for instance, this still works AFAICT.
> 

Based on the OP's example, I was assuming that any match still needed to 
capture exactly some subset of the pattern. I guess it was ambiguous 
only to me...

-- 
Charles DeRykus


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

Date: Sun, 8 Oct 2006 00:44:52 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Distributed multitasking, POE, communication
Message-Id: <koqlv3-vek.ln1@osiris.mauzo.dyndns.org>

[disclaimer: I have never used POE. The below is based on the
documentation]

Quoth schwarzenschafe@gmail.com:
> I'm writing a distributed WWW media (images) robot. I want a central
> server that holds the database and manages the other servers. These
> other servers will manage several robot processes. Every server will
> have different access to the web, and must communicate over the
> internet.
> 
> I'd like to use POE, I need some kind of event driven management of
> each server. I can't run the robots themselves in POE because they'll
> be waiting for LWP to return webpages,

You can use POE::Component::Client::HTTP to get webpages, instead of
LWP. Then you can integrate the fetching into your manager process,
which will probably be more efficient.

> and I'd also like to sleep()
> which makes the whole POE driven server (all robots) stop.

Well, yes. Why do you think you want to sleep? You can use
POE::Kernel->delay_set to be notified after a certain amount of time has
passed.

> The best setup I can come up with uses domain sockets

ITYM 'Unix-domain sockets'? Every socket has a domain (usually called
the 'address family'); the point about Unix-domain sockets is that the
domain is the local Unix machine rather than the Internet.

> for the robot
> proccesses to communicate with the POE management process, which itself
> can communicate with the POE central server. I'm not very clear on how
> the servers will communicate. I want a permenant bidirectional
> connection, but I don't know if I can make a single TCP/IP connection
> with POE and have either server send data to the other to trigger
> events on the remote server.

I don't quite understand what you mean here... are you talking about the
slave servers communicating with each other, or only with the central
master server?

The way I would structure this would be to have each slave process (your
'POE management process') connect to a listening socket on the master
process (your 'POE central server'), and then communicate with it by
some protocol you define. It is perfectly possible to define the
protocol such that either end can initiate transactions: you just have
to be careful to make sure both ends don't try to speak at the same time
so the transactions get mixed up. It's worth putting some though into
the design of the protocol before you start programming: IMO HTTP/1.1 is
a good model to follow, but your situation is somewhat complicated by
the fact the either end can speak first.

> Likewise if the robot process and POE can
> monitor local sockets for bidirectional communication on teh same
> machine.

Well, yes. That's the point: to watch several filehandles for activity.
Whether the filehandles are AF_INET sockets, AF_UNIX sockets or whatever
doesn't matter: that's the point of the Unix filehandle abstraction.

>Any help is appreciated, including which modules I should look
> at. I've found a lot of books on robots, read some. And yes, I know
> what a monumental undertaking this is (I either have a lot of time or
> I'm a senseless dreamer, or both).

Heh. Good luck.

Ben

-- 
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ benmorrow@tiscali.co.uk ~            Jorge Luis Borges, 'The Babylon Lottery'


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

Date: 7 Oct 2006 21:49:46 -0700
From: ethandbrown@gmail.com
Subject: Google calendar interaction
Message-Id: <1160282986.382817.311280@k70g2000cwa.googlegroups.com>

Hi Group--

Has anyone succeeded in interacting with google calendars via Perl?
Google provides client libraries for Java, but not Perl.
I'm working with the Net::Google::Calendar module and am able
to connect and obtain calendar entries, but am not successful at
creating a new entry using the sample code provided by the module.

I'm getting a "401 Token invalid" error, which would lead me to
believe the problem is in either the feed url or the user/password,
but I can't seem to find a problem in either.

Thanks for any help,

--Ethan

Test code:
===========================================================================

#!/usr/bin/perl
##
##  Test for google calendar module using mostly sample module code.
##
use Net::Google::Calendar;
use DateTime;
use Data::Dumper;

use strict;
use warnings;

my $u = 'gmail_user;      ## Set this appropriately
my $p = 'gmail_password'; ## Ditto
my $url			  ## Ditto Ditto
  =
'http://www.google.com/calendar/feeds/your/feed/url/private-14292c8fa1bc2ae9619ff356c58ca445/full';


my $cal = Net::Google::Calendar->new( url => $url );
$cal->login($u, $p);

## This Works
for ($cal->get_events()) {
    print $_->title."\n";
    print $_->content->body."\n*****\n\n";
}

my $title = 'Fnord';
my $entry = Net::Google::Calendar::Entry->new();
$entry->title($title);
$entry->content("My content");
$entry->location('London, England');
$entry->transparency('transparent');
$entry->status('confirmed');
$entry->when(DateTime->now, DateTime->now() + DateTime::Duration->new(
hours => 6 ) );


my $author = Net::Google::Calendar::Person->new();
$author->name('Foo Bar');
$author->email('foo@bar.com');
$entry->author($author);

## This Fails
print "Trying to add the entry...\n";
my $tmp = $cal->add_entry($entry);
die "Couldn't add event: $@\n" unless defined $tmp;
print "Added the entry...\n";

print "Events=".scalar($cal->get_events())."\n";

$tmp->content('Updated');

$cal->update_entry($tmp) || die "Couldn't update ".$tmp->id.": $@\n";

$cal->delete_entry($tmp) || die "Couldn't delete ".$tmp->id.": $@\n";
===========================================================================

Result:
===========================================================================
ethan@strider:~/proj/wtgig/google_calendar$ ./testcal_basic.pl
Pelicans at La Grange
Dress:
	Gold Coats
	Blue coats
*****

Trying to add the entry...
Couldn't add event: 401 Token invalid - <HTML>
<HEAD>
<TITLE>Token invalid</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Token invalid</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
===========================================================================



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

Date: 8 Oct 2006 13:47:05 -0700
From: joubertb@gmail.com
Subject: Help with test program
Message-Id: <1160340425.190948.129880@e3g2000cwe.googlegroups.com>

I have been working on this for the past few days and still can't
figure out what I am doing wrong.

Below the my test program.  Can someone point out to me what I am doing
wong?

Thanks.

--joubert

===========================< cut here >===============================

package foobar;

sub new {
  my $class = shift;
  my $self = {};

  return bless $self, $class;
}

sub func {
  my $self = shift;
  my $param = shift;
  print "inside function\n";

  print "param=$param\n";

  return "zzzzz";
}


$f = new foobar;

my %myarray = (
          foo => { func => $f->func, }
  );
#
# When I do the above assignment, it calls the method $f->func.  What I
want it to do is assign the
# function pointer to func so that below I can call it.
#

#$myarray{foo}{func};
$xxx = $myarray{foo}{func}("abc123");
#
# When the function above is called, it says that "zzzzz" is does not
exist.  It looks like the return
# value from $f->func is assigned to $myarray{foo}{func}.
#
# What am I doing wrong ?



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

Date: Sun, 8 Oct 2006 23:17:23 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Help with test program
Message-Id: <slrneiiqn3.n82.hjp-usenet2@yoyo.hjp.at>

On 2006-10-08 20:47, joubertb@gmail.com <joubertb@gmail.com> wrote:
> I have been working on this for the past few days and still can't
> figure out what I am doing wrong.
>===========================< cut here >===============================
>
> package foobar;
[...]
> sub func {
>   my $self = shift;
>   my $param = shift;
>   print "inside function\n";
>
>   print "param=$param\n";
>
>   return "zzzzz";
> }
>
>
> $f = new foobar;
>
> my %myarray = (
>           foo => { func => $f->func, }
>   );
> #
> # When I do the above assignment, it calls the method $f->func.

Yes.

> # What I
> # want it to do is assign the
> # function pointer to func so that below I can call it.
> #
>
> #$myarray{foo}{func};
> $xxx = $myarray{foo}{func}("abc123");

If you want to call it like this (i.e., you don't want to call func on
any object, but always on $f), the best way is probably:

  my %myarray = (
            foo => { func => sub { $f->func(@_) }, }
    );

if you want to be able to call func on arbitrary objects, I'd just store
the name and let perl find the right method at call time:

  my %myarray = (
            foo => { func => 'func', }
    );

  my $f2 = new foobar;
  my $func = $myarray{foo}{func};
  $xxx = $f2->$func("abc123");

There are other ways ...

	hp


-- 
   _  | Peter J. Holzer    | > Wieso sollte man etwas erfinden was nicht
|_|_) | Sysadmin WSR       | > ist?
| |   | hjp@hjp.at         | Was sonst wäre der Sinn des Erfindens?
__/   | http://www.hjp.at/ |	-- P. Einstein u. V. Gringmuth in desd


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

Date: Sun, 8 Oct 2006 04:42:16 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Oct  8 2006
Message-Id: <J6svqG.oxr@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Bot-Pastebot-0.51
http://search.cpan.org/~rcaputo/Bot-Pastebot-0.51/
----
Curses-1.15
http://search.cpan.org/~giraffed/Curses-1.15/
terminal screen handling and optimization
----
DBD-mysql-3.0007_2
http://search.cpan.org/~capttofu/DBD-mysql-3.0007_2/
MySQL driver for the Perl5 Database Interface (DBI)
----
DBIx-ProcedureCall-0.10
http://search.cpan.org/~thilo/DBIx-ProcedureCall-0.10/
Perl extension to make database stored procedures look like Perl subroutines
----
Error-0.17006
http://search.cpan.org/~shlomif/Error-0.17006/
Error/exception handling in an OO-ish way
----
Exception-NoException-0.05
http://search.cpan.org/~jjore/Exception-NoException-0.05/
An exception object that's always false.
----
Getopt-Euclid-v0.0.8
http://search.cpan.org/~dconway/Getopt-Euclid-v0.0.8/
Executable Uniform Command-Line Interface Descriptions
----
HTML-Latemp-NavLinks-GenHtml-0.1.8
http://search.cpan.org/~shlomif/HTML-Latemp-NavLinks-GenHtml-0.1.8/
A module to generate the HTML of the navigation links.
----
HTML-Template-Compiled-0.79
http://search.cpan.org/~tinita/HTML-Template-Compiled-0.79/
Template System Compiles HTML::Template files to Perl code
----
Lemonldap-NG-Handler-0.11
http://search.cpan.org/~guimard/Lemonldap-NG-Handler-0.11/
Perl extension for building a Lemonldap compatible handler
----
Lemonldap-NG-Portal-0.1
http://search.cpan.org/~guimard/Lemonldap-NG-Portal-0.1/
Perl extension for building Lemonldap compatible portals
----
Lingua-Alphabet-Phonetic-0.053
http://search.cpan.org/~mthurn/Lingua-Alphabet-Phonetic-0.053/
map ABC's to phonetic alphabets
----
Math-Project3D-1.02
http://search.cpan.org/~smueller/Math-Project3D-1.02/
Project functions of multiple parameters from R^3 onto an arbitrary plane
----
Net-Stomp-0.30
http://search.cpan.org/~lbrocard/Net-Stomp-0.30/
A Streaming Text Orientated Messaging Protocol Client
----
Parse-Java-0.01_01
http://search.cpan.org/~claesjac/Parse-Java-0.01_01/
Parser for Java code
----
SMS-Send-US-SprintPCS-0.02
http://search.cpan.org/~jjore/SMS-Send-US-SprintPCS-0.02/
An SMS::Send driver for the messaging.sprintpcs.com website
----
Task-Catalyst-Tutorial-0.02
http://search.cpan.org/~jrockway/Task-Catalyst-Tutorial-0.02/
Installs everything you need to learn Catalyst
----
Test-Class-0.17
http://search.cpan.org/~adie/Test-Class-0.17/
Easily create test classes in an xUnit/JUnit style
----
Test-Run-CmdLine-0.0100_04
http://search.cpan.org/~shlomif/Test-Run-CmdLine-0.0100_04/
Analyze tests from the command line using Test::Run
----
Text-Same-0.06
http://search.cpan.org/~kim/Text-Same-0.06/
Look for similarities between files or arrays
----
WWW-Dict-v0.0.1
http://search.cpan.org/~gugod/WWW-Dict-v0.0.1/
Base class for WWW::Dict::* modules.
----
WWW-Mechanize-1.21_03
http://search.cpan.org/~petdance/WWW-Mechanize-1.21_03/
Handy web browsing in a Perl object
----
WWW-Mechanize-1.21_04
http://search.cpan.org/~petdance/WWW-Mechanize-1.21_04/
Handy web browsing in a Perl object


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 8 Oct 2006 08:22:20 -0700
From: weer1@gmx.net
Subject: Perl/OpenGL textures support
Message-Id: <1160320939.956784.313480@m7g2000cwm.googlegroups.com>

Can you tell me if textures are supported in Perl/OpenGL? I saw
MS-OpenGL-version is 1.1 so I guess it should work.
But I tried the command glGenTextures but that seems to be unsupported.

I use Perl 5.8 installed on Windows XP with the OpenGL-ppm from the
bribes-repository.

MD



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

Date: Sun, 8 Oct 2006 08:28:09 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.6 $)
Message-Id: <slrneihv79.df7.tadmc@magna.augustmail.com>

Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> [A complimentary Cc of this posting was sent to
> Tad McClellan 
><tadmc@augustmail.com>], who wrote in article <slrneif7pt.89h.tadmc@magna.augustmail.com>:
>> > This section assumes that faux pas are performed most often by
>> > newbies; 
> 
>> I'm not seeing that, and I don't see its relevance even if true.
> 
>> Asking a FAQ is bad manners whether you know that posting a FAQ
>> is bad manners or not.
> 
> It looks like you think in terms "this is right" or "this is wrong".
> I prefer to think in terms "what you want to achieve".  Rudeness is in
> the eyes of the beholder.
> 
> Asking a FAQ is a fact of life.  It may be "bad manners"; but
> currently "your" posting guidelines are *used as foundation* to
> proliferate this fact of life into a cascade of much worse manners.


What action can be taken to address the issue you raise?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 8 Oct 2006 21:32:09 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.6 $)
Message-Id: <egbqop$j5t$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Tad McClellan 
<tadmc@augustmail.com>], who wrote in article <slrneihv79.df7.tadmc@magna.augustmail.com>:
> > Asking a FAQ is a fact of life.  It may be "bad manners"; but
> > currently "your" posting guidelines are *used as foundation* to
> > proliferate this fact of life into a cascade of much worse manners.

> What action can be taken to address the issue you raise?

I was thinking about changing the tone of "Posting Guidelines".
[Of course, it is a hopeless battle, but anyway, one should exhaust
available resources before giving up...]

Yours,
Ilya


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

Date: Sun, 08 Oct 2006 16:38:34 -0400
From: Michael Goerz <news12@8439.e4ward.com>
Subject: print line number
Message-Id: <4ot5u2Fg5thiU1@uni-berlin.de>

Hi,

is there a way to print the line number of the line that is currently
executed in a perl script (similar to the $. variable), so that I can
use it in debugging messages, like this:

[... perl code ...]

$i = 5; print ('The value of $i changed to ', $i, "at line ",
$current_line, "\n") if $DEBUGGING;

[... perl code ...]

Thank,
Michael


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

Date: Sun, 08 Oct 2006 20:42:49 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: print line number
Message-Id: <Xns9856AA142A157asu1cornelledu@127.0.0.1>

Michael Goerz <news12@8439.e4ward.com> wrote in news:4ot5u2Fg5thiU1@uni-
berlin.de:

> is there a way to print the line number of the line that is currently
> executed in a perl script (similar to the $. variable), so that I can
> use it in debugging messages, like this:
> 
> [... perl code ...]
> 
> $i = 5; print ('The value of $i changed to ', $i, "at line ",
> $current_line, "\n") if $DEBUGGING;


You should not print debugging messages to STDOUT.

See perldoc -f warn

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

Date: 08 Oct 2006 20:43:24 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: print line number
Message-Id: <slrneiiomu.tqv.abigail@alexandra.abigail.be>

Michael Goerz (news12@8439.e4ward.com) wrote on MMMMDCCLXXXVI September
MCMXCIII in <URL:news:4ot5u2Fg5thiU1@uni-berlin.de>:
&&  Hi,
&&  
&&  is there a way to print the line number of the line that is currently
&&  executed in a perl script (similar to the $. variable), so that I can
&&  use it in debugging messages, like this:
&&  
&&  [... perl code ...]
&&  
&&  $i = 5; print ('The value of $i changed to ', $i, "at line ",
&&  $current_line, "\n") if $DEBUGGING;


print "The value of \$i changed to $i at line ", __LINE__, "\n";



Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: Sun, 08 Oct 2006 17:50:00 -0400
From: Michael Goerz <news12@8439.e4ward.com>
Subject: Re: print line number
Message-Id: <4ota3iFf71idU1@uni-berlin.de>

Abigail wrote:
 > print "The value of \$i changed to $i at line ", __LINE__, "\n";

Thanks, that exactly what I meant!

Michael


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

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 9820
***************************************


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