[16348] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3760 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 20 14:15:49 2000

Date: Thu, 20 Jul 2000 11:15:28 -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: <964116928-v9-i3760@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 20 Jul 2000     Volume: 9 Number: 3760

Today's topics:
    Re: Odd or even ? (Anno Siegel)
    Re: Odd or even ? <graham.wood@iona.com>
    Re: Odd or even ? <bill.kemp@wire2.com>
    Re: Odd or even ? <care227@attglobal.net>
    Re: Odd or even ? schnurmann@my-deja.com
    Re: Odd or even ? <bert@scanlaser.nl>
    Re: perl rendering html tables - slow <linux@worsdall.demon.co.uk>
    Re: perl rendering html tables - slow <bert@scanlaser.nl>
    Re: Posting bug reports = mail spam?? <thunderbear@bigfoot.com>
    Re: Process problem (Helgi Briem)
    Re: Reading first MX (exchange record) <gellyfish@gellyfish.com>
    Re: Reading first MX (exchange record) nobull@mail.com
    Re: SSI - Stink like poo? <tonyboy@earthling.net>
    Re: Substr question : what about the fourth argument? <sariq@texas.net>
    Re: Substr question : what about the fourth argument? (Abigail)
    Re: Substr question : what about the fourth argument? <cal@iamcal.com>
        Understanding Perl Idiom (Please Help) kenlaird@my-deja.com
    Re: variable cheching ? (Tad McClellan)
        View/Modify Read Only Attribute in Windows 98 omw61478@my-deja.com
    Re: View/Modify Read Only Attribute in Windows 98 <bert@scanlaser.nl>
        What is the differance? <drummond-m@rmc.ca>
    Re: What is the differance? <newsposter@cthulhu.demon.nl>
    Re: What is the differance? <billy@arnis-bsl.com>
    Re: What is the differance? <aqumsieh@hyperchip.com>
    Re: Where on the net can I <gellyfish@gellyfish.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 20 Jul 2000 15:11:56 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Odd or even ?
Message-Id: <8l74rt$mgb$1@lublin.zrz.tu-berlin.de>

Jimmy Lantz  <webmaster@ostas.lu.se> wrote in comp.lang.perl.misc:
>Hi,
>
>
>The thing I need is to get every other item to be treated differently. 
>I thought to make the distinction odd or even number then treat the
>objects differently depending if its odd or even. 

[snippage]

>Does anyone has a clue on how to go about it?

Yes. Look up the % operator.

Anno
-- 
"Its not bad design, its a cgi script!"


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

Date: Thu, 20 Jul 2000 16:10:45 +0100
From: "Graham Wood" <graham.wood@iona.com>
Subject: Re: Odd or even ?
Message-Id: <8l754n$f1j$1@bvweb.iona.com>

Use the modulus operator %.  This returns the remainder when you divide by
the second argument.  Therefore %2 returns either 0 if your number is
divisible by 2 or 1 if it isn't.

if($number % 2){
    #ODD (non-zero is true)
}
else{
   # EVEN (zero is false)
}
Jimmy Lantz <jimmy.lantz@ostas.lu.se> wrote in message
news:397715C3.357FDDFC@ostas.lu.se...
> Hi,
>
>
> The thing I need is to get every other item to be treated differently.
> I thought to make the distinction odd or even number then treat the
> objects differently depending if its odd or even.
>
> I'm trying to do the following:
> ################
> #!perl
>
> $number = 0;
>
> foreach $item (@in_array)
> {
>
> #Find out if the scalar $number is an odd or even number
> if ($number = odd)
> {
> #do something
> }
> else
> {
> #do something else
> }
>
> $number++;
>
> }
> ########################
>
> Does anyone has a clue on how to go about it?
>
> Yours sincerely
> Jimmy Lantz
> Sweden




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

Date: Thu, 20 Jul 2000 16:27:16 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: Odd or even ?
Message-Id: <964106986.2104.0.nnrp-13.c3ad6973@news.demon.co.uk>


