[22606] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4827 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 10 14:06:42 2003

Date: Thu, 10 Apr 2003 11:05:05 -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           Thu, 10 Apr 2003     Volume: 10 Number: 4827

Today's topics:
    Re: avoid using extra variable <usenet@NOSPAM.matthewb.org>
        broke ExtUtils::Embed in upgrade? (Carrie Coy)
    Re: How it wipe out or delete or init an array? (Helgi Briem)
    Re: How it wipe out or delete or init an array? <usenet@NOSPAM.matthewb.org>
    Re: Perl command line and backticks <richard@zync.co.uk>
    Re: Perl command line and backticks <andreas.buehmann@web.de>
    Re: Questions about Perl's Unicode Model <flavell@mail.cern.ch>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 10 Apr 2003 16:34:05 +0100
From: Matthew Browning <usenet@NOSPAM.matthewb.org>
Subject: Re: avoid using extra variable
Message-Id: <pan.2003.04.10.16.34.03.843859.2494@NOSPAM.matthewb.org>

On Thu, 10 Apr 2003 16:25:01 +0100, Eric Osman wrote:



> Putting simple expressions in a quoted string is useful.  But they seem
> limited so I'm wondering if you might have ideas on the following:
> 
> 
> This works:
> 
>    my $index = 3;
>    print "The secret card is @cards[$index] so play carefully\n";
> 
> 
> This doesn't:
> 
>    my $index = 3;
>    print "The secret card is @cards[$index] so play carefully\n"; print
>    "The next card is @cards[$index+1] so really watch out\n";


Your example should work unless there is a typo that has not been
reproduced.

If you turned on warnings it would help you to debug and also draw your
attention to the fact that the correct symbol when expecting a scalar
value is $, i.e.

$cards[$index]
$cards[$index+1]

#!/path/to/perl -w
or
use warnings;

[MB]


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

Date: 10 Apr 2003 10:01:19 -0700
From: ccoy@ssww.com (Carrie Coy)
Subject: broke ExtUtils::Embed in upgrade?
Message-Id: <8ca20109.0304100901.74e03e8@posting.google.com>

Recently upgraded from 5.004_01 to 5.8.0 on this OSF 4.0D machine.
Compiled from scratch with "sh Configure -de".

Now when trying to "make test" in ExtUtils::Embed, I get:

"perl_destruct_level" is not declared

If I install module anyway and 'make' the example scripts, some of
them compile and run, but hashref.c, for example, fails with these
errors:

cc: Error: hashref.c, line 28: In this statement, "errgv" is not
declared.
    if (SvTRUE(GvSV(errgv)))
--------^
cc: Error: hashref.c, line 29: In this statement, "na" is not
declared.
        fprintf(stderr, "eval error: %s\n", SvPVx(GvSV(errgv), na));
--------------------------------------------^
cc: Error: hashref.c, line 56: In this statement, "na" is not
declared.
        printf("in C:    %s=`%s'\n", key, SvPV(val,na));
------------------------------------------^

=========================================================================
Summary of my perl5 (revision 5.0 version 8 subversion 0)
configuration:
  Platform:
    osname=dec_osf, osvers=4.0d, archname=alpha-dec_osf
    uname='osf1 athena v4.0 878 alpha '
    config_args='-de'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=define uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-std -D_INTRINSICS -fprm d -ieee
-I/usr/local/include -DLANGUAGE_C',
    optimize='-O4',
    cppflags='-std -D_INTRINSICS -ieee -I/usr/local/include
-DLANGUAGE_C'
    ccversion='V5.6-084', gccversion='', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc
/usr/lib /var/shlib
    libs=-ldbm -ldb -lm -lutil
    perllibs=-lm -lutil
    libc=/usr/shlib/libc.so, so=so, useshrplib=true,
libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' 
-Wl,-rpath,/usr/local/lib/perl5/5.8.0/alpha-dec_osf/CORE'
    cccdlflags=' ', lddlflags='-shared -expect_unresolved "*" -msym
-std -s -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: USE_64_BIT_INT USE_64_BIT_ALL USE_LARGE_FILES
  Built under dec_osf
  Compiled at Apr  3 2003 12:38:10
  %ENV:
    PERL_DESTRUCT_LEVEL="1"
  @INC:
    /usr/local/lib/perl5/5.8.0/alpha-dec_osf
    /usr/local/lib/perl5/5.8.0
    /usr/local/lib/perl5/site_perl/5.8.0/alpha-dec_osf
    /usr/local/lib/perl5/site_perl/5.8.0
    /usr/local/lib/perl5/site_perl
    .

What could be wrong?
--
Carrie Coy


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

Date: Thu, 10 Apr 2003 16:09:15 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: How it wipe out or delete or init an array?
Message-Id: <3e9596ed.4414748@news.cis.dfn.de>

On Thu, 10 Apr 2003 15:48:21 GMT, helgi@decode.is (Helgi
Briem) wrote:

>On Thu, 10 Apr 2003 11:27:53 -0400, "jtpr"
><spam@jimryan.com> wrote:
>
>>If I have an array @array that has a bunch of stuff in it, 
>>how can I "zero it out" so to speak?  So I can reuse it.
>
>@array = ();

A better answer of course, is:

Don't.  Let it go out of scope when it has fulfilled
it's function and it will automatically be emptied.
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Thu, 10 Apr 2003 16:38:39 +0100
From: Matthew Browning <usenet@NOSPAM.matthewb.org>
Subject: Re: How it wipe out or delete or init an array?
Message-Id: <pan.2003.04.10.16.38.38.910058.2514@NOSPAM.matthewb.org>

On Thu, 10 Apr 2003 16:27:53 +0100, jtpr wrote:

> If I have an array @array that has a bunch of stuff in it, how can I
> "zero it out" so to speak?  So I can reuse it.
> 


@array = ();


[MB]


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

Date: Thu, 10 Apr 2003 17:12:30 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: Perl command line and backticks
Message-Id: <20030410.171229.1269400346.18265@richg.zync>

In article <3e958eeb.2364169@news.cis.dfn.de>, "Helgi Briem"
<helgi@decode.is> wrote:


> On Thu, 10 Apr 2003 16:10:08 +0100, "Richard Gration"
> <richard@zync.co.uk> wrote:
> 
>>I have a script called get_cchange.pl, which looks like this:
>>	#!/usr/bin/perl
>>	print "'print 23'";
>>That's it. The output of this script is:
>>	'print 23'
>>Then I try to have this executed with
>>	perl -e `perl get_cchange.pl'
> You are essentially asking for the shell to interpret your backticks,
> not perl.

That's right. get_cchange.pl is intended to produce a list of
substitution commands, built by reading a file cchange.txt. The context
of this is a little global search and replace script for class names
across a website. The idea is that the contents of cchange.txt may be
altered, the script run again and more (ie different) search & replace
happens. So I _do_ want the shell to interpret the backticks, and I _do_
want perl to use the output as a command list to -e. But it's not.
Harrumph :-/

However Ben, who probably inhabits c.u.shell, has suggested using eval,
which works :-)

Thanks for the reply
Rick


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Thu, 10 Apr 2003 16:28:14 +0000 (UTC)
From: Andreas =?iso-8859-15?Q?B=FChmann?= <andreas.buehmann@web.de>
Subject: Re: Perl command line and backticks
Message-Id: <slrnb9b6nv.255.andreas.buehmann@forelle284.wohnheim.uni-kl.de>

Richard Gration wrote:
> I have a script called get_cchange.pl, which looks like this:
> 
> 	#!/usr/bin/perl
> 	print "'print 23'";
> 
> That's it. The output of this script is:
> 
> 	'print 23'
> 
> Then I try to have this executed with
> 
> 	perl -e `perl get_cchange.pl'
> 
> The output from this is not what I expected:
> 
> 	[root@richg ~]# perl -e `perl get_cchange.pl`
> 	Can't find string terminator "'" anywhere before EOF at -e line 1.

> Can anyone offer any ideas as to what is going wrong??

Your shell splits the output of get_cchange.pl at whitespace so that the
argument to -e is |'print| and |23'| goes into @ARGV. This explains the
missing string terminator perl complains about.

You should remove the single quotes in the output of get_cchange.pl and
add double quotes around the backticks. (The shell only cares about
quotes appearing directly on the command line.)

    > cat get_cchange.pl
    #!/usr/bin/perl
    print 'print"@ARGV\n" #comment';
    > perl -e "`perl get_cchange.pl`" firstarg
    firstarg
    > perl -e `perl get_cchange.pl` firstarg
    #comment firstarg

Regards,

Andreas


F'up2 comp.unix.shell


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

Date: Thu, 10 Apr 2003 18:25:31 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Questions about Perl's Unicode Model
Message-Id: <Pine.LNX.4.53.0304101815150.21604@lxplus084.cern.ch>

On Thu, Apr 9, Rashmi Dixit inscribed on the eternal scroll:

> I want to read some locally encoded (SJIS) data from a file and I want to
> perform string manipulation functions on this data.

I'm no expert on shift_jis or indeed on any CJK coding, but I think I
can take a shot at pointing you to the relevant documentation, at
least.  Assuming Perl >= 5.8.0.

Perl would like to work in utf-8, so the natural thing to do would
be to read your data with the appropriate :encoding discipline in
effect.  See http://www.perldoc.com/perl5.8.0/pod/perluniintro.html
or your local copy of the documentation.

> Currently the string
> manipulation functions fail (upper/lower) because the SJIS data is
> incorrectly read as UTF8.

Quite.

> Can anyone help here? Is there a method of disabling this default behaviour?

Of course (clue: straightforward binmode() ), but then you would need
to handle the shift_jis encoding yourself.  I'd imagine it would be
less work to normalise the external coding into utf-8 coding for
internal working, and let Perl's own string functions cope with the
result.  Output (assuming you want shift_jis output too) would be the
converse of input.


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

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.  

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


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