[25293] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7538 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 20 06:05:36 2004

Date: Mon, 20 Dec 2004 03:05:06 -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           Mon, 20 Dec 2004     Volume: 10 Number: 7538

Today's topics:
        [OT] Re: Net::NNTP, retrieving articles  help please... <zen13097@zen.co.uk>
        [threads] problem with subroutine lock (Michael Schmitt)
    Re: change mac address formatting in a regex <do-not-use@invalid.net>
    Re: Labels not displayed when using Win32::MsgBox, more <1usa@llenroc.ude.invalid>
    Re: Newbie question <noreply@gunnar.cc>
    Re: Newbie question <1usa@llenroc.ude.invalid>
    Re: Newbie question <do-not-use@invalid.net>
    Re: Page can not be displayed... <1usa@llenroc.ude.invalid>
        Parsing Large Files <ihatespam@hotmail.com>
    Re: Parsing Large Files (Anno Siegel)
        Parsing <ihatespam@hotmail.com>
    Re: Parsing <posted@cyberpomo.com>
        Perl - User Agnet ( Problem while acessing site ) mnrao13@yahoo.com
    Re: Perl - User Agnet ( Problem while acessing site ) <spamtrap@dot-app.org>
    Re: problem creating string from list <wyzelli@yahoo.com>
    Re: problem creating string from list (Anno Siegel)
    Re: why the following HereDoc print don't work? <spamtrap@dot-app.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 20 Dec 2004 08:38:37 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: [OT] Re: Net::NNTP, retrieving articles  help please.......thanks that worked
Message-Id: <41c68f8d$0$8347$db0fefd9@news.zen.co.uk>

On Fri, 17 Dec 2004 15:45:19 GMT, jbl <j.b.l.0.2> wrote:
<nothing of any consequence>

If you *must* post a message which is just a "thanks that worked",
then please put your comments in the *body* of the article where they belong,
not in the subject.

Quoting an entire post just to add words to the subject is ... well,
not very nice.

Thank you for your future co-operation.


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

Date: 20 Dec 2004 02:09:49 -0800
From: michi200004@yahoo.de (Michael Schmitt)
Subject: [threads] problem with subroutine lock
Message-Id: <d0b611a5.0412200209.2c7e5db5@posting.google.com>

I want a subroutine Lock. I tried use attrs qw(locked); but i didnt
work, all thread run into the sub. Now I tried to use semaphores
instead like this;

#!/usr/bin/perl -w

use Thread;
use Thread::Semaphore; 

$sem = Thread::Semaphore->new(); 

sub dprint {
my $param = shift;
$sem->down;
    print("Thread $param started\n");
    sleep(5);
    print("Thread $param ends\n");
$sem->up; 
}


$thread1 = new Thread \&dprint, t1; 
$thread2 = new Thread \&dprint, t2;

$thread1->join();
$thread2->join();
exit();



I want
thread1 started
thread1 ends
thread2 started
thread2 ends

But i alway get
thread1 started
thread2 started
thread1 ends
thread2 ends


What is wrong here?


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

Date: 20 Dec 2004 10:15:03 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: change mac address formatting in a regex
Message-Id: <yzdekhljppk.fsf@invalid.net>


Uri Guttman <uri@stemsystems.com> writes:
> >>>>> "en" == edward nigma <edward.nigma@gmail.com> writes:
> 
>   en> Good evening... I'm trying to construct a way to transform a mac
>   en> address written in this format...
> 
>   en> 0:3:e2:12:4e:54
> 
>   en> To this:
> 
>   en> 0003E2124E54
> 
>   en> I have different methods of doing this using loops that delimit the
>   en> data already in place, but I now need to be able to do this through a
>   en> single regular expression and it seems there should be a way!
> 
> [...]
> 	$mac =~ s/(\w+):?/sprintf '%02x', hex $1/ge ;
> 
> 	$mac = join '', map { sprintf '%02x', hex $_ } split /:/, $mac ;
> 
> now for the gang: let's see how many fun ways there are to do this.

I put in the uppercasing too.

        $mac =~ s/(\w+):?/substr "\U0$1", -2/eg;

        $mac =~ s/(\w+):?/"0" x (2-length $1) . "\U$1"/ge;

