[31194] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2439 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 24 16:09:45 2009

Date: Sun, 24 May 2009 13:09:11 -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, 24 May 2009     Volume: 11 Number: 2439

Today's topics:
        &sub qw(1 2); QoS@invalid.net
    Re: &sub qw(1 2); <tadmc@seesig.invalid>
    Re: ampersand subroutine <1usa@llenroc.ude.invalid>
    Re: comma operator <frank@example.invalid>
    Re: comma operator <kst-u@mib.org>
    Re: edit array in place <uri@StemSystems.com>
        Here document <a@a.com>
    Re: Here document <noreply@gunnar.cc>
    Re: Here document <tadmc@seesig.invalid>
    Re: Here document <1usa@llenroc.ude.invalid>
    Re: Here document <a@a.com>
    Re: Here document <uri@StemSystems.com>
    Re: Here document <1usa@llenroc.ude.invalid>
    Re: Here document <1usa@llenroc.ude.invalid>
    Re: Here document <ben@morrow.me.uk>
    Re: Here document <someone@example.com>
    Re: Here document <1usa@llenroc.ude.invalid>
        problem running Convert::ASN1 on Windows XP <terra1024@yahoo.com>
    Re: problem running Convert::ASN1 on Windows XP <1usa@llenroc.ude.invalid>
    Re: problem running Convert::ASN1 on Windows XP <ben@morrow.me.uk>
    Re: problem running Convert::ASN1 on Windows XP <1usa@llenroc.ude.invalid>
    Re: problem running Convert::ASN1 on Windows XP <frank@example.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 24 May 2009 14:00:33 GMT
From: QoS@invalid.net
Subject: &sub qw(1 2);
Message-Id: <5qcSl.407$9L2.16@nwrddc02.gnilink.net>


Hi,

How come this works:

&ezmenu qw(
  ++ Action Lookup Cancel -- Exit
  ++ Edit Cut Copy Paste
  ++ Logfile View Save -- Clear
  ++ Options Font Color
  ++ Help Help About
);

But this produces syntax error:

ezmenu qw(
  ++ Action Lookup Cancel -- Exit
  ++ Edit Cut Copy Paste
  ++ Logfile View Save -- Clear
  ++ Options Font Color
  ++ Help Help About
);

Is this a feature of using & vs invoking a sub without & ?

Thanks,

Jason




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

Date: Sun, 24 May 2009 09:28:36 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: &sub qw(1 2);
Message-Id: <slrnh1imck.ro6.tadmc@tadmc30.sbcglobal.net>

QoS@invalid.net <QoS@invalid.net> wrote:


> How come this works:
>
> &ezmenu qw(
>   ++ Action Lookup Cancel -- Exit
>   ++ Edit Cut Copy Paste
>   ++ Logfile View Save -- Clear
>   ++ Options Font Color
>   ++ Help Help About
> );
>
> But this produces syntax error:
>
> ezmenu qw(
>   ++ Action Lookup Cancel -- Exit
>   ++ Edit Cut Copy Paste
>   ++ Logfile View Save -- Clear
>   ++ Options Font Color
>   ++ Help Help About
> );
>
> Is this a feature of using & vs invoking a sub without & ?


Kinda sorta.

If you want to omit the ampersand and omit parenthesis, then you must 
pay attention to this from perlsub:

     NAME LIST;     # Parentheses optional if predeclared/imported.

You have omitted the parenthesis but you have NOT predeclared/imported.

Either pre_define_ ezmenu() before you call it:

    sub ezmenu {
        # do stuff
    }
    ...
    ezmenu qw( ... );

or, pre_declare_ ezmenu() before you call it:

    sub ezmenu;
    ...
    ezmenu qw( ... );
    ...
    sub ezmenu {
        # do stuff
    }

or, don't omit the parenthesis:

    ezmenu (qw( ... ));

but in that case, I'd chose some qw delimiter other than parens:

    ezmenu (qw/ ... /);


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Sun, 24 May 2009 11:35:51 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: ampersand subroutine
Message-Id: <Xns9C154D54C7F4Easu1cornelledu@127.0.0.1>

Eric Pozharski <whynot@pozharski.name> wrote in 
news:slrnh1i1sd.85m.whynot@orphan.zombinet:

> On 2009-05-23, A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:

