[7834] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1459 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 12 00:07:27 1997

Date: Thu, 11 Dec 97 21:00:24 -0800
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, 11 Dec 1997     Volume: 8 Number: 1459

Today's topics:
     Re: /string/o <reibert@mystech.com>
     Re: a certain bug...!!! <rootbeer@teleport.com>
     Re: Can Perl handle Chinese(or other Asian languages)? <ha8s-jsp@asahi-net.or.jp>
     Re: Can't 'print' large (> 6M) files <rootbeer@teleport.com>
     Re: GIFgraph legend (Martien Verbruggen)
     Help a newbie out <ewalti@ix.netcom.com>
     Re: Help with a regex (Martien Verbruggen)
     Re: how to hide .pl file (Martien Verbruggen)
     Re: just starting with perl <reibert@mystech.com>
     Re: just starting with perl <rhodri@wildebst.demon.co.uk>
     Re: just starting with perl (Jim Michael)
     Re: Memory leak (perl 5.004_04) <rootbeer@teleport.com>
     Memory leak in perl 5.004_04 (Ken)
     Re: Memory leak in perl 5.004_04 (Ilya Zakharevich)
     mkdir not recoginizing mode <rshadian@hawaii.edu>
     Re: mkdir not recoginizing mode (Mike Stok)
     Re: Mysql -> DBI (Ian Baker)
     Older versions of swatch (Nobody, Really)
     Re: Older versions of swatch <tdudek@ncsa.uiuc.edu>
     Perl Modules Info <nic@cyber-west.com>
     Re: Perl support for the long long type <rootbeer@teleport.com>
     Reading serial ports using perl 5 under Win95... (Kevin Ow-Wing)
     Running NT "Net User ..." from Perl ozie@ganet.org
     Shoving an array into a glob? or fixing IO::ScalarArray schwern@rt1.net
     Re: There's More Than One Way? (Martien Verbruggen)
     Re: trapping errors from IPC::Open2 (Charles DeRykus)
     Re: untainting data <reibert@mystech.com>
     Using a fork (help needed) (David Waring)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 11 Dec 1997 16:25:15 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: /string/o
Message-Id: <3490765B.873D3C01@mystech.com>

Blake D. Mills IV wrote:

> I just inherited some code that has:
>
>     m/constant/o
>
> all over the place.  I understand the benefit of the /o modifier when
> the regex could change (but you know it wont)... ie:
>
>     m/$var/o
>
> However, perl does quite a bit behind the scenes and I wouldn't be
> surprised if m/constant/ was equivalent to m/constant/o since the regex
> can't be modified.
>
> I looked in the documentation, and didn't find the answer.  I suppose
> I'll try benchmarking the two snippets to see if there is any difference
> in performance... unless someone out there knows the answer. ;-)
>
> Thanks.
>
> -Blake

I don't believe it! I have wrestled with the exact same question and have
had
the same difficulty finding an answer. I have been using the /o because it
can't hurt, but it would be nice not to worry about it if Perl is smart
enough
to use an implied /o if the pattern is constant. Hopefully someone knows the

answer here!

Mark Reibert

-----------------------------
   Mark S. Reibert, Ph.D.

  Mystech Associates, Inc.
  3233 East Brookwood Court
   Phoenix, Arizona 85044

    Tel: (602) 732-3752
    Fax: (602) 706-5120
 E-mail: reibert@mystech.com
-----------------------------




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

Date: Thu, 11 Dec 1997 18:50:00 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Zenin <zenin@best.com>
Subject: Re: a certain bug...!!!
Message-Id: <Pine.GSO.3.96.971211184851.22475D-100000@user2.teleport.com>

On 11 Dec 1997, Zenin wrote:

> 	When opened with "+>>" you can ONLY read data that you (or someone
> 	else...) has added since you opened it.  You can NOT read the data
> 	already in the file, even with a seek (FH, 0, 0). 

That's not the case on my system, which is running SunOS. What system did
you find that to be true on?

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Fri, 12 Dec 1997 13:27:55 +0900
From: Stuart Price <ha8s-jsp@asahi-net.or.jp>
Subject: Re: Can Perl handle Chinese(or other Asian languages)?
Message-Id: <3490BD4B.6818DA1E@asahi-net.or.jp>

My perl scripts handle Japanese OK.  

Uploading data files as ASCII scrambles the Japanese, so I have to
upload as binary, which scrambles line feeds.  But any input done
directly goes well.
-- 


