[23563] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5771 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 9 21:05:39 2003

Date: Sun, 9 Nov 2003 18:05:09 -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           Sun, 9 Nov 2003     Volume: 10 Number: 5771

Today's topics:
    Re: binmode and the diamond operator <usenet@morrow.me.uk>
    Re: installing perl <usenet@morrow.me.uk>
    Re: installing perl <kingsman22004@yahoo.com>
    Re: installing perl <usenet@morrow.me.uk>
    Re: newbie 4th JaPH <REMOVEsdnCAPS@comcast.net>
    Re: newbie 4th JaPH <hexkid@hotpop.com>
    Re: newbie 4th JaPH <usenet@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 9 Nov 2003 19:14:01 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: binmode and the diamond operator
Message-Id: <bom3lp$cnv$1@wisteria.csv.warwick.ac.uk>

jl_post@hotmail.com (J. Romano) wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in message
> news:<slrnbqqnsn.bp5.tadmc@magna.augustmail.com>...
> > J. Romano <jl_post@hotmail.com> wrote:
> > 
> > > I use the diamond operator in a while loop after setting slurp
> > > mode (in order to read in the whole file at once). 
> >  
> > >    So I need to set binmode() on these files, but how do I do it with
> > > the diamond operator?
> > 
> >    binmode ARGV;
> 
>    Thanks for the response, Tad, but it doesn't work.  At least, I
> haven't figured out where to put the that line to make it work
> correctly.  Should I put it before the "while (<>)" loop or inside it?

A nice conundrum!

I can't find any way to make it work with 5.6... if you're using that
I think you'll have to write the loop 'properly' (ie. not use <> and
ARGV, but open and then binmode each file yourself), which pretty much
rules out one-liners. If you are using 5.8 then

perl -Mopen=IO,:raw -0777nwe'$n += length; END{print "$n\n"}' crlf

does what you want (this is Unix shell quoting, I'm afraid: you'll
need to correct it to DOS syntax). The -0777 is equivalent to
BEGIN{$/=undef}.

Ben

-- 
I've seen things you people wouldn't believe: attack ships on fire off the
shoulder of Orion; I've watched C-beams glitter in the darkness near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die.  |-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-|  ben@morrow.me.uk


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

Date: Sun, 9 Nov 2003 19:38:53 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: installing perl
Message-Id: <bom54d$d7s$2@wisteria.csv.warwick.ac.uk>