>> I think this is more expressive:
>>
>> $ perl -Mstrict -wle 'no attributes -to_like => exit [ keel => pos ]'
> 
> Didn't get it.

Well, the code is nonsense and there is nothing to 'get' Perl-wise.

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://www.rehabitation.com/clpmisc/


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

Date: Sun, 24 May 2009 11:57:47 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: comma operator
Message-Id: <91qwd6i7yh75$.14mcuetb7bkx4.dlg@40tude.net>

In Dread Ink, the Grave Hand of Ike Naar Did Inscribe:

> In article <147sccjewm360.1r5rg3qzs0r3f.dlg@40tude.net>,
> Franken Sense  <frank@example.invalid> wrote:

[x-posted to clp.misc]
>>jk2.c:26: warning: value computed is not used
>>
>>Line 26 is
>>e = 1 , 2 , 3;
> 
> A little experimentation shows that the warning is given for
> the ``2'' expression.
> No idea why it's the only expression that triggers this warning.
> Does it really matter?

I wonder whether this is something that has been baffling me for as long as
I've been looking at source in C-like languages, as with the following:

my ($since, @arts)=time-10*60*60;
  for (reverse $first..$last) {
      my %hdr=map /^(\S[^:]+):\s(.*)$/g, @{$nntp->head($_)};
      defined(my $date=$hdr{'NNTP-Posting-Date'}) or next;
      defined(my $time=str2time $date)
        or warn "Couldn't parse date for article $_ ($date)\n"
        and next;
      last if $time < $since;
      unshift @arts, $_;
  }

I think this is an example of the comma operator that purports to be the
same as C's.  I think it puts RHS into the scalar $since and simply
declares @arts as an array.

I'm also still scratching my head with this from n1256.pdf:

The left operand of a comma operator is evaluated as a void expression;
there is a sequence point after its evaluation. Then the right operand is
evaluated; the result has its type and value.

Do any of the examples posted show this as a distinction that matters?
-- 
Frank

I would never ordinally say this, but... is there any way you can get to a
pound cake?
~~ Al Franken


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

Date: Sun, 24 May 2009 11:17:27 -0700
From: Keith Thompson <kst-u@mib.org>
Subject: Re: comma operator
Message-Id: <lniqjq2wnc.fsf@nuthaus.mib.org>

Franken Sense <frank@example.invalid> writes:
[...]
> I wonder whether this is something that has been baffling me for as long as
> I've been looking at source in C-like languages, as with the following:
>
> my ($since, @arts)=time-10*60*60;
>   for (reverse $first..$last) {
>       my %hdr=map /^(\S[^:]+):\s(.*)$/g, @{$nntp->head($_)};
>       defined(my $date=$hdr{'NNTP-Posting-Date'}) or next;
>       defined(my $time=str2time $date)
>         or warn "Couldn't parse date for article $_ ($date)\n"
>         and next;
>       last if $time < $since;
>       unshift @arts, $_;
>   }
>
> I think this is an example of the comma operator that purports to be the
> same as C's.  I think it puts RHS into the scalar $since and simply
> declares @arts as an array.