regards



     Stuart Price
     Asahi Net
     ha8s-jsp@asahi-net.or.jp
     http://www.4est.com/


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

Date: Thu, 11 Dec 1997 18:53:43 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ben Rector <brector@bnr.ca>
Subject: Re: Can't 'print' large (> 6M) files
Message-Id: <Pine.GSO.3.96.971211185126.22475E-100000@user2.teleport.com>

On Thu, 11 Dec 1997, Ben Rector wrote:

>     I have been have problems printing files larger than 2Mb with
> "print" and  6Mb with "syswrite".
> Each time I try to print I get an "Out of Memory!" error. 

Sounds as if you're running out of memory. :-)

Are you printing these one line at a time, in other suitably-small chunks,
or megabytes at a time? If you're trying to print more than, say, 256K at
once, you may be doing something that your system never expected. Try
outputting perhaps 8K at a time and see whether that fixes things. Good
luck! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 12 Dec 1997 04:25:27 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
To: tedgren@ford.com
Subject: Re: GIFgraph legend
Message-Id: <66qebn$23p$3@comdyn.comdyn.com.au>

[ CC by email ]

In article <348EC42B.5171@ford.com>,
	Tim Edgren <tedgren@ford.com> writes:
> I've looked at (and run) the sample scripts for Martien's GIFgraph, but
> don't seem to find a way to build a legend among the option
> documentation.  Is there a way to use the logo option (or some other
> way) to show a dynamically-built legend?
> 
> I'm currently using gnuplot (which supports legends, albeit rather
> inflexibly) but I'd rather have a bit more control over my various
> graphs.

Hi Tim,

I replied to this earlier, but our news server decided to fall over,
and lots of posts got lost.

At the moment GIFgraph doesn't support legends (it's an alpha release)
but I have started working on it again, and hope to release a newer
version in January which does.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.       | Gates?
NSW, Australia                      | 


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

Date: Thu, 11 Dec 1997 16:21:45 -0800
From: Eric <ewalti@ix.netcom.com>
Subject: Help a newbie out
Message-Id: <34908399.8C34649@ix.netcom.com>

Hi. I'm good at HTML and i know java too. Now i figure its time to move
onto CGI. Right? Anyways, i dont have the slightest idea about CGI. Can
someone help me out? help me get started? Any good tutorials out there?
Somone please help!!! thanx


Vertis



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

Date: 12 Dec 1997 04:17:02 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Help with a regex
Message-Id: <66qdru$23p$2@comdyn.comdyn.com.au>

[Reposting a mail I sent before our fu^H^Hnews server fell over a few
days ago. There are other answers now as well, but I did the work of
replying, and I'll be damned if I don't see it as a post :)]

In article <66im51$6qb$1@news.digifix.com>,
    sanguish@digifix.com (Scott Anguish) writes:
> 
> I'm attempting to breakdown different file entries...
> 
> Filename.1.0.PIs.tgz
> Filename.1.3.W.tgz
> Filename.PI.tgz
> Flex.files.2.0.tgz
> 
> The parts are 
> 
> filename,version (optional), keyletters some combination of PIWMs 
> (optional) followed by a known file extension..
> 
> I seem to have no problem breaking out the common situation when they 
> are all present, but I'm having problems with the optional 
> situations...
>
> ($filename,$version,$archs)=$a=~/^(.*)\.(\d+\.*\d+)\.([PIWMs]*)\.tgz$/
> ;

A few remarks:

- This regex assumes 3 dots in every file name, which will break on
  the third. 
- If the version number is optional, the dot before it is also
  optional, and the same goes for the PIWMs field. 
- In this regex, the version number always has to be present
  (\d+\.*\d+) assumes at least a string of digits.

Possibly better would be:

---- SNIP ----
#!/usr/local/bin/perl5 -w

use strict;

printf "%-20s %-12s %-8s\n\n", "File Name", "Version", "PIWMs";

while (<DATA>)
{
    chomp;

    my ($filename, $version, $PIWMs) = 
        m{
            ^(.*?)                      # file name (match non-greedy)
            \.?                         # 0 or 1 dot
            (\d+\.\d+)?                 # 0 or 1 version number
            \.?                         # 0 or 1 dot
            ([PIWMs]*)                  # PIWMs field (might be empty)
            \.tgz                       # extension
            $                           # The end
        }x;

    # The defined's are here to prevent warnings about uninitialised
    # variables
    printf "%-20s %-12s %-8s\n", 
        defined $filename ? $filename : "", 
        defined $version  ? $version  : "", 
        defined $PIWMs    ? $PIWMs    : "";
}