Jimmy Lantz wrote in message <397715C3.357FDDFC@ostas.lu.se>...
>Hi,
>
>
>The thing I need is to get every other item to be treated differently.
>I thought to make the distinction odd or even number then treat the
>objects differently depending if its odd or even.
>
>I'm trying to do the following:
>################
>#!perl
>
>$number = 0;
>
>foreach $item (@in_array)
>{>
>#Find out if the scalar $number is an odd or even number
>if ($number = odd)
>{
>#do something
>}
>else
>{
>#do something else
>}

>$number++;>
>}


If its not really odd or even, just give alternate treatments, and $number
isn't used, I like this one-
my $i=0;
foreach (@list){
    if (1-$i){
        #one treatment
    }else{
        #other treatment
    }
}




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

Date: Thu, 20 Jul 2000 11:26:37 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Odd or even ?
Message-Id: <39771A2D.8E4FBA1@attglobal.net>

Jimmy Lantz wrote:
> 
> Hi,
> 
> The thing I need is to get every other item to be treated differently.
> I thought to make the distinction odd or even number then treat the
> objects differently depending if its odd or even.
> 
> I'm trying to do the following:
> ################
> #!perl
> 
> $number = 0;
> 
> foreach $item (@in_array)
> {
> 
> #Find out if the scalar $number is an odd or even number
> if ($number = odd)

If you are posting psuedo-code, say so.  I sure as heck hope
that the above code is your idea of psuedo-code, because 
otherwise, you need alot more help than anyone here can provide.

$number = odd ?  Thats an assignment operator. 
you use foreach $item (@in_array) but then I don't see you doing 
anything with $item, resorting back to $number, which you had 
started with a value of 0, then changed it to the string 'odd',
and you are then doing an increment on the word odd?  wow.

> Does anyone has a clue on how to go about it?

Yes.  Its simple math.  If a number is divisble by 2, it is even.
If it is not, it is odd.  So, we want to divide the number by 2 and 
see if there is a remainder.  For this, we use the % operator (called
the modulus operator).  

#!/usr/bin/perl -w
use strict;

my $a = 9;
my $b = 2;


my $c = $number % $b;

if ($c == 0){
	print "$a is even!"
}else{
	print "$a is odd!"
}  

	
I hope you can take it from there.


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

Date: Thu, 20 Jul 2000 16:23:46 GMT
From: schnurmann@my-deja.com
Subject: Re: Odd or even ?
Message-Id: <8l791q$rpu$1@nnrp1.deja.com>

Let n be any element in {I}. Even: n MOD 2 = 0.  Odd: n MOD 2 = 1.
That is, any even n will be 2p and any odd n will be 2p+1.

In Perl:

if (n % 2) ## it is odd
{
  ## do "odd" stuff
}
else
{
  ## do even stuff
}

In article <397715C3.357FDDFC@ostas.lu.se>,
  webmaster@ostas.lu.se wrote:
> Hi,
>
> The thing I need is to get every other item to be treated
differently.
> I thought to make the distinction odd or even number then treat the
> objects differently depending if its odd or even.
>
> I'm trying to do the following:
> ################
> #!perl
>
> $number = 0;
>
> foreach $item (@in_array)
> {
>
> #Find out if the scalar $number is an odd or even number
> if ($number = odd)
> {
> #do something
> }
> else
> {
> #do something else
> }
>
> $number++;
>
> }
> ########################
>
> Does anyone has a clue on how to go about it?
>
> Yours sincerely
> Jimmy Lantz
> Sweden
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 20 Jul 2000 19:27:27 +0200
From: Bert IJff <bert@scanlaser.nl>
Subject: Re: Odd or even ?
Message-Id: <3977367F.877F6FCE@scanlaser.nl>



W Kemp wrote:
> 
> Jimmy Lantz wrote in message <397715C3.357FDDFC@ostas.lu.se>...
> >Hi,
> >
> >
> >The thing I need is to get every other item to be treated differently.
> >I thought to make the distinction odd or even number then treat the
> >objects differently depending if its odd or even.
> >
> >I'm trying to do the following:
> >################
> >#!perl
> >
> >$number = 0;
> >
> >foreach $item (@in_array)
> >{>
> >#Find out if the scalar $number is an odd or even number
> >if ($number = odd)
> >{
> >#do something
> >}
> >else
> >{
> >#do something else
> >}
> 
> >$number++;>
> >}
> 
> If its not really odd or even, just give alternate treatments, and $number
> isn't used, I like this one-

Untested!!!
This only does treatment one

> my $i=0;
> foreach (@list){
>     if (1-$i){
>         #one treatment
>     }else{
>         #other treatment
>     }
> }

use of XOR does the trick as wanted
Correct (tested) code snippet

my $i=0;
foreach (@list){
      if ($i^=1){
         print "one treatment\n";
     }else{
         print "other treatment\n";
     }
}

hth,
Bert


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

Date: Thu, 20 Jul 2000 17:01:58 +0100
From: Mark Worsdall <linux@worsdall.demon.co.uk>
Subject: Re: perl rendering html tables - slow
Message-Id: <yKXFEtA2Jyd5Ewya@worsdall.demon.co.uk>

In article <964082947.3065.4.nnrp-09.c29f015a@news.demon.co.uk>, Gus
<gus@black.hole-in-the.net> writes
>Mark Worsdall <linux@worsdall.demon.co.uk> wrote:
>> Hi,
>
>> I am rendering an html table from a data file, this csv file is 67K in
>> size, it has 887 records, each record has 6 fields, it takes over
>> 1minute 8 seconds an an ISDN 64K link.
>
>Are you /sure/ that it does ? Have you tested this without a browser to 
>make sure that it is the script which is causing the delay ?
>
>I just tried the URL >/dev/null  and the transfer took 5 seconds. Perhaps
>the delay is in the rendering of the table.
>

This is new 2 me. Yep thought the delay was there, might use a
start/stop/start/stop multiple tables routine (i.e. split the table into
lots of tables.

>
>> So how to render partially as we get the data or to speed up generally?
>
>Probably more of a question for comp.infosystems.www.authoring.cgi or
>comp.infosystems.www.authoring.html
>

OK, guess this is another group's issue, wanted too check if there were
any known issues with perl 1st.

-- 
Mark Worsdall - Oh no, I've run out of underpants :(
Home:- jaydee@wizdom.org.uk       http://www.wizdom.org.uk
Shadow:- webmaster@shadow.org.uk  http://www.shadow.org.uk
Work:- netman@hinwick.demon.co.uk http://www.hinwick.demon.co.uk
Web site Monitoring:-             http://www.shadow.org.uk/SiteSight/


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

Date: Thu, 20 Jul 2000 18:33:53 +0200
From: Bert IJff <bert@scanlaser.nl>
To: Mark Worsdall <linux@worsdall.demon.co.uk>
Subject: Re: perl rendering html tables - slow
Message-Id: <397729F1.2E57FE08@scanlaser.nl>



Mark Worsdall wrote:
> 
> Hi,
> 
> I am rendering an html table from a data file, this csv file is 67K in
> size, it has 887 records, each record has 6 fields, it takes over
> 1minute 8 seconds an an ISDN 64K link.

Saving the frame on my disk takes up 508K, because of all the HTML
formatting, 8 times as big as your original file. 
May be it is possible to set the font once for the whole table, in
stead of setting it for each individual cell.

hth
Bert

<---snipped other text--->


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

Date: Thu, 20 Jul 2000 17:15:09 +0200
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: Posting bug reports = mail spam??
Message-Id: <3977177D.F8753A3B@bigfoot.com>

The WebDragon wrote:

> Anything that remains in Inbox itself is 99% likely to be spam, as 100%
> of the time, spam is 'hidden' via 'Bcc:' :)

Spammers are improving, and I get spam with my email adress
in the To: line.

I am considering revising this so that my name needs to be
in the To: line too, as this is typical for a reply or a
follow-up.  This is naturally only for email adresses used
on Usenet.

-- 
  Thorbjørn Ravn Andersen         "...plus...Tubular Bells!"
  http://bigfoot.com/~thunderbear


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

Date: Thu, 20 Jul 2000 16:14:38 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Process problem
Message-Id: <39772528.180575894@news.itn.is>

On Thu, 20 Jul 2000 06:14:56 -0400, James
<jamesmckay@MailAndNews.com> wrote:

>Hi All,
>      I'm currently stuck on a NT scripting problem.  I'm writing a script 
>which  calls an external  16-bit DOS program via the "system()" call.  This 
>external program generates a data file which my script then uses.
>
>Unfortunately the DOS program is rather slow, so by the time it's halfway 
>thru, my script has raced ahead and then gives an error, because the file it 
>needs is only half complete.
>
>I can't just use a "sleep" command, as the DOS program's speed is very 
>dependant upon our network's current load, so sometimes it's fast and 
>sometimes it's very, very slow!
>
>What I need is a way to halt execution of my script at this point until the 
>DOS program completes.  I've tried using the "wait" command but it appears 
>to 
>behave very differently to its Unix counterpart - in that it is completely 
>ignored.

I am hardly an expert, but this seems to do what you require

#Set value of $largenumber and $datafile here

for (1..$largenumber){
	if (-e $datafile) 
	{ 	
		# process $datafile here
		last;
	} 
	sleep 1;
}



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

Date: Thu, 20 Jul 2000 15:26:37 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Reading first MX (exchange record)
Message-Id: <NSEd5.598$Px6.52914@news.dircon.co.uk>

On Wed, 19 Jul 2000 15:52:32 -0700, steve cramton Wrote:
> use Net::DNS;
> 
> $name = "foo.com";
> $res = new Net::DNS::Resolver;
> @mx = mx($res, $name) ;
> 
> if (@mx) {
> foreach $rr (@mx) {
> print $rr->preference, " ", $rr->exchange, "\n";
> }
> }
> else {
> print "can't find MX records for $name: ", $res-
> 
> 
> errorstring, "\n";
> 
> }
> $mailhost = $name ;
> 
> -----------------------------------------------------------
> 
> 
> I've just been reading my post. The question i posted does not
> make it clear what i am trying to achive.
> 
> Of course I know how to get the value of the mailhost.
> What i am trying to do is to get rid of the foreach part and
> just read the first returned exchange record (if present) into a
> varible and move on.
> 

$mx[0]->exchange at a guess.


/j\


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

Date: 20 Jul 2000 17:38:47 +0100
From: nobull@mail.com
Subject: Re: Reading first MX (exchange record)
Message-Id: <u9wvigeoyw.fsf@wcl-l.bham.ac.uk>

steve cramton <scrampton71NOscSPAM@hotmail.com.invalid> writes:

> Of course I know how to get the value of the mailhost.
> What i am trying to do is to get rid of the foreach part and
> just read the first returned exchange record (if present) into a
> varible and move on.

Given an array @foo the first element is $foo[0].

Given a function foo() that returns a list you can get the first
element as (foo())[0] without having to create an array.

Note: the fact that you want "the first returned exchange record (if
present)" means then there probably something badly wrong with your
design - but that's not a Perl issue.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 20 Jul 2000 12:41:10 -0400
From: Anthony Lalande <tonyboy@earthling.net>
Subject: Re: SSI - Stink like poo?
Message-Id: <B59CA3E6.517E%tonyboy@earthling.net>