I see no comma operator in that Perl code.  (I see things I would have
done differently, but I won't get into that in comp.lang.c.)

> I'm also still scratching my head with this from n1256.pdf:
>
> The left operand of a comma operator is evaluated as a void expression;
> there is a sequence point after its evaluation. Then the right operand is
> evaluated; the result has its type and value.
>
> Do any of the examples posted show this as a distinction that matters?

What distinction are you referring to?  Distinction between what and
what, exactly?

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"


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

Date: Sun, 24 May 2009 11:43:35 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: edit array in place
Message-Id: <87k54633rs.fsf@quad.sysarch.com>

>>>>> "EP" == Eric Pozharski <whynot@pozharski.name> writes:

  EP> On 2009-05-23, Uri Guttman <uri@StemSystems.com> wrote:

  >> no, but it isn't always easy. i use localized globs for handles, i have
  >> to custom make some constants (fctnl stuff) that weren't always
  >> available back then. and new releases need to be tested against older
  >> perls. the reason is that slurp is fairly popular and used by some who
  >> can't/won't upgrade their perl.

  EP> Yes, I see.  You seem to be pretty responsible.  I hope that one day
  EP> you'll fail, and then start to care more about alives then some
  EP> fictious fairies what can't/won't upgrade.

most of the needs for backwards compat are done and won't need
maintenance so there is no reason to not keep doing it.

  EP> p.s.  BTW, why you don't check return value of B<binmode>?

email it in and i will add it to my todo list. one issue with checking
perl funcs and syscalls is testing them. i just recently found a way to
test failure of sysread/syswrite using CORE:: and overriding those calls
in the tests. amusing but very simple code. it is in the git repo i
think and will be in the next release (whenever). that is due when i
finish this batch of patches and new tests.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Sun, 24 May 2009 21:02:50 +0700
From: michael20545 <a@a.com>
Subject: Here document
Message-Id: <gvbk2b$2fme$2@adenine.netfront.net>

my $j=0;
print <<END1;
$j
END1

Can I interpolate ,for example, $j+2 in here document? Or I must ever 
create additional variable?


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

Date: Sun, 24 May 2009 16:14:58 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Here document
Message-Id: <77t333F1g9a3eU1@mid.individual.net>

michael20545 wrote:
> my $j=0;
> print <<END1;
> $j
> END1
> 
> Can I interpolate ,for example, $j+2 in here document?

$ perl -e '
print <<END1;
@{[ $j+2 ]}
END1
'
2
$

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


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

Date: Sun, 24 May 2009 09:39:03 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Here document
Message-Id: <slrnh1in07.ro6.tadmc@tadmc30.sbcglobal.net>

michael20545 <a@a.com> wrote:
> my $j=0;
> print <<END1;
> $j
> END1
>
> Can I interpolate ,for example, $j+2 in here document? 


You _can_, but it is a Very Bad Idea for maintenance reasons.

You can do it using the method given in the answer to this FAQ:

    How do I expand function calls in a string?

Which works even though you want to expand an expression rather than
a function call (which is just a particular kind of expression).


e.g.

print <<END1;
@{[ $j+2 ]}
END1

but that is too homely to behold.

Note that here docs are nothing more than an alternative way of
specifying a string. This does the same thing:

    print "@{[$j+2 ]}";

and that in turn, does the same as either

    print $j+2;

or

    $j_inc = $j + 2;
    print $j_inc;

or

    $j_inc = $j + 2;
    print "$j_inc";


> Or I must ever 
> create additional variable?


That is what I would recommend instead of the shenanigans I gave above.

It may be even better to use a real templating system rather than
invent yet another one based on here docs.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Sun, 24 May 2009 16:07:51 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Here document
Message-Id: <Xns9C157B721A071asu1cornelledu@127.0.0.1>

michael20545 <a@a.com> wrote in news:gvbk2b$2fme$2@adenine.netfront.net:

> my $j=0;
> print <<END1;
> $j
> END1
> 
> Can I interpolate ,for example, $j+2 in here document? Or I must ever 
> create additional variable?

You could use (s)printf to make it more readable in case the heredoc is 
long (which I presume is the case) and you have only a few 
substitutions. Note that any % signs that appear in the heardoc will 
have to be escaped as %% if the string is going to be used as a format 
argument to sprintf.

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

my $j = 0;

my $template = <<EO_TMPL;
%d
EO_TMPL

printf $template, $j + 2;

__END__

But why not use a proper templating module? My favorite is 
HTML::Template which you can use for things other than HTML. 
Alternatively, there is Text::Template, Template, Template::Simple and a 
bazillion others which have already solved the problem you are trying to 
solve and at least one of them is bound to fit with your personal style.

-- 
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://www.rehabitation.com/clpmisc/


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

Date: Mon, 25 May 2009 00:38:18 +0700
From: michael20545 <a@a.com>
Subject: Re: Here document
Message-Id: <gvc0me$6g9$1@adenine.netfront.net>

Tad J McClellan пишет:

> 
> It may be even better to use a real templating system rather than
> invent yet another one based on here docs.
> 
> 

Thank you for assistance. In my case (I create many gnuplot scripts with 
Perl), IMO, is better to write:

print OUTFILE <<END1
 ...
"$fname[$i].dat" every :::0::0 using 1:@{[$j+2]} with \\
linespoints lt @{[$j+2]} lw 4 pt @{[$j+2]} t "$numbers[$j],"\\
 ...
END1

than

 ...
print OUTFILE "'$fname[$i].dat' every :::0::0 using 1:",$j+2,"with 
linespoints lt",$j+2,"lw 4 pt",$j+2,"t '$numbers[$j]',\\\n";
 ...

Michael


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

Date: Sun, 24 May 2009 13:44:31 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Here document
Message-Id: <87ws861jls.fsf@quad.sysarch.com>

>>>>> "m" == michael20545  <a@a.com> writes:

  m> Thank you for assistance. In my case (I create many gnuplot scripts
  m> with Perl), IMO, is better to write:

  m> print OUTFILE <<END1
  m> ...
  m> "$fname[$i].dat" every :::0::0 using 1:@{[$j+2]} with \\
  m> linespoints lt @{[$j+2]} lw 4 pt @{[$j+2]} t "$numbers[$j],"\\
  m> ...
  m> END1

but as others have said, the @{[]} expression interpolation trick is not
cool and can get very messy.

  m> than

  m> ...
  m> print OUTFILE "'$fname[$i].dat' every :::0::0 using 1:",$j+2,"with
  m> linespoints lt",$j+2,"lw 4 pt",$j+2,"t '$numbers[$j]',\\\n";

here docs are better than that but why not use another variable at
least? you have $j + 2 in there 3 times which is noisy.

	my $j2 = $j + 2 ;

# you need a ; here as this is the actual statement
# also you don't need the " or trailing \\. here docs are great for
# those reasons

	print OUTFILE <<END1 ;
$fname[$i].dat every :::0::0 using 1:$j2 with
linespoints lt $j2 lw 4 pt $j2 t $numbers[$j]
END1

and if it is more complex than that, a templater is useful. you can do
repeated sections and nested data with Template::Simple with very little
work. you can't do any of that with perl string interpolation.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Sun, 24 May 2009 18:01:01 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Here document
Message-Id: <Xns9C158EA1D2EA9asu1cornelledu@127.0.0.1>

michael20545 <a@a.com> wrote in news:gvc0me$6g9$1@adenine.netfront.net:

> Tad J McClellan пишет:
> 
>> 
>> It may be even better to use a real templating system rather than
>> invent yet another one based on here docs.
>> 
>> 
> 
> Thank you for assistance. In my case (I create many gnuplot scripts
> with Perl),

Have you seen Chart::Gnuplot?
http://search.cpan.org/~kwmak/Chart-Gnuplot-0.09/ 

> IMO, is better to write:
> 
> print OUTFILE <<END1
> ...
> "$fname[$i].dat" every :::0::0 using 1:@{[$j+2]} with \\
> linespoints lt @{[$j+2]} lw 4 pt @{[$j+2]} t "$numbers[$j],"\\
> ...
> END1

my $dataset = Chart::Gnuplot::DataSet->new(
   # ...
   style => 'linespoints',
   linetype => $j + 2,
   pointtype => $j + 2,
   # ...
);

The code above is not tested, but I have benefited from Chart::Gnuplot 
and the clean interface it provides. It works.

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://www.rehabitation.com/clpmisc/


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

Date: Sun, 24 May 2009 18:17:43 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Here document
Message-Id: <Xns9C159176544B1asu1cornelledu@127.0.0.1>

michael20545 <a@a.com> wrote in news:gvc0me$6g9$1@adenine.netfront.net:

> Tad J McClellan пишет:
> 
>> 
>> It may be even better to use a real templating system rather than
>> invent yet another one based on here docs.
>> 
> Thank you for assistance. In my case (I create many gnuplot scripts
> with Perl), IMO, is better to write:
> 
> print OUTFILE <<END1
> ...
> "$fname[$i].dat" every :::0::0 using 1:@{[$j+2]} with \\
> linespoints lt @{[$j+2]} lw 4 pt @{[$j+2]} t "$numbers[$j],"\\
> ...
> END1
> 

Expanding on the template idea:

use strict;
use warnings;

use File::Slurp;
use HTML::Template;

my @fname = qw( file1 file2 );
my @numbers = qw( Number1 Number2 );

my $script_tmpl = <<'EO_TMPL';
"<TMPL_VAR FILENAME>" every :::0::0 using 1:<TMPL_VAR COLUMN> with \\
linespoints lt <TMPL_VAR LINETYPE> lw 4 pt <TMPL_VAR POINTTYPE> \\
t "<TMPL_VAR TITLE>,"
EO_TMPL

my $tmpl = HTML::Template->new( scalarref => \$script_tmpl );

my $i = 0;
my $j = 0;

$tmpl->param(
    FILENAME  => "$fname[$i].dat",
    COLUMN    => $j + 2,
    LINETYPE  => $j + 2,
    POINTTYPE => $j + 2,
    TITLE     => $numbers[$j],
);

write_file 'output.plt', \ $tmpl->output;

__END__

This way, you can keep the template in a separate file, the script 
becomes simpler and you don't have to change the script for minor 
changes in the template file etc etc.

-- 
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://www.rehabitation.com/clpmisc/


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

Date: Sun, 24 May 2009 19:07:21 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Here document
Message-Id: <pveoe6-lo4.ln1@osiris.mauzo.dyndns.org>


Quoth michael20545 <a@a.com>:
> Tad J McClellan пишет:
> 
> > It may be even better to use a real templating system rather than
> > invent yet another one based on here docs.
> 
> Thank you for assistance. In my case (I create many gnuplot scripts with 
> Perl), IMO, is better to write:
> 
> print OUTFILE <<END1
> ...
> "$fname[$i].dat" every :::0::0 using 1:@{[$j+2]} with \\
> linespoints lt @{[$j+2]} lw 4 pt @{[$j+2]} t "$numbers[$j],"\\
> ...
> END1
> 
> than
> 
> ...
> print OUTFILE "'$fname[$i].dat' every :::0::0 using 1:",$j+2,"with 
> linespoints lt",$j+2,"lw 4 pt",$j+2,"t '$numbers[$j]',\\\n";
> ...

Tad's point is that a *real* templating system would be better still. In
this case, however, I'd probably just use sprintf:

    my $gnuplot = <<END1;
    ...
    "%s.dat" every :::0::0 using 1:%d with \\
    linespoints ls %d lw 4 pt %d t "%d,"\\
    ...
    END1

    print OUTFILE sprintf $gnuplot, 
        $fname[$i], $j + 2,
        $j + 2, $j + 2, $numbers[$j];

or, in fact, since '$j + 2' is clearly an important number here, just
assign it to a variable.

Ben



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

Date: Sun, 24 May 2009 11:24:40 -0700
From: "John W. Krahn" <someone@example.com>
Subject: Re: Here document
Message-Id: <IhgSl.32181$ho7.3582@newsfe10.iad>

A. Sinan Unur wrote:
> michael20545 <a@a.com> wrote in news:gvbk2b$2fme$2@adenine.netfront.net:
> 
>> my $j=0;
>> print <<END1;
>> $j
>> END1
>>
>> Can I interpolate ,for example, $j+2 in here document? Or I must ever 
>> create additional variable?
> 
> You could use (s)printf to make it more readable in case the heredoc is 
> long (which I presume is the case) and you have only a few 
> substitutions. Note that any % signs that appear in the heardoc will 
> have to be escaped as %% if the string is going to be used as a format 
> argument to sprintf.
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> my $j = 0;
> 
> my $template = <<EO_TMPL;
> %d
> EO_TMPL
> 
> printf $template, $j + 2;

Or just:

printf <<EO_TMPL, $j + 2;
%d
EO_TMPL



John
-- 
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov


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

Date: Sun, 24 May 2009 18:30:39 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Here document
Message-Id: <Xns9C1593A831F12asu1cornelledu@127.0.0.1>

"John W. Krahn" <someone@example.com> wrote in
news:IhgSl.32181$ho7.3582@newsfe10.iad: 

> A. Sinan Unur wrote:
>> michael20545 <a@a.com> wrote in
>> news:gvbk2b$2fme$2@adenine.netfront.net: 
>> 
>>> my $j=0;
>>> print <<END1;
>>> $j
>>> END1
>>>
>>> Can I interpolate ,for example, $j+2 in here document? Or I must
>>> ever create additional variable?
>> 
>> You could use (s)printf to make it more readable in case the heredoc
>> is long (which I presume is the case) 

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> Or just:
> 
> printf <<EO_TMPL, $j + 2;
> %d
> EO_TMPL

Sure, but my assumption was that the real heredoc was longer than that 
;-)

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://www.rehabitation.com/clpmisc/


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