__DATA__
Filename.1.0.PIs.tgz
Filename.foo.1.3.W.tgz
Filename.bar.PI.tgz
Flex.files.2.0.tgz
perl.5.00404.tgz
---- SNIP ----

Output:

File Name            Version      PIWMs

Filename             1.0          PIs
Filename.foo         1.3          W
Filename.bar                      PI
Flex.files           2.0
perl                 5.00404

Instead of building a complex regexp, you can also use split, and
process the resulting list. A bit of benchmarking would need to go
into it to figure out what is more efficient.

The following might be a good starting point, although you'll need to
build in some checking yourself to see if @ff still contains anything,
and to see if the version number is valid. I also didn't attempt to
make the code terse..

---- SNIP ----
#!/usr/local/bin/perl5 -w

#use strict;

printf "%-20s %-12s %-8s\n\n", "File Name", "Version", "PIWMs";

while(<DATA>)
{
    my ($PIWMs, $version, $filename) = ( "", "", "" );

    chomp;
    my @ff = split /\./;

    # get rid of extension
    pop(@ff);

    my $ff = pop(@ff);

    if ($ff =~ /^[PIWMs]+$/)
    {
        # Found a PIWMs field
        $PIWMs = $ff;
        $ff = pop(@ff);
    }

    if ($ff =~ /^\d+$/)
    {
        $version = pop(@ff) . '.' . $ff;
        $filename = join( '.', @ff);
    }
    else
    {
        $filename = join( '.', @ff, $ff);
    }

    printf "%-20s %-12s %-8s\n", $filename, $version, $PIWMs;
}

__DATA__
Filename.1.0.PIs.tgz
Filename.foo.1.3.W.tgz
Filename.bar.PI.tgz
Flex.files.2.0.tgz
perl.5.00404.tgz
---- SNIP ----

Output:
File Name            Version      PIWMs

Filename             1.0          PIs
Filename.foo         1.3          W
Filename.bar                      PI
Flex.files           2.0
perl                 5.00404

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd.       | clothes.
NSW, Australia                      | 


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

Date: 12 Dec 1997 04:08:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: how to hide .pl file
Message-Id: <66qdci$23p$1@comdyn.comdyn.com.au>

Nathan Stanford <nathan@cyberservices.com> writes:
> venkat5@hotmail.com wrote:
> 
>> I want to hide the .pl program from being read from others. Is there any
>> way to do it? I am using Perl 5 under WindowsNT 4.0 Please reply me at
>> venkat5@hotmail.com Regards. venkat.
>>
>  If you haven't figured it out or gotten an answer email me

No one else allowed to hear the answer?

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.       | Gates?
NSW, Australia                      | 


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

Date: Thu, 11 Dec 1997 16:55:26 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: just starting with perl
Message-Id: <34907D6E.899FD740@mystech.com>

jennifer wrote:

>      #!usr/bin/perl -w
>      print ("Hi Jen!\n");
> I saved this as jen.pl.
> Back at the dos prompt..
>     c:\perl5\perl jen.pl
> "can't open perl script jen.pl no such filde or directory exists."

Don't know what is going on here - works fine for me. Check that notepad
actually saved the file to the directory you think. Sometimes those Windows
apps launch from the windows directory.

> So I type...
>     c:\perl5\perl
> Now I'm on a blank line, no prompt of any kind so I type..
>      jen.pl
> Now I'm on another blank line no repsonse from perl
> I type..
>     c:jen.pl
> Another blank line, still no response.

When you simply run Perl it is expecting input from stdin. Try this to get a
feel for how this works:

echo print "Hi Mom"; | c:\perl5\perl

When you just type "c:\perl5\perl" nothing is coming across stdin so Perl just
sits there and waits! You can always Ctrl-C out of the interpreter.

Hope this helps!
Mark Reibert

-----------------------------
   Mark S. Reibert, Ph.D.

  Mystech Associates, Inc.
  3233 East Brookwood Court
   Phoenix, Arizona 85044

    Tel: (602) 732-3752
    Fax: (602) 706-5120
 E-mail: reibert@mystech.com
-----------------------------




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

Date: Fri, 12 Dec 1997 01:48:17 +0000 (GMT)
From: Rhodri James <rhodri@wildebst.demon.co.uk>
Subject: Re: just starting with perl
Message-Id: <47f714be0crhodri@wildebst.demon.co.uk>

In article <01bd0675$8b7e6a60$d6812299@xbwerrsn>,
 jennifer <tuia@msn.com> wrote:
> Everyone was so helpful on my last question, I'm going to ask another
> num-num question.

Flattery will get you... quite a lot of places, anyway :-)

> Now I've typed a program in notepad
>      #!usr/bin/perl -w
>      print ("Hi Jen!\n");
> I saved this as jen.pl.
> Back at the dos prompt..
>     c:\perl5\perl jen.pl
> "can't open perl script jen.pl no such filde or directory exists."

Which directory did you save jen.pl in?  Probably not the root (i.e. C:\).
What is your current directory in the DOS box?  C:\ unless you've moved.
All that Perl is complaining about is that it can't find jen.pl because it
isn't in the current directory.


> So I type...
>     c:\perl5\perl
> Now I'm on a blank line, no prompt of any kind so I type..
>      jen.pl
> Now I'm on another blank line no repsonse from perl I type..
>     c:jen.pl
> Another blank line, still no response.

It's just taunting you :-)
Actually, at this point, Perl is taking everything that you type as being
a program to compile and execute.  It will do so once you closed down the
input by typing Ctrl-Z (I think it's ^Z on Windows -- it's ^D on most
other systems).

Hope this helps -- learning to live with DOS is not for the nervous!

-- 
Rhodri James  *-*  Wildebeeste herder to the masses
If you don't know who I work for, you can't misattribute my words to them

 ... Scotty, now would be a really good time...


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

Date: Fri, 12 Dec 1997 02:57:40 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: just starting with perl
Message-Id: <genepoolEL22w5.4FG@netcom.com>

jennifer (tuia@msn.com) wrote:
: Back at the dos prompt..
:     c:\perl5\perl jen.pl
: "can't open perl script jen.pl no such filde or directory exists."

You are giving the path to the perl executable but not the script. If 
jen.pl is in c:\mydir\, you can run using:

c:\perl5\perl c:\mydir\jen.pl

You may as well modify the PATH environment variable to include 
c:\perl5, then if you are in the directory where your script is located, 
just enter:

perl jen.pl

Hope this helps.

Cheers,

Jim


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

Date: Thu, 11 Dec 1997 20:46:56 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Brian Atkins <brian@posthuman.com>
Subject: Re: Memory leak (perl 5.004_04)
Message-Id: <Pine.GSO.3.96.971211204510.10598A-100000@user2.teleport.com>

On Thu, 11 Dec 1997, Brian Atkins wrote:

>    open(FILE,"/data2/logs/temp_log");
>    open(FILE2,">/data2/logs/temp_log2");
>    open(LOG,">>/data2/logs/users-access_log");
>    open(LOG2,">>/data2/logs/userlogs/$user"); 

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