Glen Heide wrote on 20/07/2000 1:04 AM:

> I wrote a little CGI script which simply prints to the standard output
> "Hello", and the SHTML file that I use has the contents as follows:
> <TABLE><TR><TD><!--#exec cgi="/cgi-bin/helloworld.cgi" --></TD></TR></TABLE>
> 
> The resulting HTML file that the server returns has nothing from the CGI
> script.  It only returns
> <TABLE><TR><TD></TD></TR></TABLE>
> 
> I also tested it with a longer running script which reads 2 large files, so
> I know they're being ran, but I still get no output.  Do server side include
> files do what I'm trying to do?  (Print hello in the table)  Or are they
> simply pieces of code to be "executed".  Can anyone help?  It would be
> greatly appreciated.
> 

SSIs are able to execute code as well as return output. The classic example
being the counter. What you might want to try:

When you print back to the web page, prefix your output with:

    print "Content-type: text/html\n\n";

Also, you'll want to make sure your permission on the executable file are
set correctly (chmod a+x ...). Basically, debug your program by testing
helloworld.pl as a normal web page. When that works, SSIs should work.

You'll also want to make sure any permissions are set properly for SSIs to
work. You might have to rename your file from *.html to *.shtml, or add a
 .htaccess file to your directory.

Hope this helps.
I've been down this road quite a few times, if you need more help, feel free
to ask.
- Anthony L.



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