Date: Sun, 24 May 2009 07:21:58 -0700 (PDT)
From: yawnmoth <terra1024@yahoo.com>
Subject: problem running Convert::ASN1 on Windows XP
Message-Id: <195c59a6-1be1-4a7d-b064-d60371b89f74@g37g2000yqn.googlegroups.com>

I installed ActivePerl on Windows and placed the contents of the lib
directory in <http://search.cpan.org/~gbarr/Convert-ASN1-0.22/lib/
Convert/ASN1.pod> into a local folder.  I then created a file -
test.pl - whose contents are identical to those at <http://
search.cpan.org/~gbarr/Convert-ASN1-0.22/lib/Convert/
ASN1.pod#SYNOPSYS> and...  I get the following error when I try to run
"perl test.pl":

7 string
Can't use an undefined value as a symbol reference at Convert/ASN1/
IO.pm line 73.

My directory structure is as follows:

test.pl
Convert\ASN1.pm
Convert\ASN1.pod
Convert\ASN1\_decode.pm
Convert\ASN1\_encode.pm
Convert\ASN1\Debug.pm
Convert\ASN1\IO.pm
Convert\ASN1\parser.pm

Any ideas?


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

Date: Sun, 24 May 2009 16:00:58 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: problem running Convert::ASN1 on Windows XP
Message-Id: <Xns9C157A4737A18asu1cornelledu@127.0.0.1>

