[16360] in Perl-Users-Digest
Perl-Users Digest, Issue: 3772 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 21 18:15:41 2000
Date: Fri, 21 Jul 2000 15:15:29 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964217729-v9-i3772@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 21 Jul 2000 Volume: 9 Number: 3772
Today's topics:
strict <rbank@csf.edu>
Re: strict <care227@attglobal.net>
Re: strict <bcaligari@shipreg.com>
Swapping items in an array of associative arrays <news@chrismo.com>
Re: Swapping items in an array of associative arrays <jraff@home.com>
Re: Swapping items in an array of associative arrays <news@chrismo.com>
Re: Swapping items in an array of associative arrays <bert@scanlaser.nl>
Re: Swapping items in an array of associative arrays <aqumsieh@hyperchip.com>
Re: Swapping items in an array of associative arrays <news@chrismo.com>
Re: Swedish social security number control. (slow code (Tim)
UDP and ActivePERL (WIN32) 3lush3@my-deja.com
UDP and ActivePERL (WIN32) lush3@geocities.com
unbuffered nonblocking read from STDIN? (Bas Zoetekouw)
Re: Understanding Perl Idiom (Please Help) <care227@attglobal.net>
UPD-packet problem.. <ditlew@abk.auc.dk>
Re: What is the differance? <bert@scanlaser.nl>
Re: What is the differance? <bart.lateur@skynet.be>
Re: What is the differance? (Eric Bohlman)
Re: What is the differance? <bart.lateur@skynet.be>
Win32::NetAdmin problems <dunfeeje@pilot.msu.edu>
Re: Writing to a file error <bert@scanlaser.nl>
Re: Writing to a file error <care227@attglobal.net>
Re: Writing to a file error schnurmann@my-deja.com
Re: Writing to a file error <bert@scanlaser.nl>
Re: Writing to a file error <care227@attglobal.net>
Re: Writing to a file error <newsposter@cthulhu.demon.nl>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 21 Jul 2000 14:32:45 -0600
From: "Robin Bank" <rbank@csf.edu>
Subject: strict
Message-Id: <8lad4m$2mdo$2@reader.nmix.net>
Will you people stop "using" that damn strict thing. Pragmas are so
pragmatic....
lol.
------------------------------
Date: Fri, 21 Jul 2000 16:50:48 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: strict
Message-Id: <3978B7A8.AD7BB57C@attglobal.net>
Robin Bank wrote:
>
> Will you people stop "using" that damn strict thing. Pragmas are so
> pragmatic....
>
> lol.
huh?
------------------------------
Date: Fri, 21 Jul 2000 23:37:02 +0200
From: "Brendon Caligari" <bcaligari@shipreg.com>
Subject: Re: strict
Message-Id: <8laf63$slt$1@news.news-service.com>
"Robin Bank" <rbank@csf.edu> wrote in message
news:8lad4m$2mdo$2@reader.nmix.net...
> Will you people stop "using" that damn strict thing. Pragmas are so
> pragmatic....
>
> lol.
>
>
>
look at it as a dogma
B
------------------------------
Date: Fri, 21 Jul 2000 20:21:47 +0100
From: "Chris Moreton" <news@chrismo.com>
Subject: Swapping items in an array of associative arrays
Message-Id: <8la7vl$n2r$1@lure.pipex.net>
Hi,
I have an array of associative arrays so that, for example, I can store the
data below.
$item[0]{'key1'}="value1";
$item[0]{'key2'}="value2";
$item[1]{'key1'}="value3";
$item[1]{'key2'}="value4";
I am trying to sort the array of items but I can't figure out how to swap
items, for example, swapping item[0] and item[1] so that I end up with the
data below.
$item[1]{'key1'}="value3";
$item[1]{'key2'}="value4";
$item[2]{'key1'}="value1";
$item[2]{'key2'}="value2";
Thanks for your help
Chris
------------------------------
Date: Fri, 21 Jul 2000 19:33:12 GMT
From: "jraff" <jraff@home.com>
Subject: Re: Swapping items in an array of associative arrays
Message-Id: <Yz1e5.78028$lU5.538627@news1.rdc1.nj.home.com>
One can NOT sort associative arrays!
http://www.cpan.org/doc/manual/html/pod/perlfaq4.html#How_do_I_sort_a_hash_o
ptionally
----------------------------------------------------------------------------
-----------------------
"Chris Moreton" <news@chrismo.com> wrote in message
news:8la7vl$n2r$1@lure.pipex.net...
> Hi,
>
> I have an array of associative arrays so that, for example, I can store
the
> data below.
>
> $item[0]{'key1'}="value1";
> $item[0]{'key2'}="value2";
> $item[1]{'key1'}="value3";
> $item[1]{'key2'}="value4";
>
> I am trying to sort the array of items but I can't figure out how to swap
> items, for example, swapping item[0] and item[1] so that I end up with the
> data below.
>
> $item[1]{'key1'}="value3";
> $item[1]{'key2'}="value4";
> $item[2]{'key1'}="value1";
> $item[2]{'key2'}="value2";
>
> Thanks for your help
> Chris
>
>
>
------------------------------
Date: Fri, 21 Jul 2000 21:08:12 +0100
From: "Chris Moreton" <news@chrismo.com>
Subject: Re: Swapping items in an array of associative arrays
Message-Id: <8laamn$p9v$1@lure.pipex.net>
Thanks for your response jraff. My problem is not that I need to sort the
associative array but that I have an array of
associative arrays, for example as shown below and I want to sort the array
based on the "score" value of each associative array, so that
$item[0]{'date'} eq "27 June".
$item[0]{'date'}="23 June";
$item[0]{'score'}=54;
$item[1]{'date'}="27 June";
$item[1]{'score'}=4;
$item[2]{'date'}="2 April";
$item[2]{'score'}=23;
"jraff" <jraff@home.com> wrote in message
news:Yz1e5.78028$lU5.538627@news1.rdc1.nj.home.com...
> One can NOT sort associative arrays!
>
http://www.cpan.org/doc/manual/html/pod/perlfaq4.html#How_do_I_sort_a_hash_o
> ptionally
> --------------------------------------------------------------------------
--
> -----------------------
> "Chris Moreton" <news@chrismo.com> wrote in message
> news:8la7vl$n2r$1@lure.pipex.net...
> > Hi,
> >
> > I have an array of associative arrays so that, for example, I can store
> the
> > data below.
> >
> > $item[0]{'key1'}="value1";
> > $item[0]{'key2'}="value2";
> > $item[1]{'key1'}="value3";
> > $item[1]{'key2'}="value4";
> >
> > I am trying to sort the array of items but I can't figure out how to
swap
> > items, for example, swapping item[0] and item[1] so that I end up with
the
> > data below.
> >
> > $item[1]{'key1'}="value3";
> > $item[1]{'key2'}="value4";
> > $item[2]{'key1'}="value1";
> > $item[2]{'key2'}="value2";
> >
> > Thanks for your help
> > Chris
> >
> >
> >
>
>
------------------------------
Date: Fri, 21 Jul 2000 22:23:31 +0200
From: Bert IJff <bert@scanlaser.nl>
To: jraff <jraff@home.com>
Subject: Re: Swapping items in an array of associative arrays
Message-Id: <3978B143.566DBAB5@scanlaser.nl>
jraff wrote:
>
> One can NOT sort associative arrays!
> http://www.cpan.org/doc/manual/html/pod/perlfaq4.html#How_do_I_sort_a_hash_o
> ptionally
> ----------------------------------------------------------------------------
> -----------------------
I don't have a code answer at hand so quickly, but your reply doesn't
answer the question either.
The OP asked how to sort the array of items @item, where each array
element is a hash.
So he has an array of hashes, which, of course, can be sorted.
perldoc -f sort may have some hints
> "Chris Moreton" <news@chrismo.com> wrote in message
> news:8la7vl$n2r$1@lure.pipex.net...
> > Hi,
> >
> > I have an array of associative arrays so that, for example, I can store
> the
> > data below.
> >
> > $item[0]{'key1'}="value1";
> > $item[0]{'key2'}="value2";
> > $item[1]{'key1'}="value3";
> > $item[1]{'key2'}="value4";
> >
> > I am trying to sort the array of items but I can't figure out how to swap
> > items, for example, swapping item[0] and item[1] so that I end up with the
> > data below.
> >
> > $item[1]{'key1'}="value3";
> > $item[1]{'key2'}="value4";
> > $item[2]{'key1'}="value1";
> > $item[2]{'key2'}="value2";
> >
--
perl -e '$l=(@j=split//,"\nnPcutrete !A aJoekshlr rH");
$a=$l<<2&0x3f|1; do{print$j[$i+=$a,$i%=$l];} while $i;'
------------------------------
Date: Fri, 21 Jul 2000 20:27:13 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Swapping items in an array of associative arrays
Message-Id: <7a1z0ni5zv.fsf@merlin.hyperchip.com>
"Chris Moreton" <news@chrismo.com> writes:
> Thanks for your response jraff. My problem is not that I need to sort the
> associative array but that I have an array of
> associative arrays, for example as shown below and I want to sort the array
> based on the "score" value of each associative array, so that
> $item[0]{'date'} eq "27 June".
>
> $item[0]{'date'}="23 June";
> $item[0]{'score'}=54;
>
> $item[1]{'date'}="27 June";
> $item[1]{'score'}=4;
>
> $item[2]{'date'}="2 April";
> $item[2]{'score'}=23;
Does this do what you want?
my @sorted_item = sort { $b->{score} <=> $a->{score} } @item;
For more info on sort(), checkout perlfaq4.
--Ala
------------------------------
Date: Fri, 21 Jul 2000 21:34:05 +0100
From: "Chris Moreton" <news@chrismo.com>
Subject: Re: Swapping items in an array of associative arrays
Message-Id: <8lac77$rvt$1@lure.pipex.net>
Excellent! - That is perfect. Thank you very much. What a wonderful
lanuage.
>
> Does this do what you want?
>
> my @sorted_item = sort { $b->{score} <=> $a->{score} } @item;
>
> For more info on sort(), checkout perlfaq4.
>
> --Ala
------------------------------
Date: Fri, 21 Jul 2000 18:46:01 GMT
From: SPAM+indigo@dimensional.com (Tim)
Subject: Re: Swedish social security number control. (slow code / get it more effective if you can please)
Message-Id: <8F7889B27indigodimcom@166.93.207.145>
webmaster@ostas.lu.se (Jimmy Lantz) wrote in
<39786E02.6E62EE95@ostas.lu.se>:
>Hi,
>the below is a working code for checking if a swedish soc. security
>number is valid or not,
>but I wonder if any of you perlexperts can see ways to make it more
>efficient.
>It takes a lot of code to check it this way.
>
>####### Facts (working code below) ########
>
>The swedish soc sec nr consists by 10 numbers.
>often written yymmdd-nnnn
>the last number is a control number.
>you can check it by taking
>the first nr and multiply it by 2 the second by 1 third by 2 and so on
>until all NINE numbers are
>multiplied (LEAVE OUT THE CONTROLNUMBER). then add all the digits
>NB! if you have the year 56 then you multiply 5 by 2 and 6 by 1 when you
>add everything up
>you need to take it digit by digit 1+0+6 etc.....
>when you get your sum, you count how much it lacks until it ends with 0
>(that is the difference between the sum until it gets to a zero in the
>end. then you know the control number (or check it with the control
>number).
Returns true for valid ssn's, false for invalid.
(ungolfed for readiblity)
sub s_ssn
{
shift =~ /(\d)(\d)(\d)(\d)(\d)(\d).*(\d)$/;
10 - eval(join '+',
split //, 2 * $1 . 2 * $3 . 2 * $5 ."$2$4$6") % 10 eq $7;
}
-T
------------------------------
Date: Fri, 21 Jul 2000 18:51:37 GMT
From: 3lush3@my-deja.com
Subject: UDP and ActivePERL (WIN32)
Message-Id: <8la63i$q15$1@nnrp1.deja.com>
Hello everyone,
I'm trying to set up a communication via UDP but no matter what I
try it does not work. Doing the same thing via TCP just works fine.
Here's some code fragment -->
$chall = "sensomething";
use strict;
use IO::socket;
my (..... etc)
$host="date.game.net";
$port="12233";
$sock = IO::Socket::INET->new(Proto => "udp",
PeerPort => $port,
PeerAddr => $host,)
or die "Could not open SocketSend ... exiting";
for (1..3000)
{
$sock->send($chall) == length($chall) or die "Can not send
UDP data to $!";
}
$sock->recv($test,10) or die "Error receiving ....: $!";
When I start the script it seems to send data (judging from my
dial-up monitor) but I can't see the (new) port (UDP) via Netstat!!!
When the script reaches the recv portion it either exits (unknown error)
or just sits there doing (waiting?) ....!
The UDP-Port does not show up while receiving as well!
Any hints are higly appreciated!
Should I use another module?
I'm totally clueless here!
Thanks in advance,
Andreas
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 21 Jul 2000 18:51:45 GMT
From: lush3@geocities.com
Subject: UDP and ActivePERL (WIN32)
Message-Id: <8la63p$q16$1@nnrp1.deja.com>
Hello everyone,
I'm trying to set up a communication via UDP but no matter what I
try it does not work. Doing the same thing via TCP just works fine.
Here's some code fragment -->
$chall = "sensomething";
use strict;
use IO::socket;
my (..... etc)
$host="date.game.net";
$port="12233";
$sock = IO::Socket::INET->new(Proto => "udp",
PeerPort => $port,
PeerAddr => $host,)
or die "Could not open SocketSend ... exiting";
for (1..3000)
{
$sock->send($chall) == length($chall) or die "Can not send
UDP data to $!";
}
$sock->recv($test,10) or die "Error receiving ....: $!";
When I start the script it seems to send data (judging from my
dial-up monitor) but I can't see the (new) port (UDP) via Netstat!!!
When the script reaches the recv portion it either exits (unknown error)
or just sits there doing (waiting?) ....!
The UDP-Port does not show up while receiving as well!
Any hints are higly appreciated!
Should I use another module?
I'm totally clueless here!
Thanks in advance,
Andreas
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 21 Jul 2000 21:32:09 +0200
From: bas@medeia.dhs.org (Bas Zoetekouw)
Subject: unbuffered nonblocking read from STDIN?
Message-Id: <slrn8nh99p.2ms.bas@medeia.warande.net>
Hi!
I'm trying to do unbuffered non-blocking reading from STDIN, but I'm not
getting it to work. THe best I've come up with is:
sysopen(STDIN,"&STDIN",0);
sleep 5;
$num=sysread(STDIN,$buf,50);
print "You entered $num characters during sleep\n";
open(STDIN);
But this doesn't work: after the sysread, $num is still undefined.
Does anyone have any idea of what I'm doing wrong and/or how (or if)
unbuffered non-blocking reading should be handled?
--
Kind regards,
Bas Zoetekouw ``Si l'on sait exactement ce que l'on
va faire, a quoi bon le faire?''
bas@A-Es2.uu.nl Pablo Picasso
------------------------------
Date: Fri, 21 Jul 2000 14:15:54 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Understanding Perl Idiom (Please Help)
Message-Id: <3978935A.1138FFDA@attglobal.net>
kenlaird@my-deja.com wrote:
>
> In article <39774039.655DD730@attglobal.net>,
> Drew Simonis <care227@attglobal.net> wrote:
> > kenlaird@my-deja.com wrote:
> > >
> > > #!/usr/bin/perl -w
> > > @a=`ps -edf`;
> > > foreach (@a) {
> > > if (/ftp/) {
> > > print ;
> > > }
> > > }
> > >
> > > It works fine,but trying to understand the Perl idiom I'd like to
> > > know why the use of both parenthesis (without them it doesn't work
> ).
> > > Would be grateful to have any explanation.
> > >
> >
> > Do you mean the parens with 'if (/ftp/)' and 'foreach (@a)' ?
> > I have to assume that you are, since these are the only ones in
> > your example. Called in this way, if() requires parens, as does
> > foreach(). I must confess to being a little confused by your
> > question (question fragment?)
> >
> > > It works fine,but trying to understand the Perl idiom I'd like to
> > > know why the use of both parenthesis (without them it doesn't work )
> >
> > You need to reword that to be a complete question.
> >
>
> Yes, I mean I'm trying to understand the use of () in the examle above.
> Because the first time I wrote this more "naturally" without "()"
>
> #!/usr/bin/perl -w
> @a=`ps -edf`;
> foreach @a {
> if /ftp/ {
> print ;
> }
> }
Right. As you've seen, those are just required. No tricks to it.
Read the other posts for more elegant ways to do this same thing.
------------------------------
Date: Fri, 21 Jul 2000 20:26:01 GMT
From: "Daniel Ditlew" <ditlew@abk.auc.dk>
Subject: UPD-packet problem..
Message-Id: <tl2e5.2783$MJ5.32912@twister.sunsite.auc.dk>
Hi.. I get this UPD - packet from a server.. when I make the UPD request
"players"..
Server responds with the following packet:
(int32) -1
(byte) ASCII 'D' (players response, S2A_PLAYER)
(byte) active client count
for each active client
(byte) client number / index
(string) player name
(int32) client's frag total
(float32) client's total time in-game
I have a problem.. I seem to recive the packet as one long string, and I
dont know how to split the string up into the different components.. I have
tried to use a filter which looks for names in the packet, but it doesn't
always do the work..
This is my code:
use strict;
use Socket;
my
($ipaddr,$portaddr,$temp,$ctr2,$score,$indr,$msg,@msg,$portnr,$a,$line,$host
,$rin,$tst,$ctr);
my $getstatus = "\xff\xff\xff\xffplayers\x00";
$ctr=0; $ctr2 = 0;
if (@ARGV[0]) {
$host = @ARGV[0];
$portnr = @ARGV[1];
}
else {
print "Usage: halflifeplayers host portnr\n";
exit;
}
socket(STATUS, PF_INET, SOCK_DGRAM, getprotobyname("udp"))
or die "socket: $!";
$ipaddr = inet_aton($host);
$portaddr = sockaddr_in($portnr,$ipaddr);
send(STATUS,$getstatus,0,$portaddr)
or die "Cannot connect to : $host:$portnr";
$tst = 1;
vec($rin,fileno(STATUS),1) = 1;
while ($tst==1 && select($rin,undef,undef,3)) {
$portaddr = recv(STATUS,$msg,4096,0)
or die "recv: $!";
$tst = 0;
}
print"<u>player</u> | <u>score</u>\n";
@msg = split("\x", $msg);
foreach $line (@msg) {
$score = ord @msg[$ctr2+1];
$temp = $line;
if ($line =~ /(.*?)([a-zA-Z0-9[][a-zA-Z0-9][a-zA-Z0-9].*)/) {
print"$2 $score\n";
}
$ctr2++;
}
- Ditlew, Denmark, Newbie!!
------------------------------
Date: Fri, 21 Jul 2000 20:49:58 +0200
From: Bert IJff <bert@scanlaser.nl>
To: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: What is the differance?
Message-Id: <39789B56.64E41D67@scanlaser.nl>
Bart Lateur wrote:
>
> Mark E. Drummond wrote:
>
> > (length($octet) == 1) ? $mac.="0$octet" : $mac.=$octet;
>
> You're abusing the "?:" operator set. This is how it was intended to be
> used:
>
> $mac .= (length($octet) == 1? "0$octet" : $octet;
syntax error at -e line 1, near "$octet;"
>
> And, uh, everybody must have told you by now you have aprecedence
> problem.
>
> And since you're trying to do some padding with zeroes, try this:
>
> @mac = map { sprintf '%02s', $_ } split /:/, $mac;
>
--
perl -e '$l=(@j=split//,"\nnPcutrete !A aJoekshlr rH");
$a=$l<<2&0x3f|1; do{print$j[$i+=$a,$i%=$l];} while $i;'
------------------------------
Date: Fri, 21 Jul 2000 19:12:12 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: What is the differance?
Message-Id: <c38hnsckt76mpp0kdnqiut7iegpqgo6adm@4ax.com>
Bert IJff wrote:
>> $mac .= (length($octet) == 1? "0$octet" : $octet;
>
>syntax error at -e line 1, near "$octet;"
Oops. opening paren too many, or closing paren too little.
$mac .= length($octet) == 1? "0$octet" : $octet;
or
$mac .= (length($octet) == 1)? "0$octet" : $octet;
--
Bart.
------------------------------
Date: 21 Jul 2000 21:27:28 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: What is the differance?
Message-Id: <8laf80$5f6$7@slb1.atl.mindspring.net>
Bart Lateur (bart.lateur@skynet.be) wrote:
: Bert IJff wrote:
:
: >> $mac .= (length($octet) == 1? "0$octet" : $octet;
: >
: >syntax error at -e line 1, near "$octet;"
:
: Oops. opening paren too many, or closing paren too little.
:
: $mac .= length($octet) == 1? "0$octet" : $octet;
: or
: $mac .= (length($octet) == 1)? "0$octet" : $octet;
Is this National Forget-about-sprintf week?
------------------------------
Date: Fri, 21 Jul 2000 21:43:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: What is the differance?
Message-Id: <otghnske9v80ctfqt8q7sdfau7cc9g6i6j@4ax.com>
Eric Bohlman wrote:
>Is this National Forget-about-sprintf week?
Haven't you seen my first reply? It contained this snippet:
@mac = map { sprintf '%02s', $_ } split /:/, $mac;
--
Bart.
------------------------------
Date: Fri, 21 Jul 2000 15:23:53 -0400
From: Jeffrey Scott Dunfee II <dunfeeje@pilot.msu.edu>
Subject: Win32::NetAdmin problems
Message-Id: <3978A349.209EE14B@pilot.msu.edu>
I keep getting a message that says:
cannot locate /Win32/NetAdmin/usersexists.pm in @inc (@inc contains
c:/perl/lib c:/perl/site/lib.)
when I try to run my perl script. It uses the
Win32::NetAdmin::UsersExist() function. I am using a Windows NT and I
donwload a NetAdmin zip file and unzipped it into both my c:/perl/lib
and my c:/perl/site/lib and it still gives me this error message. is
there anything else I need to do to install the NetAdmin? Is there a
place where I can get the NetAdmin add on to active perl for this that
maybe works??
-jeff
------------------------------
Date: Fri, 21 Jul 2000 20:07:05 +0200
From: Bert IJff <bert@scanlaser.nl>
To: Colin Larcombe <colin_larcombe@hotmail.com>
Subject: Re: Writing to a file error
Message-Id: <39789149.77129A3@scanlaser.nl>
Colin Larcombe wrote:
>
> The following code reads data from a file and then tries to output it to two
> files depending on the results
>
> #!/usr/local/bin/perl
> # Put all the bonds into an array, except the first two lines
> $filepath="/usr/users/larcombe/";
> $isinname="moody_bnd_upd.txt\n";
> $accept="acceptable.txt\n";
> $notaccept="notaccept.txt\n";
Are you sure you want the "\n" as a part of the filename.
> open(ACCEPT,">$filepath.$accept") || "Cannot open $filepath.$accept to write
> to";
Using the '.' you will create an invisible file (at least on Unix
systems)
that you can only list with "ls -a".
Other advices were given in previous answers.
> open(NOTACCEPT,">$filepath.$notaccept") || "Cannot open $filepath.$notaccept
> to write to";
> open(ISINS,$isinname);
> while ($isin = <ISINS>) {
> chop($isin); # Does the ISIN meet the criteria of being XX9999999999
> if ($isin =~ /[a-zA-Z]{2}[0-9]{10}/) {
> print ACCEPT $isin."\n";
> } else {
> print NOTACCEPT $isin."\n";
> }
> }
> close(ISINS);
> close(ACCEPT);
> close(NOTACCEPT);
>
> The reading and checking of the $isin works fine but the file writing
> doesn't. I have run it under debug but am limited to what I can see.
>
> 1) Is there anyway under debug to see if a file has been created.
> 2) Is there a better way of doing this
> 3) As a complete beginner (3rd day of Perl) is there another area I should
> post to.
>
> Many Thanks
>
> Colin Larcombe
Regards,
Bert
--
perl -e '$l=(@j=split//,"\nnPcutrete !A aJoekshlr rH");
$a=$l<<2&0x3f|1; do{print$j[$i+=$a,$i%=$l];} while $i;'
------------------------------
Date: Fri, 21 Jul 2000 14:55:18 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Writing to a file error
Message-Id: <39789C96.4CC8621@attglobal.net>
Neil Lathwood wrote:
>
> It may be because of the . between $filepath and $notaccept it should just
> be $filepath$notaccept
>
#!/usr/bin/perl -w
my $filepath = '/usr/bin/';
my $notaccept = 'hi_there';
print $filepath$notaccept; # line 6
print $filepath . $notaccept, "\n";
Output:
Scalar found where operator expected at ip.pl line 6, at end of line
(Missing operator before ?)
Filehandle main::/usr/bin/ never opened at ip.pl line 6.
/usr/bin/hi_there
the dot operator is used to concatenate.
------------------------------
Date: Fri, 21 Jul 2000 19:32:52 GMT
From: schnurmann@my-deja.com
Subject: Re: Writing to a file error
Message-Id: <8la8h4$s0n$1@nnrp1.deja.com>
The original code had the variables for path and file names quoted.
This created a "dot" file....that is, hidden...
In article <39789C96.4CC8621@attglobal.net>,
Drew Simonis <care227@attglobal.net> wrote:
> Neil Lathwood wrote:
> >
> > It may be because of the . between $filepath and $notaccept it
should just
> > be $filepath$notaccept
> >
>
> #!/usr/bin/perl -w
>
> my $filepath = '/usr/bin/';
> my $notaccept = 'hi_there';
>
> print $filepath$notaccept; # line 6
> print $filepath . $notaccept, "\n";
>
> Output:
>
> Scalar found where operator expected at ip.pl line 6, at end of line
> (Missing operator before ?)
> Filehandle main::/usr/bin/ never opened at ip.pl line 6.
> /usr/bin/hi_there
>
> the dot operator is used to concatenate.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 21 Jul 2000 21:50:21 +0200
From: Bert IJff <bert@scanlaser.nl>
To: Drew Simonis <care227@attglobal.net>
Subject: Re: Writing to a file error
Message-Id: <3978A97D.A0DB7A34@scanlaser.nl>
Drew Simonis wrote:
>
> Neil Lathwood wrote:
> >
> > It may be because of the . between $filepath and $notaccept it should just
> > be $filepath$notaccept
> >
>
> #!/usr/bin/perl -w
>
> my $filepath = '/usr/bin/';
> my $notaccept = 'hi_there';
>
> print $filepath$notaccept; # line 6
> print $filepath . $notaccept, "\n";
>
> Output:
>
> Scalar found where operator expected at ip.pl line 6, at end of line
> (Missing operator before ?)
> Filehandle main::/usr/bin/ never opened at ip.pl line 6.
> /usr/bin/hi_there
>
> the dot operator is used to concatenate.
In your example it is the dot operator, in the example of the OP was
written
open(NOTACCEPT,">$filepath.$notaccept") .......
where the . is used in a string (and is just an ordinary character),
and with
my $filepath = '/usr/bin/';
my $notaccept = 'hi_there';
file /usr/bin/.hi_there will be opened for writing (if permission
granted)
Reading is an art ;-)
--
perl -e '$l=(@j=split//,"\nnPcutrete !A aJoekshlr rH");
$a=$l<<2&0x3f|1; do{print$j[$i+=$a,$i%=$l];} while $i;'
------------------------------
Date: Fri, 21 Jul 2000 16:39:16 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Writing to a file error
Message-Id: <3978B4F4.45EC0DC5@attglobal.net>
Bert IJff wrote:
>
>
> file /usr/bin/.hi_there will be opened for writing (if permission
> granted)
>
> Reading is an art ;-)
>
I confess to not reading the OP.
$mistake++;
print "mistakes: $mistake";
Can Perl handle numbers that large?
------------------------------
Date: 21 Jul 2000 20:58:42 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Writing to a file error
Message-Id: <8ladi2$j8$1@internal-news.uu.net>
Drew Simonis <care227@attglobal.net> wrote:
> I confess to not reading the OP.
> $mistake++;
> print "mistakes: $mistake";
> Can Perl handle numbers that large?
Don't worry, after some time you'll end up with a negative amount
of mistakes, and then you can claim to be an expert :)
Erik
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3772
**************************************