Date: Thu, 20 Jul 2000 10:22:41 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Substr question : what about the fourth argument?
Message-Id: <39771941.42B961E@texas.net>

Cal Henderson wrote:
> 
> "Abigail" <abigail@delanet.com> wrote...
> :
> : Which docs that should mention it don't mention it?
> 
> Programming Perl, 2nd Edition, Page 227

Bzzzt!

That came out *way* before 5.005.

- Tom


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

Date: 20 Jul 2000 11:24:10 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Substr question : what about the fourth argument?
Message-Id: <slrn8ne7e0.3do.abigail@alexandra.delanet.com>

Cal Henderson (cal@iamcal.com) wrote on MMDXV September MCMXCIII in
<URL:news:AvEd5.452$yE4.7531@news2-win.server.ntlworld.com>:
:: 
:: "Abigail" <abigail@delanet.com> wrote...
:: :
:: : Which docs that should mention it don't mention it?
:: :
:: 
:: Programming Perl, 2nd Edition, Page 227


I don't think a book that documents Perl 5.003 should describe a feature
introduced in 5.005.


Abigail
-- 
perl -we'$;=$";$;{Just=>another=>Perl=>Hacker=>}=$/;print%;'


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

Date: Thu, 20 Jul 2000 16:38:12 +0100
From: "Cal Henderson" <cal@iamcal.com>
Subject: Re: Substr question : what about the fourth argument?
Message-Id: <e1Fd5.476$yE4.7595@news2-win.server.ntlworld.com>