The second one is not so robust - it assumes there are no redundant
leading zeroes.


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

Date: 20 Dec 2004 08:36:16 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Labels not displayed when using Win32::MsgBox, more information provided
Message-Id: <Xns95C524ABB6FE6asu1cornelledu@132.236.56.8>

hurlu.berlue@laposte.net (hurluberlu) wrote in 
news:d9b80c0c.0412192350.74cc7306@posting.google.com:

> open a command prompt and run the folowwing command :
> 
> perl -MWin32 -e "Win32::MsgBox('My Question', 1, 'My Title')"
> 
> on all PC (WIN XP, WIN NT, WIN 2000) it works but on PC with WIN XP it
> is displaying only the box: Any Text is displayed.

I don't understand the problem description above. Running the command 
line you gave resulted in a message box with the title 'My Title' which 
had a label 'My Question' with two buttons: OK and Cancel.

Win XP SP2

C:\Home> perl -v

This is perl, v5.8.6 built for MSWin32-x86-multi-thread
(with 3 registered patches, see perl -V for more detail)

Copyright 1987-2004, Larry Wall

Binary build 811 provided by ActiveState Corp. http://www.ActiveState.com

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



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

Date: Mon, 20 Dec 2004 08:59:13 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Newbie question
Message-Id: <32ng94F3ns0soU1@individual.net>

Petterson Mikael wrote:
> I am trying to run the following perl script but I cannot
> get it to compile. I get the following error:
> 
> "my" variable $msg masks earlier declaration in same scope at
> run_dtest.pl line 34.
> syntax error at run_dtest.pl line 33, near "sub printWARNING "
> Can't use global @_ in "my" at run_dtest.pl line 34, near "=$_"
> syntax error at run_dtest.pl line 38, near "}"
> Execution of run_dtest.pl aborted due to compilation errors.

Take a look at the statement right *before* line 33, and you'll find the 
explanation.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 20 Dec 2004 08:38:53 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Newbie question
Message-Id: <Xns95C5251D3234Aasu1cornelledu@132.236.56.8>

Petterson Mikael <mikael.petterson@ericsson.se> wrote in news:cq5vfs$a52
$1@newstree.wise.edt.ericsson.se:

> I am trying to run the following perl script but I cannot
> get it to compile. I get the following error:
> 
> "my" variable $msg masks earlier declaration in same scope at 
> run_dtest.pl line 34.
> syntax error at run_dtest.pl line 33, near "sub printWARNING "
> Can't use global @_ in "my" at run_dtest.pl line 34, near "=$_"
> syntax error at run_dtest.pl line 38, near "}"
> Execution of run_dtest.pl aborted due to compilation errors.
 ...
> ####################### SCRIPT #######################
> 
> #!/usr/local/bin/perl -w

#!/usr/local/bin/perl

> # turn on perl's safety features
> use strict;
> #use warning;

use warnings;

 ...

> # Main
> 
> prepare

What is this?


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



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

Date: 20 Dec 2004 10:23:40 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Newbie question
Message-Id: <yzdacs9jpb7.fsf@invalid.net>


Petterson Mikael <mikael.petterson@ericsson.se> writes:
> I am trying to run the following perl script but I cannot
> get it to compile. I get the following error:
> 
> 
> "my" variable $msg masks earlier declaration in same scope at
> run_dtest.pl line 34.
> syntax error at run_dtest.pl line 33, near "sub printWARNING "
> Can't use global @_ in "my" at run_dtest.pl line 34, near "=$_"
> syntax error at run_dtest.pl line 38, near "}"
> Execution of run_dtest.pl aborted due to compilation errors.
> [...]

I suggest using just "perl -c" to check the syntax, and stripping off
things from your script until the error messages change or
disappear. By then it may be obvious what the syntax error is.


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

Date: 20 Dec 2004 08:41:24 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Page can not be displayed...
Message-Id: <Xns95C5258ADE45asu1cornelledu@132.236.56.8>

PietLaroy@hotmail.com (Piet L.) wrote in 
news:c47f81f6.0412192112.cb1f6fc@posting.google.com:

> I think I found the problem.
> When I run the dbi execute I get a lot of these warnings:
> Use of uninitialized value in string eq at
> c:/perl/site/lib/XML/Generator/DBI.pm line 180.
> Use of uninitialized value in string eq at
> c:/perl/site/lib/XML/Generator/DBI.pm line 187.
> 
> If I try the code without the fetch record, there is no problem.
> But clearly there must be a problem with the sql / dbi or so.
> 
> still help needed :-((

Please ponder the responses you have received so far. Re-reading the 
posting guidelines might help.

Otherwise, make sure to fix the error on line 142, otherwise your script 
will not work.

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



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

Date: Wed, 15 Dec 2004 04:30:00 -0800
From: BigDaDDY <ihatespam@hotmail.com>
Subject: Parsing Large Files
Message-Id: <10sd5h9k714qh08@corp.supernews.com>

All,

I recently received a reply to a previous post which is almost the answer I 
needed.  The problem is, when I tried it at work, it wouldn't work.  The 
reason it didn't work was because we have an early version of Perl at work 
which does not support "values" as in:

my(%nid, %id);

foreach (values %id) {
  foreach my $y (keys %$_) {
     foreach (values %{$_->{$y}}) {
        die "duplicate $_!" if exists $nid{$_};
        $nid{$_}=$y;
     }
  }
}

Can this be done in a different way that doesn't use values?  Also, I do 
care about the x-values as well, so I don't think the code above will work 
as is.  Basically, I'm parsing one file to get an ID given an x,y,z 
cartesian coordinate.  This gives me the hash %id which is keyed by 
{"x"}{"y"}{"z"} coordinates, whose values are id numbers.  Then I close 
this file, and open a large results file which only contains ids with 
results.  I want to pull out all values for a unique y into a separate file 
and sort them by x ascending.  Each id occurs 21 times in the large file 
for a total of 21 subcases.  I want them printed as in:

id    value(subcase1)  value(subcase2) value(subcase3) . . .
 .
 .
 .
id's ordered by x ascending in a file for a unique value of y.

Any help would be greatly appreciated.




Re: Parsing Huge Files

From:

xhoster@gmail.com

Date:

Thursday 09 December 2004 03:04:10 pm

Groups:

comp.lang.perl.misc



References: 1



BigDaDDY <ihatespam@hotmail.com> wrote:
> All,
>
> I have a huge text file (around 700MB) that I am trying to parse.

Whether that is huge depends on your RAM.  I just might be able to throw
that into a big old hash and work with it that way.  Can you?

> I was
> successful, but I don't think I have done it very efficiently.

What kind of efficiency are you concerned with?  CPU, memory, programmer
time, maintainer time?

> Basically
> in my program I have a hash containing some unique id numbers which are
> keyed by cartesian (x,y,z) coordinates.
>
> #!/usr/bin/perl -w
>
> use strict;
>
> my %id;
>
> $id{"200"}{"-11"}{"199.5"} = 123456;
> $id{"201"}{"-11"}{"199.5"} = 246891;
> $id{"202"}{"-11"}{"199.5"} = 169245;
> $id{"200"}{"-45"}{"199.5"} = 274321;
>
> # End of example code
>
> Here is where it is getting difficult for me.  I have 8 possible
> y-values, 420 x-values and 1 z-value

If there is only one possible z-value, what is the point of having a
z-value?

1*8*420 = 3360 different IDs (assuming all are different)

It seems like you only really care about the Y value of any given ID,
and not the X or Z.
So invert and prune the hashes so that $nid{123456}="-11", etc.

my %nid;

foreach (values %id) {
  foreach my $y (keys %$_) {
     foreach (values %{$_->{$y}}) {
        die "duplicate $_!" if exists $nid{$_};
        $nid{$_}=$y;
     }
  }
}


> The format of my 700MB file is something like
>
> #ID             Value
> 123456          200
> 274321          100
> 246891          400
> 169245          600
> 123456          300
> 274321          50
> 246891          600 #each element id occurs 24 times once for each
> subcase

Well then, I assume the subcases must occur in order?

3360 different IDs, times 24 occurences, = 80640 lines you care about.
Out of 700MB/15char per line = 50 million lines.

You can surely store 80640 lines, no?


> What I want to do is for each unique y value, I want to create a file
> named after each y-value which looks like the following
>
> element ID      Value(subcase1) Value(subcase2) Value(subcase3) . . .
> 123456          200             300     400
> 246891          400             600     800
> 169245          600             800     999
>
> So basically, given a fixed y and z value, loop over all x values and get
> element ids which are then searched for in the big file and reformatted
> into individual files for each unique y-value.  Is there a very efficient
> way to do this in Perl?

my %y_stuff; # hash by Y of hash by ID of list of values
while (<>) { chomp;
  my ($id,$v)=split;
  next unless exists $nid{$id};
  push @{$y_stuff{$nid{$id}}{$id}}, $v;
};

Printing this out is left as an exercise.

Xho




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

Date: 20 Dec 2004 10:06:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Parsing Large Files
Message-Id: <cq6870$itc$1@mamenchi.zrz.TU-Berlin.DE>

BigDaDDY  <ihatespam@hotmail.com> wrote in comp.lang.perl.misc:
> All,
> 
> I recently received a reply to a previous post which is almost the answer I 
> needed.  The problem is, when I tried it at work, it wouldn't work.  The 

Wouldn't work, eh?  So what is the error you get, or in which way is the
result different from what you expect?  

> reason it didn't work was because we have an early version of Perl at work 
> which does not support "values" as in:
> 
> my(%nid, %id);
> 
> foreach (values %id) {
>   foreach my $y (keys %$_) {
>      foreach (values %{$_->{$y}}) {
>         die "duplicate $_!" if exists $nid{$_};
>         $nid{$_}=$y;
>      }
>   }
> }

"values" works since Perl 1 (and I don't see them used as lvalues).  So
what's the error?  Please don't waste our time.

Anno


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

Date: Mon, 20 Dec 2004 01:36:31 -0800
From: BigDaDDY <ihatespam@hotmail.com>
Subject: Parsing
Message-Id: <10sd759fqdmeicc@corp.supernews.com>





Parsing Large Files
All,

I recently received a reply to a previous post which is almost the answer I 
needed.  The problem is, when I tried it at work, it wouldn't work.  The 
reason it didn't work was because we have an early version of Perl at work 
which does not support "values" as in:

my(%nid, %id);

foreach (values %id) {
  foreach my $y (keys %$_) {
     foreach (values %{$_->{$y}}) {
        die "duplicate $_!" if exists $nid{$_};
        $nid{$_}=$y;
     }
  }
}

Can this be done in a different way that doesn't use values?  Also, I do 
care about the x-values as well, so I don't think the code above will work 
as is.  Basically, I'm parsing one file to get an ID given an x,y,z 
cartesian coordinate.  This gives me the hash %id which is keyed by 
{"x"}{"y"}{"z"} coordinates, whose values are id numbers.  Then I close 
this file, and open a large results file which only contains ids with 
results.  I want to pull out all values for a unique y into a separate file 
and sort them by x ascending.  Each id occurs 21 times in the large file 
for a total of 21 subcases.  I want them printed as in:

id    value(subcase1)  value(subcase2) value(subcase3) . . .
 .
 .
 .
id's ordered by x ascending in a file for a unique value of y.

Any help would be greatly appreciated.




Re: Parsing Huge Files

From:

xhoster@gmail.com

Date:

Thursday 09 December 2004 03:04:10 pm

Groups:

comp.lang.perl.misc



References: 1



BigDaDDY <ihatespam@hotmail.com> wrote:
> All,
>
> I have a huge text file (around 700MB) that I am trying to parse.

Whether that is huge depends on your RAM.  I just might be able to throw
that into a big old hash and work with it that way.  Can you?

> I was
> successful, but I don't think I have done it very efficiently.

What kind of efficiency are you concerned with?  CPU, memory, programmer
time, maintainer time?

> Basically
> in my program I have a hash containing some unique id numbers which are
> keyed by cartesian (x,y,z) coordinates.
>
> #!/usr/bin/perl -w
>
> use strict;
>
> my %id;
>
> $id{"200"}{"-11"}{"199.5"} = 123456;
> $id{"201"}{"-11"}{"199.5"} = 246891;
> $id{"202"}{"-11"}{"199.5"} = 169245;
> $id{"200"}{"-45"}{"199.5"} = 274321;
>
> # End of example code
>
> Here is where it is getting difficult for me.  I have 8 possible
> y-values, 420 x-values and 1 z-value

If there is only one possible z-value, what is the point of having a
z-value?

1*8*420 = 3360 different IDs (assuming all are different)

It seems like you only really care about the Y value of any given ID,
and not the X or Z.
So invert and prune the hashes so that $nid{123456}="-11", etc.

my %nid;

foreach (values %id) {
  foreach my $y (keys %$_) {
     foreach (values %{$_->{$y}}) {
        die "duplicate $_!" if exists $nid{$_};
        $nid{$_}=$y;
     }
  }
}


> The format of my 700MB file is something like
>
> #ID             Value
> 123456          200
> 274321          100
> 246891          400
> 169245          600
> 123456          300
> 274321          50
> 246891          600 #each element id occurs 24 times once for each
> subcase

Well then, I assume the subcases must occur in order?

3360 different IDs, times 24 occurences, = 80640 lines you care about.
Out of 700MB/15char per line = 50 million lines.

You can surely store 80640 lines, no?


> What I want to do is for each unique y value, I want to create a file
> named after each y-value which looks like the following
>
> element ID      Value(subcase1) Value(subcase2) Value(subcase3) . . .
> 123456          200             300     400
> 246891          400             600     800
> 169245          600             800     999
>
> So basically, given a fixed y and z value, loop over all x values and get
> element ids which are then searched for in the big file and reformatted
> into individual files for each unique y-value.  Is there a very efficient
> way to do this in Perl?

my %y_stuff; # hash by Y of hash by ID of list of values
while (<>) { chomp;
  my ($id,$v)=split;
  next unless exists $nid{$id};
  push @{$y_stuff{$nid{$id}}{$id}}, $v;
};

Printing this out is left as an exercise.

Xho



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

Date: Mon, 20 Dec 2004 11:17:12 +0100
From: Calle Dybedahl <posted@cyberpomo.com>
Subject: Re: Parsing
Message-Id: <86acs9clzr.fsf@ulthar.bisexualmenace.org>

>>>>> "BigDaDDY" == BigDaDDY  <ihatespam@hotmail.com> writes:

> The reason it didn't work was because we have an early version of
> Perl at work which does not support "values" as in:

The values() function has been in perl since perl version 1. I very
much doubt that is your problem. If you give actual error messages
instead of your misinterpretations of them, maybe someone can help you.
-- 
		     Calle Dybedahl <calle@cyberpomo.com>
		 http://www.livejournal.com/users/cdybedahl/
    "Rational thought. It's an acquired taste." -- Gunn, Angel: the Series


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

Date: 20 Dec 2004 02:02:04 -0800
From: mnrao13@yahoo.com
Subject: Perl - User Agnet ( Problem while acessing site )
Message-Id: <1103536924.253714.17960@f14g2000cwb.googlegroups.com>

Hi,
When i am trying to acess the the following
through user agent. I am not getting the response
properly.
URL:- https://accessnet.state.nj.us/home.asp
Code:-

$ua = LWP::UserAgent->new(agent =>'Mozilla/4.0
(compatible; MSIE 5.01; Windows NT 5.0)',
timeout => 45,

requests_redirectable => ['GET', 'HEAD', 'POST']);
$ua->cookie_jar($cookie_jar_tmp);

my $req = HTTP::Request->new(GET =>
'https://accessnet.state.nj.us/home.asp');
# send request
my $res = $ua->request($req);
my $r = $res;
my @redirects;
while ($r) {
$res = $r;
$r = $r->previous;
push (@redirects, $res) if $r;
}

print $res->as_string;

I am not getting the reason where i am failing. Please
help me out to acess the given URL through perl.

Thanks 
Nageswara Rao.



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

Date: Mon, 20 Dec 2004 05:33:34 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Perl - User Agnet ( Problem while acessing site )
Message-Id: <2fSdne4moKziN1vcRVn-hQ@adelphia.com>

mnrao13@yahoo.com wrote:

> through user agent. I am not getting the response
> properly.

Ask the response object what the problem is:

> my $res = $ua->request($req);

unless ($res->is_success()) {
     die $res->status_line;
}

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Mon, 20 Dec 2004 09:58:52 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: problem creating string from list
Message-Id: <wnxxd.81635$K7.22026@news-server.bigpond.net.au>

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message 
news:32lc8oF3o0k30U1@individual.net...
: Peter Wyzl wrote:
: > I have been playing around with this for a while now and am clearly 
missing
: > something...
: >
: > __SAMPLE__
: >
: > #!/usr/bin/perl -w
: > use strict;
: >
: > my $word = 'foobar';
: >
: > my $string = substr $word,0,1;
: > $string = join '|', $string, substr $word,0,$_ for 2..length $word;
: >
: > print $string;
:
: You may be missing that what's happening can be written as:
:
:     my $string = substr $word,0,1;
:     for ( 2..length $word ) {
:         $string = join '|', $string, substr $word,0,$_;
:     }

Thats the clue I needed!  I was considering the 4 argument issue which is 
why I came up against the syntax errors while trying the parens.

If I were using it myself I would have probably gone the map route, but it 
was more about trying to understand what _was_ and _wasn't_ happening in the 
loop.

I also ran into an interesting scoping problem whilst playing with this.

I am well aware that

foreach my $var (@array){
    #ya ya
}

has $var limited to the scope of the loop.

I ran into the unexpected situation where  I had an unexpectedly short scope 
with the same construct:

my $path .= ",DC=$_" for split '\.', $fqdn;

$path was empty after the line, where pre-declaring $path as in

my $path;
$path .= ",DC=$_" for split '\.', $fqdn;

Works fine!

I assume that is more equivalent to

for (split '\.', $fqdn){
    my $path .= ",DC=$_";
}

where once out of the loop $path is out of scope.

I can see I have a lot to learn yet... :)

-- 
Wyzelli 




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

Date: 20 Dec 2004 10:21:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: problem creating string from list
Message-Id: <cq693s$itc$2@mamenchi.zrz.TU-Berlin.DE>

Peter Wyzl <wyzelli@yahoo.com> wrote in comp.lang.perl.misc:

[...]

> I ran into the unexpected situation where  I had an unexpectedly short scope 
> with the same construct:
> 
> my $path .= ",DC=$_" for split '\.', $fqdn;
> 
> $path was empty after the line, where pre-declaring $path as in
> 
> my $path;
> $path .= ",DC=$_" for split '\.', $fqdn;
> 
> Works fine!

That's simple.  You can't declare a lexical variable under the influence
of a statement modifier, by penalty of an undefined result.

> I assume that is more equivalent to
> 
> for (split '\.', $fqdn){
>     my $path .= ",DC=$_";
> }

Not really.  Here you have a defined scope, and $path is known within
it, but not outside.  That's perfectly legal and reasonable daily
practice.

The scope of a lexical declared in a statement modifier (if it were
allowed), would have to be the surrounding scope.  There is no inner
block it could be confined to.

Anno


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

Date: Mon, 20 Dec 2004 03:43:58 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: why the following HereDoc print don't work?
Message-Id: <eaqdnWPgi7RSDVvcRVn-sA@adelphia.com>

Gunnar Hjalmarsson wrote:

> But that has nothing to do with the Perl compiler complaining about the
> *file* syntax, has it? It's complaining because the here-document syntax
> requires a line that matches /^EOF\n\z/ (assuming that the terminating
> string happens to be 'EOF'...), right?

That sounds right, yes. No other part of perl fails in this manner, as 
far as I've found. Ordinary statements are parsed just fine if they 
appear at the end of a file.

It appears to me that the lexer is failing to match a here-doc token 
when the terminating delimiter is at the end of the file. Since it 
doesn't fail when other statements appear at the end of the file, I'm 
assuming it's a bug in perl.

I'm going to verify this with the latest Perl before I file a perlbug - 
I need to upgrade anyway. And I'll try to be a good citizen and follow 
it up with a patch to p5p, if I can manage to create one.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

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


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