>       while ($line = <FILE>) { 

Modern perls will encourage you to use defined() here, if you use -w.

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 11 Dec 1997 18:45:57 -0500
From: ken@forum.swarthmore.edu (Ken)
Subject: Memory leak in perl 5.004_04
Message-Id: <ken-1112971845570001@news.swarthmore.edu>

Hi there-

I've got a program with a memory leak in it.  From my investigations, it
seems like the leak is in Perl itself.  I've pared the program down to
what follows - I can't pare it down any further, because this leak seems
to depend on several seemingly unrelated factors (see below).  Also, this
program is a pared down version of a pretty big program, so I know it
doesn't look like it does anything useful =).

 1  #!/usr/bin/perl -w
 2  use DB_File;
 3
 4  for ($i=0; $i<10000; $i++) {
 5
 6     $filehandle = &get_string;
 7
 8     open ($filehandle, "test.db") or die $!;
 9     tie (%hash, 'DB_File', "test.db", O_CREAT|O_RDWR, 0660) or die $!;
10
11     close $filehandle or die $!;
12     untie (%hash);
13
14     # Display memory usage:
15     print ("$i:\n", `ps ux`) if ($i % 1000 == 1);
16  }
17
18  sub get_string {
19     my ($string_chars, $string) = ("QWERTYUIOPASDFGHJKLZXCVBNM", '');
20     my ($int, $i);
21
22     for($i=0; $i<9; $i++) {
23        $int = rand(26);
24        $int = int($int);
25        $string .= substr($string_chars, $int, 1);
26     }
27     return $string;
28  }

Now, here's the interesting stuff.  If I replace line 23 with $int = 7.5;
, then the leak goes away.  So I figured it was a bug in rand() (which was
hard to believe).  But the leak also goes away when I comment out lines 8
and 11 (and leave line 23 as written), or when I make the for() loop at
line 22 go from 0 to 1 instead of from 0 to 9.  

So this seems to depend on some interrelationship of rand(), open(), and
close(), in some way I don't understand.  My gut says "garbage
collection," but my brain says I'd better not say that because I have no
idea.  Seems like a job for the people who know about perl's guts.

In case you're curious, the reason I call open() and then tie() is that in
the original version of the program, I call flock() on $filehandle.

Here's info about my Perl & platform:

Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
  Platform:
    osname=dec_osf, osvers=4.0, archname=alpha-dec_osf
    uname='osf1 forum.swarthmore.edu v4.0 564 alpha '
    hint=previous, useposix=true, d_sigaction=define
    bincompat3=y useperlio=define d_sfio=undef
  Compiler:
    cc='cc', optimize='-O4', gccversion=
    cppflags='-DSTANDARD_C -I/usr/local/include/db'
    ccflags ='-DSTANDARD_C -I/usr/local/include/db'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='ld', ldflags ='-L/usr/local/lib'
    libpth=/usr/local/lib /usr/shlib /shlib /lib /usr/lib /usr/ccs/lib
/usr/local/src/sfio97/lib
    libs=-ldb -lm -lc -lbsd -lPW
    libc=/usr/shlib/libc.so, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-shared -expect_unresolved "*" -O4 -msym -s
-L/usr/local/lib -L/usr/local/src/sfio97/lib
'


Characteristics of this binary (from libperl):
  Built under dec_osf
  Compiled at Nov 13 1997 23:12:32
  @INC:
    /usr/local/lib/perl5/alpha-dec_osf/5.00403
    /usr/local/lib/perl5
    /usr/local/lib/perl5/site_perl/alpha-dec_osf
    /usr/local/lib/perl5/site_perl
    /usr/local/lib/perl5/alpha-dec_osf
    .


Can anybody tell me what's causing it?  How about a patch/workaround? 
Thanks for your attention.

-Ken Williams
 The Math Forum
 ken@forum.swarthmore.edu


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

Date: 12 Dec 1997 00:51:25 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Memory leak in perl 5.004_04
Message-Id: <66q1qd$b0v$1@agate.berkeley.edu>

In article <ken-1112971845570001@news.swarthmore.edu>,
Ken <ken@forum.swarthmore.edu> wrote:
> I've got a program with a memory leak in it.  From my investigations, it
>  4  for ($i=0; $i<10000; $i++) {
>  5
>  6     $filehandle = &get_string;
>  7
>  8     open ($filehandle, "test.db") or die $!;

Here you create a glob named $filehandle, and never free it.  This is
why Perl has IO::Handle's, which are anonymous, thus do not create
this problem.

Hope it helps,
Ilya


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

Date: Thu, 11 Dec 1997 13:43:24 -1000
From: Ritchard Shadian <rshadian@hawaii.edu>
Subject: mkdir not recoginizing mode
Message-Id: <Pine.GSO.3.95q.971211133342.24758B-100000@uhunix3>

When you have a 

mkdir $dir, $mode;

command, isn't it supposed to create $dir with the permission specified by
$mode?  For instance, 

mkdir "dir", 0777;

is meant to create the directory "dir" with a permission mode of 0777,
right?  But for some reason that isn't working on my system.  It creates
"dir" but doesn't give it 0777 permissions.  To get that, I need to use
a special

chmod 0777, "dir";

command right after.  Does the umask have something to do with it, and if
so, can I temporarily change the umask during the execution of my program?

Thank you for any help.

Ritchard



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

Date: 11 Dec 1997 19:55:06 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: mkdir not recoginizing mode
Message-Id: <66q21a$2c3$1@stok.co.uk>

In article <Pine.GSO.3.95q.971211133342.24758B-100000@uhunix3>,
Ritchard Shadian  <rshadian@hawaii.edu> wrote:
>When you have a 
>
>mkdir $dir, $mode;
>
>command, isn't it supposed to create $dir with the permission specified by
>$mode?  For instance, 
>
>mkdir "dir", 0777;
>
>is meant to create the directory "dir" with a permission mode of 0777,
>right?  But for some reason that isn't working on my system.  It creates
>"dir" but doesn't give it 0777 permissions.  To get that, I need to use
>a special
>
>chmod 0777, "dir";
>
>command right after.  Does the umask have something to do with it, and if
>so, can I temporarily change the umask during the execution of my program?

You can user perl's umask function, which is documented in the perlfunc
man page:

[mike@stok tmp]$ cat try.pl
#!/usr/local/bin/perl -w

printf "umask is %03o\n", umask;
mkdir 'dir1', 0777              or die "$0 dir1 ($!)\n";
umask 0;
printf "umask is %03o\n", umask;
mkdir 'dir2', 0777              or die "$0 dir2 ($!)\n";
[mike@stok tmp]$ ./try.pl
umask is 002
umask is 000
[mike@stok tmp]$ ls -ld dir*
drwxrwxr-x   2 mike     mike         1024 Dec 11 19:51 dir1
drwxrwxrwx   2 mike     mike         1024 Dec 11 19:51 dir2

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 12 Dec 1997 01:00:47 GMT
From: ian@sonic.net (Ian Baker)
Subject: Re: Mysql -> DBI
Message-Id: <66q2bv$lrb$1@ultra.sonic.net>

Ian Baker (ian@sonic.net) wrote:
[snip]
: that API from the beginning) but I have a problem.  I'm making use of the
: insert_id method in Mysql.pm, and can't find a DBI counterpart.  Am I
: overlooking someting, or is nothing like that implemented?

This morning, I received a response from Matthew Reimer.  Apparently, it's
availavle via:

$id = $dbh->func("_InsertID");

thanks!
:)