"Abigail" <abigail@delanet.com> wrote in...
:
: I don't think a book that documents Perl 5.003 should describe a feature
: introduced in 5.005.
:

Ahh - thankyou for the enlightenment.


--
Cal Henderson

sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift@a,$a;}sub b{$c.=reverse
shift; while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);
shift@b;}}@b=(6,3,5,4,10,6,4,4,2,1);$a="l?jouipv"."ezvmxpbuxih";$a.=
",jofoqqibmzamsfsfxfjtuiIg";while($a ne ""){b(substr($a,0,2));$a=
substr($a,2);}print join(" ",@a);




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

Date: Thu, 20 Jul 2000 17:36:08 GMT
From: kenlaird@my-deja.com
Subject: Understanding Perl Idiom (Please Help)
Message-Id: <8l7da7$v3c$1@nnrp1.deja.com>

I've got this script:

#!/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.

Ken Laird


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 20 Jul 2000 11:12:12 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: variable cheching ?
Message-Id: <slrn8ne96s.10c.tadmc@maxim.metronet.com>

On Wed, 19 Jul 2000 23:20:39 +0200, Ed Bras <e.bras@hccnet.nl> wrote:

>How can I check the existens of a variable, which name is stored in another
>variable ?


Assuming that the variable is a lexical variable (and nearly
all user-defined variables _should be_ lexicals), then
you cannot do it.


>I don't how to use the values stored in a variable as a variable name !!


That is a _good_ thing. You will be better off if you continue
to not know how to do it, because then you won't do it :-)

You will use a different approach instead.

Like having it be a hash key instead of a variable, then
using the exists() function.