yawnmoth <terra1024@yahoo.com> wrote in news:195c59a6-1be1-4a7d-b064-d60371b89f74@g37g2000yqn.googlegroups.com:

> I installed ActivePerl on Windows and placed the contents of the lib
> directory in <http://search.cpan.org/~gbarr/Convert-ASN1-0.22/lib/
> Convert/ASN1.pod> into a local folder.  I then created a file -
> test.pl - whose contents are identical to those at <http://
> search.cpan.org/~gbarr/Convert-ASN1-0.22/lib/Convert/
> ASN1.pod#SYNOPSYS> and...  I get the following error when I try to run
> "perl test.pl":
> 
> 7 string

The first part (up to the second use line) is a stand alone script
and this output shows that it ran.

> Can't use an undefined value as a symbol reference at Convert/ASN1/
> IO.pm line 73.

The second part of the synopsis:

 use Convert::ASN1 qw(:io);

  $peer   = asn_recv($sock,$buffer,0);
  $nbytes = asn_read($fh, $buffer);
  $nbytes = asn_send($sock, $buffer, $peer);
  $nbytes = asn_send($sock, $buffer);
  $nbytes = asn_write($fh, $buffer);
  $buffer = asn_get($fh);
  $yes    = asn_ready($fh)

is not a standalone script. These are just examples of functions 
exported when the :io export group is requested.