-- 
Ian Baker                               Sonic
(707)522-1001 (33.6kbps)                (707)522-1000 (Voice)
mailto:support@sonic.net                http://www.sonic.net


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

Date: 12 Dec 1997 02:13:59 GMT
From: salvation@triple.homicide.org (Nobody, Really)
Subject: Older versions of swatch
Message-Id: <66q6l7$j5o@eve.enteract.com>

I'm not sure if this is the right place to post this, but I have spent all
night looking for an older version of swatch that is not dependant on perl5.
anything.  I've only got an older version of perl and I cannot find anything.
anywhere you could point me would be most helpful.  Thanks.


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

Date: Thu, 11 Dec 1997 22:40:10 -0600
From: Tim Dudek <tdudek@ncsa.uiuc.edu>
Subject: Re: Older versions of swatch
Message-Id: <3490C029.DEA4CF7@ncsa.uiuc.edu>

Nobody, Really wrote:

> I'm not sure if this is the right place to post this, but I have spent all
> night looking for an older version of swatch that is not dependant on perl5.
> anything.  I've only got an older version of perl and I cannot find anything.
> anywhere you could point me would be most helpful.  Thanks.

  I believe we are running a version of swatch on an older version of perl
here.  I will look into this further if I get the time.

Timothy Dudek  (tdudek@ncsa.uiuc.edu)
Technology Management Group
National Center for Supercomputer Applications
http://gto.ncsa.uiuc.edu/tdudek

"In a world so hard and dirty
        so fouled and confused
 searching for a little bit of God's mercy
        I found living proof"
                        'Living Proof'
                        Bruce Springsteen




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

Date: Thu, 11 Dec 1997 21:56:46 -0700
From: "Nic" <nic@cyber-west.com>
Subject: Perl Modules Info
Message-Id: <3490dc62.0@news5.kcdata.com>

I am somewhat familiar with perl programming and have been tinkering with it
for a while.  I was just wondering if there is a book out there that covers
many of the commonly used and/or advanced perl modules.  I have all of the
man pages and documentation, but I find it easier to have a book in front of
me so I don't have to toggle and fumble around as much.

Thanks

Nic




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

Date: Thu, 11 Dec 1997 20:43:51 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Vincent Joseph <vincent.joseph@usa.net>
Subject: Re: Perl support for the long long type
Message-Id: <Pine.GSO.3.96.971211185441.22475F-100000@user2.teleport.com>

On Thu, 11 Dec 1997, Vincent Joseph wrote:

> The 5 byte integer that I wish to convert is actually Unix time in 100th
> of a seconds.  (By Unix time I mean the value returned by the time
> function.)=20

By that statement, I believe that you mean that your number will normally
be around 100 times the current Unix time number.=20

> The value is being read from a file.  I need to convert this value to
> Unix time in seconds (which will fit in 4 bytes)  The "conversion" is
> really just a division by 100.  However, there does not seem to be a way
> to read in a 5 byte field into any of the numeric types using unpack (eg
> N n)=20

No, and if you could, you wouldn't be able to work with it very easily.