Symbolic references are evil:

   http://www.plover.com/~mjd/perl/varvarname.html
   http://www.plover.com/~mjd/perl/varvarname2.html
   http://www.plover.com/~mjd/perl/varvarname3.html


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 20 Jul 2000 15:38:15 GMT
From: omw61478@my-deja.com
Subject: View/Modify Read Only Attribute in Windows 98
Message-Id: <8l76d3$pjl$1@nnrp1.deja.com>

Hello,

Is there a way to view/modify the read-only attribute for files in
Windows 98?  I would like to make a script that changes the read-only
setting for files with certain extensions.  The only problem is that
whenever I try to change the read only attribute it doesn't work.  I
have tried two things: (1) reading attributes from the File::stat
package using the mode method and (2) using the GetArributes method in
the Win32::File package.  Examples of both are below.

#File::stat example:
use File::stat;

$test = stat("c:/windows/desktop/test.txt");
print $test->mode;

#prints '33206' - what does this mean?


#Win32::File
use Win32::File;

GetAttributes("c:/windows/desktop/test.txt" , $results);
print $results;

#prints 'Undefined subroutine &main::GetAttributes called at test.pl
line 7.' - Am I using the GetArributes method incorectly?

TIA,
Owen Williams


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 20 Jul 2000 19:46:45 +0200
From: Bert IJff <bert@scanlaser.nl>
To: omw61478@my-deja.com
Subject: Re: View/Modify Read Only Attribute in Windows 98
Message-Id: <39773B05.4CE9167C@scanlaser.nl>



omw61478@my-deja.com wrote:
> 
> Hello,
> 
> Is there a way to view/modify the read-only attribute for files in
> Windows 98?  I would like to make a script that changes the read-only
> setting for files with certain extensions.  The only problem is that
> whenever I try to change the read only attribute it doesn't work.  I
> have tried two things: (1) reading attributes from the File::stat
> package using the mode method and (2) using the GetArributes method in
> the Win32::File package.  Examples of both are below.
> 
> #File::stat example:
> use File::stat;
> 
> $test = stat("c:/windows/desktop/test.txt");
> print $test->mode;
> 
> #prints '33206' - what does this mean?

This decimal number gives more info when printed in octal:
33206 (dec) => 100666 (oct)

This octal number shows you have a regular file that has read and
write permissions set for owner, group and other.

See the following definitions taken from my Unix system file 
/usr/include/sys/stat.h:

#  define _S_IFMT   0170000     /* type of file */
#  define _S_IFREG  0100000     /* regular */
#  define _S_IFBLK  0060000     /* block special */
#  define _S_IFCHR  0020000     /* character special */
#  define _S_IFDIR  0040000     /* directory */
#  define _S_IFIFO  0010000     /* pipe or FIFO */

#    define S_ISUID 0004000     /* set user ID on execution */
#    define S_ISGID 0002000     /* set group ID on execution */

#    define S_IRWXU 0000700     /* read, write, execute permission
(owner) */
#    define S_IRUSR 0000400     /* read permission (owner) */
#    define S_IWUSR 0000200     /* write permission (owner) */
#    define S_IXUSR 0000100     /* execute permission (owner) */

#    define S_IRWXG 0000070     /* read, write, execute permission
(group) */
#    define S_IRGRP 0000040     /* read permission (group) */
#    define S_IWGRP 0000020     /* write permission (group) */
#    define S_IXGRP 0000010     /* execute permission (group) */

#    define S_IRWXO 0000007     /* read, write, execute permission
(other) */
#    define S_IROTH 0000004     /* read permission (other) */
#    define S_IWOTH 0000002     /* write permission (other) */
#    define S_IXOTH 0000001     /* execute permission (other) */

> 
> #Win32::File
> use Win32::File;
> 
> GetAttributes("c:/windows/desktop/test.txt" , $results);
> print $results;
> 
> #prints 'Undefined subroutine &main::GetAttributes called at test.pl
> line 7.' - Am I using the GetArributes method incorectly?
> 
> TIA,
> Owen Williams
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.


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