news@group.com wrote:
> > Likely you still have 5.6.1 installed as /usr/bin/perl. The easiest
> > way to fix this is
> > 
> > mv /usr/bin/perl /usr/bin/perl5.6.1
> > ln -s /usr/local/bin/perl /usr/bin/perl
> 
> 
> box:~# mv /usr/bin/perl /usr/bin/perl5.6.1
> mv: `/usr/bin/perl' and `/usr/bin/perl5.6.1' are the same file
> box:~# ln -s /usr/local/bin/perl /usr/bin/perl
> ln: `/usr/bin/perl': File exists
> box:~#

OK,

rm -f /usr/bin/perl
ln -sf /usr/local/bin/perl /usr/bin/perl

 . Use a little imagination, can't you?

Ben

-- 
               EAT
               KIDS                                          (...er, whoops...)
               FOR                                             ben@morrow.me.uk
               99p


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

Date: Mon, 10 Nov 2003 08:06:32 +1100
From: King <kingsman22004@yahoo.com>
Subject: Re: installing perl
Message-Id: <3FAEAC58.8090209@yahoo.com>

Ben Morrow wrote:
> news@group.com wrote:
> 
>>>Likely you still have 5.6.1 installed as /usr/bin/perl. The easiest
>>>way to fix this is
>>>
>>>mv /usr/bin/perl /usr/bin/perl5.6.1
>>>ln -s /usr/local/bin/perl /usr/bin/perl
>>
>>
>>box:~# mv /usr/bin/perl /usr/bin/perl5.6.1
>>mv: `/usr/bin/perl' and `/usr/bin/perl5.6.1' are the same file
>>box:~# ln -s /usr/local/bin/perl /usr/bin/perl
>>ln: `/usr/bin/perl': File exists
>>box:~#
> 
> 
> OK,
> 
> rm -f /usr/bin/perl
> ln -sf /usr/local/bin/perl /usr/bin/perl
> 
> . Use a little imagination, can't you?
> 
> Ben
> 


Ben
I am new to linux, I do appreicaite you help
$/bin/su
# rm -f /usr/bin/perl
# ln -sf /usr/local/bin/perl /usr/bin/perl
# perl -e 'print "$]\n";'
bash: perl: command not found
# perl -e 'print "$]\n";'
bash: perl: command not found
#

domain:/usr/bin# ls -l | grep perl
-rwxr-xr-x    1 root     root        22903 Aug 10 11:18 find2perl
lrwxrwxrwx    1 root     root           19 Nov 10 07:48 perl -> 
/usr/local/bin/perl
-rwxr-xr-x    2 root     root       774947 Aug 10 11:19 perl-5.6
-rwxr-xr-x    2 root     root       774947 Aug 10 11:19 perl5.6.1
-rwxr-xr-x    1 root     root        35465 Aug 10 11:18 perlbug
-rwxr-xr-x    1 root     root        16920 Aug 10 11:18 perlcc
-rwxr-xr-x    1 root     root        22696 Aug 10 11:18 perldoc
-rwxr-xr-x    1 root     root          121 Aug 10 11:19 perldoc.stub
domain:/usr/bin# ls -l /usr/local/bin/ | grep perl
lrwxrwxrwx    1 root     staff           9 Nov 10 07:57 perl -> perl5.8.0
domain:/usr/bin#C-d
username@domain:~$ls -l | grep perl
drwxr-xr-x   32 username    username        8192 Nov  7 20:12 perl-5.8.1
username@demain:~$



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

Date: Sun, 9 Nov 2003 22:58:51 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: installing perl
Message-Id: <bomgrb$i12$1@wisteria.csv.warwick.ac.uk>


news@group.com wrote:
> Ben
> I am new to linux, I do appreicaite you help

Fair enough.

> $/bin/su
> # rm -f /usr/bin/perl
> # ln -sf /usr/local/bin/perl /usr/bin/perl
> # perl -e 'print "$]\n";'
> bash: perl: command not found
> # perl -e 'print "$]\n";'
> bash: perl: command not found
> #
> 
> domain:/usr/bin# ls -l | grep perl
> -rwxr-xr-x    1 root     root        22903 Aug 10 11:18 find2perl
> lrwxrwxrwx    1 root     root           19 Nov 10 07:48 perl -> 
> /usr/local/bin/perl
> -rwxr-xr-x    2 root     root       774947 Aug 10 11:19 perl-5.6
> -rwxr-xr-x    2 root     root       774947 Aug 10 11:19 perl5.6.1
> -rwxr-xr-x    1 root     root        35465 Aug 10 11:18 perlbug
> -rwxr-xr-x    1 root     root        16920 Aug 10 11:18 perlcc
> -rwxr-xr-x    1 root     root        22696 Aug 10 11:18 perldoc
> -rwxr-xr-x    1 root     root          121 Aug 10 11:19 perldoc.stub
> domain:/usr/bin# ls -l /usr/local/bin/ | grep perl
> lrwxrwxrwx    1 root     staff           9 Nov 10 07:57 perl -> perl5.8.0
> domain:/usr/bin#C-d
> username@domain:~$ls -l | grep perl
> drwxr-xr-x   32 username    username        8192 Nov  7 20:12 perl-5.8.1
> username@demain:~$

Right, what you have here is technically known as 'a mess' :).

1. Which version of perl have you just installed, 5.8.0 or 5.8.1?

2. Where did you install it? What answer did you give when Configure
   asked for an installation prefix?

3. Where did that file perl-5.8.1 in ~ come from? And that symlink
   perl in /usr/local/bin?

4. Are you sure you can't install 5.8 using apt-get/dpkg/dselect?

Ben

-- 
"If a book is worth reading when you are six,                * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis


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

Date: Sun, 09 Nov 2003 14:16:55 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: newbie 4th JaPH
Message-Id: <Xns942E9B81195C5sdn.comcast@216.196.97.136>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Pedro Graca <hexkid@hotpop.com> wrote in news:bogp42$1dqb28$1@ID-
203069.news.uni-berlin.de:

> How do you like this newbie's 4th JaPH attempt?
> 
> -- (not a .sig now)
> #!/usr/bin/perl -w                 2003-11-07 Pedro Graca - JaPH4
> @1=(2399670,250604053953,1455299,5114679918);foreach$2(@1){$s='';
> while($2){$c=$2%49;$2=int($2/49);$s.=(chr(($c+64)^32))}push@p,$s}
> print join(' ',@p),"\n"

Not bad.  I'm somewhat surprised that you can use $2 as a loop variable.  I 
wonder if that's a bug.

Why join @p to print it?  Why not just print "@p\n"?

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP66gxmPeouIeTNHoEQLxjwCgnGzBs3abvzy7yjjWkkJnGrEoMWMAoI7V
fcS9F70qM9EoJ3NW1yF8K3N4
=Vmkg
-----END PGP SIGNATURE-----


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

Date: 10 Nov 2003 01:00:51 GMT
From: Pedro Graca <hexkid@hotpop.com>
Subject: Re: newbie 4th JaPH
Message-Id: <bomo03$1g4eh1$1@ID-203069.news.uni-berlin.de>

Eric J. Roode wrote:
> Pedro Graca wrote
>> How do you like this newbie's 4th JaPH attempt?
> Not bad.

Thank you :)


> I'm somewhat surprised that you can use $2 as a loop variable.  I 
> wonder if that's a bug.

I wanted to use @1, $2, $3 (for $s) and $4 (for $c), but perl (or
Perl?) complained.
I don't see any references to $2, $3, and $4 in perldoc perlvar except
for regexes which I'm not using.

What do they mean?
Or where can I find out what do they mean?


> Why join @p to print it?  Why not just print "@p\n"?

Changed!


> Eric
> $_ = reverse sort $ /. r , qw p ekca lre uJ reh
> ts p , map $ _. $ " , qw e p h tona e and print

I tried to understand your JaPH ... finally made it!
with a lot of trial and error in recoding it, trying to guess where the
lists started and ended and where the instructions started and ended.

-- 
#!/usr/bin/perl -w                 2003-11-09 Pedro Graca - JaPH4
@1=(2399670,250604053953,1455299,5114679918);foreach$2(@1){$s='';
while($2){$c=$2%49;$2=int($2/49);$s.=(chr(($c+64)^32))}push@p,$s}
print "@p\n"


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

Date: Mon, 10 Nov 2003 01:41:11 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: newbie 4th JaPH
Message-Id: <bomqbn$n1c$1@wisteria.csv.warwick.ac.uk>


Pedro Graca <hexkid@hotpop.com> wrote:
> Eric J. Roode wrote:
> > I'm somewhat surprised that you can use $2 as a loop variable.  I 
> > wonder if that's a bug.
> 
> I wanted to use @1, $2, $3 (for $s) and $4 (for $c), but perl (or
> Perl?) complained.
> I don't see any references to $2, $3, and $4 in perldoc perlvar except
> for regexes which I'm not using.

That is their only significance: they hold the contents of the
bracketed sections of the last successful match.

perlvar states they are read-only, which is why Perl complained about
your use of $3 and $4. That it didn't complain about $2 is wrong, and
is (I think) to do with the special way that globals are treated when
used as the iterator of a for loop. @1 is (currently) not special, but
you should not use it as it is reserved for Perl, which means it may
become so one day.

(Note, for your (probable) immediate change, that $a and $b are
special as well... :)

Ben

-- 
  The cosmos, at best, is like a rubbish heap scattered at random.
                                                         - Heraclitus
  ben@morrow.me.uk


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

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


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