See http://search.cpan.org/~gbarr/Convert-ASN1-0.22/lib/Convert/ASN1.pod#IO_Functions

See http://cpansearch.perl.org/src/GBARR/Convert-ASN1-0.22/examples/ 
for examples.

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://www.rehabitation.com/clpmisc/


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

Date: Sun, 24 May 2009 16:57:33 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: problem running Convert::ASN1 on Windows XP
Message-Id: <dc7oe6-ak3.ln1@osiris.mauzo.dyndns.org>


Quoth yawnmoth <terra1024@yahoo.com>:
> I installed ActivePerl on Windows and placed the contents of the lib
> directory in <http://search.cpan.org/~gbarr/Convert-ASN1-0.22/lib/
> Convert/ASN1.pod> into a local folder. 

This is a bad idea. Either install Convert::ASN1 using PPM, or install
Strawberry Perl instead of ActivePerl and use CPAN.

> I then created a file -
> test.pl - whose contents are identical to those at <http://
> search.cpan.org/~gbarr/Convert-ASN1-0.22/lib/Convert/
> ASN1.pod#SYNOPSYS> and...  I get the following error when I try to run
> "perl test.pl":
> 
> 7 string
> Can't use an undefined value as a symbol reference at Convert/ASN1/
> IO.pm line 73.

That code is just an example. You're not meant to run it directly,
you're meant to read it, understand it, and learn from it. In
particular, it uses variables like $sock and $fh without setting them
up: the implication is that $sock should be a socket handle, but you
have to make that happen yourself.

Ben



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

Date: Sun, 24 May 2009 17:38:29 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: problem running Convert::ASN1 on Windows XP
Message-Id: <Xns9C158ACFCAEC3asu1cornelledu@127.0.0.1>

Ben Morrow <ben@morrow.me.uk> wrote in news:dc7oe6-ak3.ln1
@osiris.mauzo.dyndns.org:

> 
> Quoth yawnmoth <terra1024@yahoo.com>:
>> I installed ActivePerl on Windows and placed the contents of the lib
>> directory in <http://search.cpan.org/~gbarr/Convert-ASN1-0.22/lib/
>> Convert/ASN1.pod> into a local folder. 
> 
> This is a bad idea. Either install Convert::ASN1 using PPM, or install
> Strawberry Perl instead of ActivePerl and use CPAN.

Ooops, I missed that part. To the OP, the module installs fine using

ppm install Convert::ASN1

from the command line.

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://www.rehabitation.com/clpmisc/


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

Date: Sun, 24 May 2009 12:37:46 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: problem running Convert::ASN1 on Windows XP
Message-Id: <mu4pf5afc76n.rbw426svs9yi.dlg@40tude.net>

In Dread Ink, the Grave Hand of yawnmoth Did Inscribe:

> My directory structure is as follows:
> 
> test.pl
> Convert\ASN1.pm
> Convert\ASN1.pod
> Convert\ASN1\_decode.pm
> Convert\ASN1\_encode.pm
> Convert\ASN1\Debug.pm
> Convert\ASN1\IO.pm
> Convert\ASN1\parser.pm
> 
> Any ideas?

I just know that activestate is really touchy about where it expects to
find things.


C:\Perl\site\lib>dir
 Volume in drive C has no label.
 Volume Serial Number is 942A-AD55

 Directory of C:\Perl\site\lib

05/12/2009  11:05 PM    <DIR>          .
05/12/2009  11:05 PM    <DIR>          ..
02/13/2009  01:09 AM    <DIR>          Acme
05/09/2009  01:08 AM    <DIR>          auto
02/20/2009  05:59 PM    <DIR>          Bundle
02/20/2009  05:59 PM    <DIR>          Data
01/30/2009  10:06 PM    <DIR>          DateTime
03/09/2009  02:23 AM    <DIR>          Devel
03/09/2009  02:23 AM    <DIR>          Email
03/09/2009  03:28 AM    <DIR>          HTML
02/21/2009  03:15 AM    <DIR>          HTTP
03/09/2009  01:52 AM    <DIR>          Mail
03/09/2009  02:23 AM    <DIR>          Module
02/13/2009  01:15 AM             1,425 perl4.lnk
01/23/2007  04:15 PM                31 sitecustomize.pl
05/09/2009  01:08 AM    <DIR>          Sub
05/09/2009  01:08 AM    <DIR>          Test
05/12/2009  11:05 PM                 0 text63.txt
05/09/2009  01:08 AM    <DIR>          Tree
02/20/2009  06:14 PM    <DIR>          WWW
               3 File(s)          1,456 bytes
              17 Dir(s)  60,465,082,368 bytes free

This is where it expects to find these modules, but ...

C:\Perl\site\lib>cd ..

C:\Perl\site>dir
 Volume in drive C has no label.
 Volume Serial Number is 942A-AD55

 Directory of C:\Perl\site

12/29/2008  10:34 PM    <DIR>          .
12/29/2008  10:34 PM    <DIR>          ..
12/03/2008  06:29 PM    <DIR>          bin
05/11/2009  01:30 AM    <DIR>          etc
05/12/2009  11:05 PM    <DIR>          lib
               0 File(s)              0 bytes
               5 Dir(s)  60,464,713,728 bytes free

C:\Perl\site>cd ..

C:\Perl>dir
 Volume in drive C has no label.
 Volume Serial Number is 942A-AD55

 Directory of C:\Perl

05/09/2009  01:08 AM    <DIR>          .
05/09/2009  01:08 AM    <DIR>          ..
05/12/2009  11:09 PM    <DIR>          bin
12/03/2008  06:29 PM    <DIR>          eg
05/11/2009  01:30 AM    <DIR>          etc
05/09/2009  01:08 AM    <DIR>          html
12/03/2008  06:29 PM    <DIR>          lib
12/29/2008  10:34 PM    <DIR>          site
               0 File(s)              0 bytes
               8 Dir(s)  60,464,611,328 bytes free

C:\Perl>

 ... there are other folders named site and lib.

--
Frank

And by the way, a few months ago, I trademarked the word 'funny.' So when
Fox calls me 'unfunny,' they're violating my trademark. I am seriously
considering a countersuit.
~~ Al Franken, in response to Fox's copyright infringement lawsuit


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

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


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