Date: Thu, 20 Jul 2000 11:12:09 -0400
From: "Mark E. Drummond" <drummond-m@rmc.ca>
Subject: What is the differance?
Message-Id: <397716C9.DA172CA2@rmc.ca>

The following 2 pieces of code give me differant results for what I am
trying to accomplish (q.v.).

snippet 1
---------
@mac=split(/:/,$mac); undef $mac;
foreach $octet (@mac) {
	(length($octet) == 1) ? $mac.="0$octet" : $mac.=$octet;
}

snippet 2
---------
@mac=split(/:/,$mac); undef $mac;
foreach $octet (@mac) {
	if (length($octet)==1) {
		$mac.="0$octet";
	} else {                
		$mac.=$octet;
	}
}

@mac is an array whose elements are the individual octets of a machine's
MAC address, where leading zeros may or may not be preset for single
digit values. The idea of the code is to ensure that all octets _do_
have leading zeros where required. In other words, this MAC

	8:0:20:ab:cd:ef

becomes

	080020abcdef

The problem is that the first snippet gives me the wrong results. The
above example address is being created by the first code bit as

	08800020abcdef

You can see that the octets which are already 2 hex digits come out
fine, but those that are one hex digit are all screwed up. In fact, the
above incorrect address would be the result, if, for the single hex
digits, _both_ code segments in the conditional operator were executed.

What the? Any ideas?

-- 
Mark Drummond|ICQ#19153754|mailto:mark.drummond@rmc.ca
UNIX System Administrator|Royal Military College of Canada
The Kingston Linux Users Group|http://signals.rmc.ca/klug/
Saving the World ... One CPU at a Time

Please excuse me if I am terse. I answer dozens of emails every day.


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

Date: 20 Jul 2000 15:48:35 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: What is the differance?
Message-Id: <8l770j$rpo$1@internal-news.uu.net>

Mark E. Drummond <drummond-m@rmc.ca> wrote:
> The following 2 pieces of code give me differant results for what I am
> trying to accomplish (q.v.).

> 	(length($octet) == 1) ? $mac.="0$octet" : $mac.=$octet;

This does not do what you think it does. Operator priorities ...

Write this as:
   $mac .= (length($octet) == 1) ? "0$octet" : $octet;

Erik



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

Date: Thu, 20 Jul 2000 16:56:01 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: What is the differance?
Message-Id: <8l7auo$tf0$1@nnrp1.deja.com>

In article <397716C9.DA172CA2@rmc.ca>,
  "Mark E. Drummond" <drummond-m@rmc.ca> wrote:
> The following 2 pieces of code give me differant results for what I am
> trying to accomplish (q.v.).
>
> snippet 1
> ---------
> @mac=split(/:/,$mac); undef $mac;
> foreach $octet (@mac) {
> 	(length($octet) == 1) ? $mac.="0$octet" : $mac.=$octet;
> }
>

IMHO you mean:

length($octet) == 1 ? ($mac.="0$octet") : ($mac.=$octet)

See perldoc perlop about operator precedence.

Or maybe more compact:

$mac = join '' => map {length==1? "0$_" : $_} split(/:/,$mac);

Hope this helps.
Ilja.



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 20 Jul 2000 18:03:19 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: What is the differance?
Message-Id: <7abszsisr9.fsf@merlin.hyperchip.com>


Ilja Tabachnik <billy@arnis-bsl.com> writes:

> length($octet) == 1 ? ($mac.="0$octet") : ($mac.=$octet)
> 
> See perldoc perlop about operator precedence.
> 
> Or maybe more compact:
> 
> $mac = join '' => map {length==1? "0$_" : $_} split(/:/,$mac);

You have one weird definition for 'compact'!

:-)

--Ala


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

Date: Thu, 20 Jul 2000 15:27:37 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Where on the net can I
Message-Id: <JTEd5.599$Px6.52914@news.dircon.co.uk>

On Wed, 19 Jul 2000 11:56:58 +0200, Hans Kvalheim Wrote:
> find more info about PERL?
> 

www.google.com


/J\


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

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


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