> sub toSeconds
> {
> =A0=A0=A0=A0=A0=A0=A0 my $rawepoch=3D();=A0 #Raw time (epoch) passed in f=
rom outside, 5 byte
> (100th second)

I don't know what those extra symbols are, or even whether you can see
them on your screen. To me, they're distracting. :-)

That's an unusual way to set a scalar to undef. I'd either leave off the
'=3D()' part, or I'd explicitly say "=3Dundef'. Of course, the value you wa=
nt
will be shifted off of @_ later, so you could simply assign it here.
Otherwise, it's a waste of processor power.

[ remainder of algorithm snipped ]

> Is there a more efficient (time wise, algorithmic)=A0 way of doing
> this in Perl?

Well, your algorithm could certainly be tweaked some. But I'd try this.

    sub toSeconds {
=09# Given a five-byte bitstring with an unsigned integer
=09# value less than or equal to 429,496,729,599, returns that
=09# value divided by 100, as a long unsigned integer
=09my($first2, @rest) =3D unpack("SCCC", shift);
=09# $first2 must be in range 0..25599
=09die "Value of \$first2 ($first2) too large"
=09    if $first2 > 25599;
=09my $value =3D int($first2/100);=09# in range 0..255
=09my $carry =3D $first2 - 100*$value;=09# 0..99
=09while (@rest) {=09=09=09# Obey Newton's 1st? :-)
=09    $carry =3D $carry * 256 + shift @rest;
=09    my $quot =3D int($carry/100);
=09    my $rem  =3D $carry - 100 * $quot;
=09    $value =3D $value * 256 + $quot;
=09    $carry =3D $rem;
=09}
=09# Could return $carry to give remainder
        return $value;
    }

Hope this helps!

--=20
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!




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

Date: 12 Dec 1997 01:05:50 GMT
From: kevin@kestrel.edu (Kevin Ow-Wing)
Subject: Reading serial ports using perl 5 under Win95...
Message-Id: <66q2le$39f$1@tern.kestrel.edu>

OK, so I can open and send data out a com port under windows 95
using perl 5.00402 binary distribution.  But I can't seem to
read any responses.  I have tried read, sysread, and the readline
function (i.e., $response = <COMPORT>;) without success.  The script just 
hangs there, waiting.  Which brings me to another question - how can I
make the I/O non-blocking?

Thanks,
Kevin
email responses to kevin@kestrel.edu are preferred...


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

Date: Thu, 11 Dec 1997 18:02:25 -0600
From: ozie@ganet.org
Subject: Running NT "Net User ..." from Perl
Message-Id: <881884623.450101258@dejanews.com>

Does anyone know how to call the "Net user" system
command from a perl script from a web browser?

The script I've written works fine from the command line
but it does not execute when launched from a browser.

Any clues.

Thanks
 -Ozie

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Thu, 11 Dec 1997 22:21:40 -0600
From: schwern@rt1.net
Subject: Shoving an array into a glob? or fixing IO::ScalarArray
Message-Id: <881900139.1297874953@dejanews.com>

I recently found it necessary to use the data on an array as a filehandle
(a module routine only accepted IO::Handle type filehandles and I had
data which I had piped and processed into an array that I wanted to pass
into it.)  I grabbed the IO::ScalarArray module and tried the
following...

	use IO::ScalarArray;
	...
	$ah = IO::ScalarArray->new(\@array);
	LibFunction($ah);

Unfortunately, LibFunction tries to do "binmode $ah" which fails because
unlike most other IO objects an IO::ScalarArray object isn't a glob.  The
IO::ScalarArray docs suggested trying this...

	tie *GLOB, IO::ScalarArray, \@array;
        LibFunction(\*GLOB);

That fails because LibFunction expects an IO::Handle object and tries to
do "$ah->print" and such.

So I need the best of both worlds.  I need a IO::ScalarArray module which
inherits from IO::Handle.  Unfortunately, I can't for the life of me
figure out how to shove array data onto a filehandle/glob.  IO::File uses
open() to do make its filehandle and IO::Socket uses socket() to make its
filehandle.

Again, I need something where you can do, more or less, this:

	$ah = IO::Array->new(\@array);
	$ah->print;   # Prints the first element of @array.
	$foo = <$ah>; # Places the second element of @array onto $foo.
	binmode $ah;  # Effectively does nothing, but produces no error.

An object which inherits from IO::Handle, is a glob and accepts an array
of scalars as its input data.

Thanks.


"If you could imagine anyone obtaining this power of becoming invisible,
and never doing any wrong or touching what was another's he would be
thought by the lookers-on to be a most wretched idiot..."  Glaucon,
Plato's _Republic_ Book II  schwern@envirolink.org  schwern@rt1.net 
Floggo the Stupid aka Milko aka Schwern aka Auveyron aka Dupre 
http://www.envirolink.org/home/schwern/

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 12 Dec 1997 04:31:36 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: There's More Than One Way?
Message-Id: <66qen8$23p$4@comdyn.comdyn.com.au>

In article <348EDA60.7850@min.net>,
	John Porter <jdporter@min.net> writes:
> Quoth Larry, "There's more than one way to do it", as we are all aware.

This statement actually only applies to "it". The definition of what
"it" includes is not given here..

Maybe "it" isn't everything...?

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd.       | things get worse.
NSW, Australia                      | 


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

Date: Thu, 11 Dec 1997 23:04:17 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: trapping errors from IPC::Open2
Message-Id: <EL1s36.LH3@bcstec.ca.boeing.com>

In article <66mgvv$dc$1@rtnews.rto.dec.com>,
Robert L. Urban <urban@rto.dec.com> wrote:
 > Hello all,
 > 
 > If the following script is run without arguments, it spits out
 > 
 > 	"open3: exec of some cmd and args failed at /tmp/otest line 5"
 > 
 > However, if run with the argument "catch", it simply prints the pid
 > of the spawned process.  I presume this is because IPC::Open3 is doing
 > the 'croak' in question in the child process.
 > 
 > Has anyone come up with a decent way of trapping the error?
 > 
 > The script:
 > ------------------ snip snip -----------------
 > #!/usr/local/bin/perl
 > 
 > use IPC::Open2;
 > 
 > if ($ARGV[0] eq 'catch') {
 > 	eval {
 > 		$pid = open2(\*RDR, \*WTR, 'some cmd and args');
 > 	};
 > 	if ($@) {
 > 		print "open2 failed\n";
 > 		exit;
 > 	} else {
 > 		print "pid=$pid\n";
 > 	}
 > } else {
 > 	$pid = open2(\*RDR, \*WTR, 'some cmd and args');
 > 	print "pid=$pid\n";
 > }

open2 now does an open3 which re-directs STDERR so a block eval 
won't work. However, you could just call open3 directly, e.g.,

use IPC::Open3;
use Carp;

$pid = open3(\*RDR, \*WTR, \*ERR, 'some cmd and args');
croak @err if @err=<ERR>;


HTH,
--
Charles DeRykus


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

Date: Thu, 11 Dec 1997 16:36:43 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: untainting data
Message-Id: <3490790B.E4750275@mystech.com>

Mark Worsdall wrote:

> Hi, I am trying to untaint an IP variable passed to me. Now in all
> SINGLE IP numbers the untainting works fine, however on occasion I am
> passed data such as this:-
> 194.154.10.177, 194.238.50.8
>
> 2 IP numbers with a space, so I drop the space and then try to untaint
> the data (DOH!) no good, cos yes I should really untaint the data before
> doing anything with it to avoid the following error:-

How about splitting on ', ' then dealing with each IP individually? Something like:

@IP = split /, /, $surfer;

Then process the IP array.

Mark Reibert

-----------------------------
   Mark S. Reibert, Ph.D.

  Mystech Associates, Inc.
  3233 East Brookwood Court
   Phoenix, Arizona 85044

    Tel: (602) 732-3752
    Fax: (602) 706-5120
 E-mail: reibert@mystech.com
-----------------------------




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

Date: Thu, 11 Dec 1997 17:40:08 -0800
From: dwaring@nwsr.com (David Waring)
Subject: Using a fork (help needed)
Message-Id: <dwaring-1112971740080001@blv-pm107-ip6.halcyon.com>

I have script that sends mail to people on a mailing list as shown below

open(MAIL,"|$mailprog -t");
            print MAIL "To: $address\n";
            print MAIL "From: NW Ski Report\n";
            print MAIL "Subject: Powder Alert\n\n";
            print MAIL "Dear $name,\n\n";
            print MAIL "$FORM{'headline'}\n\n";
 .......
      close (MAIL);

It works but there is a problem  the mailing list is now over 500
addresses and when I call this script from a web page using a form the
process takes several minutes and eventually I get an internal server
error instead of the proper responce that things worked.  All the mail is
actually sent.

I would like to fix this so that I don't hang my browser for 5 minutes and
get a proper return.  I assume that I need to call a child process but I
really don't know how to do it or if that is what I really need to do.  I
am a self taught Perl programmer (thanks to Randal, Larry, and Matt's
Scripts).  Could someone point me in the right direction?

David Waring


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1459
**************************************

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