[6825] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 450 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 8 08:17:41 1997

Date: Thu, 8 May 97 05:00:40 -0700
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, 8 May 1997     Volume: 8 Number: 450

Today's topics:
     Re: > 2GB "file too large", AIX 4.2, perl 5.001, not "u (Bob Shair)
     Re: > 2GB "file too large", AIX 4.2, perl 5.001, not "u (peter hakanson)
     Re: a question on striping characters (Parillo)
     Re: a question on striping characters (Mike Stok)
     Re: absolute novice - help me start <zonycat@flash.net>
     Re: bad name for good idea: comp.lang.perl.moderated (w (Andy Wardley)
     Re: Finding a pattern in a file <a.aitken@unl.ac.uk>
     Half of GD.pm working with Perl 5.003_07 (Steven Galfano)
     Re: Help a Newbie (please) <a.aitken@unl.ac.uk>
     Help with opening socket to port 25 <darren.bentham@cmc.co.uk>
     Re: Help with opening socket to port 25 (Mike Stok)
     Re: How to add line of text to Random Image Displayer? (Kyzer)
     HP-UX 9.05 binaries <phil_lee@dial.pipex.com>
     Re: Loosing clpm regulars (was Re: Perl auto-replier) (Parillo)
     Re: Moving a file <tom@eiscat.uit.no>
     Re: need help w/forms and Perl <flavell@mail.cern.ch>
     Re: Need help with PERL script! <a.aitken@unl.ac.uk>
     Re: New Perl programmer in need of tutorials <zonycat@flash.net>
     Re: Newbie question alert! Strip characters during spli (Mike Stok)
     Re: Newbie question alert! Strip characters during spli <sibsib@hotmail.com>
     Re: ODBC driver for Informix and Perl <rheisner@worldnet.att.net>
     Re: Ousterhout and Tcl lost the plot with latest paper (Harvey J. Stein)
     Require assistance with function stat ( Thomas Lachlan XMS x1893 )
     Re: standards (brian d foy)
     Re: system () won't execute the called program. <otisg@panther.middlebury.edu>
     Re: system () won't execute the called program. (brian d foy)
     Re: system () won't execute the called program. (Tad McClellan)
     Re: Where do I get PERL? <santiago@gambito.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 8 May 1997 06:50:06 GMT
From: rmshair@uiuc.edu (Bob Shair)
Subject: Re: > 2GB "file too large", AIX 4.2, perl 5.001, not "ulimit"
Message-Id: <5krt2u$maf@vixen.cso.uiuc.edu>

rmshair@uiuc.edu (Bob Shair) writes:

>I'm running a perl (5.001) script on AIX 4.2 which receives files from 
>a mainframe (over a TCP socket) and writes them to disk.  When writing
>to a large_file_enabled filesystem, the program died at 2GB with:
>Sustem write error: File too large
 ...
>Can this be a limit in the perl interface to the C library?
it was
>How can I circumvent it?

Recompile perl at the 5.003 level with the following three changes to
the default config.sh produced by Configure -der:

fpostype='fpos64_t'
lseektype='off64_t'
ccflags='-qmaxmem=8192 -D_LARGE_FILES -qarch=com -qtune=604 -qflag=I:E -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -I/usr/local/include -D_NO_PROTO'

where the key flag is -D_LARGE_FILES
(-qarch=com -qtune=604 -qflag=I:E are just my personal preferences,
 and the rest are produced by the default Configure).


On "make test" I get one error, in a package we don't use here.
I should run "make test" against the default configuration, without
64-bit file support, and see if it's there, too.  It's almost 2AM, though
and I'm tired.
 ...
lib/safe.......ok
lib/sdbm.......sdbm store returned -1, errno 22, key "101" at ./lib/sdbm.t line 
104.
FAILED on test 8
lib/socket.....ok
lib/soundex....ok
Failed 1 test, 98.94% okay.
u=1.81  s=1.13  cu=24.72  cs=15.64  files=94  tests=1968

It does allow me to create files greater than 2GB in size.

I'll post the complete config.sh to comp.lang.perl.misc (only) 
as a separate posting.

Thanks to all who sent help, especially Dave and Phil, whose help was helpful!

-- 
Bob Shair                          Open Systems Consultant
1018 W. Springfield Avenue         rmshair@uiuc.edu
Champaign, IL 61821		   217/356-2684
< Not employed by or representing the University of Illinois >


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

Date: 8 May 1997 08:29:56 GMT
From: peter@cyklop.volvo.se (peter hakanson)
Subject: Re: > 2GB "file too large", AIX 4.2, perl 5.001, not "ulimit"
Message-Id: <5ks2u4$ort@nike.volvo.se>

Kent, 
if You have read the original post then you understand
WHY aix4.2 (or any 32 bit machine has this limitation)

Even if one could (like in BSD) use a struckt for this, then
any application compiles has to use this correct.

In contrast, using normal (64bits) int and manipulationg
this int is trivial. 

My guess is that perl dont do this correct. Same 
perl code compiled in an dec-alpha works! The reason
is that an int is an int is an int....

peter h
Kent Perrier (kperrier@Starbase.NeoSoft.COM) wrote:
: In article <5kq7u4$h4e@nike.volvo.se> 
: peter@cyklop.volvo.se (peter hakanson) writes:

: >
: >Looks like a clear case for migrating to DEC-unix or anything
: >else that runs on 64 bits machines. (aka "full grown box")
: >

: AIX 4.2 doesn't have the 2 gig filesize limit.  I suspect that the problem
: is in the version of perl that he is using.  As a possibile solution, try
: compiling perl on the AIX box in question and see if the problem persists.

: Kent
: -- 
: Kent Perrier           If Bill Clinton is the answer, then it must
: kperrier@neosoft.com    have been a really stupid question.
: Corporations don't have opinions, people do.  These are mine.
: PGP 2.6 Public Key available by request and on key servers
: PGP encrypted mail preferred!


--
--
<peter.devnull@cyklop.volvo.se> (remove ".devnull" before use!)
Peter Hakanson  VolvoData Dep 2580 phone +46 31 66 74 27


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

Date: 7 May 1997 21:16:42 GMT
From: lparillo@newshost.li.net (Parillo)
Subject: Re: a question on striping characters
Message-Id: <5kqrfq$kq4@linet06.li.net>

I prefer the second because it is more clear.
Is there a reason why the first is better?

my ($foo, $bar);

$bar = "79I_LIKE_TH79E_NUMBER_9";
$bar =~ s/[^\d]+//g;
print $bar, "\n";

$foo = "79I_LIKE_TH79E_NUMBER_9";
$foo =~ s/\D//g;
print $foo, "\n";

Abigail (abigail@fnx.com) wrote:

: $foo = "I_LIKE_THE_NUMBER_9";
: $bar =~ s/[^\d]+//g;

: strips out all non numbers.


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

Date: 8 May 1997 09:57:47 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: a question on striping characters
Message-Id: <5ks82r$kvk@news-central.tiac.net>

In article <5kqrfq$kq4@linet06.li.net>,
Parillo <lparillo@newshost.li.net> wrote:
>I prefer the second because it is more clear.
>Is there a reason why the first is better?
>
>my ($foo, $bar);
>
>$bar = "79I_LIKE_TH79E_NUMBER_9";
>$bar =~ s/[^\d]+//g;
>print $bar, "\n";
>
>$foo = "79I_LIKE_TH79E_NUMBER_9";
>$foo =~ s/\D//g;
>print $foo, "\n";

Well, the first has a + so it will replace sequences of 1 or more
non-digits at a time, the second deals with them one at a time which
involves more shuffling of string data, but \D and [^\d] both match
against a character which isn't a digit:

#!/usr/local/bin/perl -w

use Benchmark;
use vars qw/$init/;

$init = "79I_LIKE_TH79E_NUMBER_9" x 1000;

timethese (100, {
             'without +' => '($bar = $init) =~ s/[^\d]//g;',
             'with +   ' => '($bar = $init) =~ s/[^\d]+//g;',
             'D with + ' => '($bar = $init) =~ s/\D+//g;'
           });
__END__

says:

Benchmark: timing 100 iterations of D with + , with +   , without +...
 D with + :  2 secs ( 1.26 usr  0.00 sys =  1.26 cpu)
 with +   :  2 secs ( 2.53 usr  0.00 sys =  2.53 cpu)
 without +:  9 secs ( 8.77 usr  0.00 sys =  8.77 cpu)

on my system...

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@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Wed, 07 May 1997 22:50:45 -0700
From: Dennis <zonycat@flash.net>
Subject: Re: absolute novice - help me start
Message-Id: <337169B5.5CEE@flash.net>

Chris,

See notes below....
(BTW, did you read my earlier posts on this subject thread?)

chris wrote:
> 
> here's what i did (do).
> 
> 1) installed perl into per5\perl5 directory.
> 2) type my program in the dos editor (i read that win95 users need to add
> something other that #!/usr..... do you know what?)

Hmm, not sure where you read that.  I am using perl under Win95.

> 3) saved it in my per5\perl5 dir
> 4) open up my perl.exe and nothing happened.

If you do not have a file association set for perl, you will need to
call perl from the command line.  I recommend a file association.  Also
as stated before, make sure that perl is in your dos path
(autoexec.bat).

When you want to runa program via the command line such as hello.pl;
type:  perl hello.pl.  This will execute your perl program of hello.pl. 
If that program contained the line, printf "HELLO Chris!\n";

Then HELLO Chris will be printed upon execution of the 'perl hello.pl'

Please see my other responses for inportant information.


> 
> i need to save all programs as *.pl?  also in my bin folder there is a
> perl95.exe, should i be using this instead?

If you do not have the association and/or path set, then you need to
specify full pathing for perl.exe and your file names.  NO FUN!

ZONY
> 
> too many question, if you can answer these, i'm pretty confident i can
> finally get cracking.  thanks alot.
> 
> chris.
> 
> etta  <etta@fyi.com> wrote in article
> <336e84d1.10142617@netnews.worldnet.att.net>...
> >
> >
> > Did you assocate the .pl ext to perl.exe in windows?
> >
> > Then you just go to the dir where the file you want to excuate
> > and type:  perl filename.pl
> >
> >
> > Hope this helps,
> >
> > etta
> >
> >


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

Date: 8 May 1997 08:47:34 +0100
From: abw@peritas.com (Andy Wardley)
Subject: Re: bad name for good idea: comp.lang.perl.moderated (was Re: Loosing clpm regulars (was Re: Perl auto-replier))
Message-Id: <5ks0em$78f@aoxomoxoa.peritas.com>

Randal Schwartz  <merlyn@stonehenge.com> wrote:
>
>I like comp.lang.perl.questions (moderated) myself.
>

I agree with what Randal says about the "moderated" element, but I 
would much prefer comp.lang.perl.answers over clp.questions.

To me "questions" implies the place for hundreds of newbies to ask
the same old questions which, by the fact that they haven't read the 
FAQ and answered the questions themselves, should be rejected by the
moderator.

On the other hand, "answers" is a place for all the FAQs and other 
doucumentation and the name *should* jump out as the first place for 
Joe Hapless Newbie to look.


A

-- 
Andy Wardley <abw@peritas.com>  **NEW** http://www.peritas.com/~abw 
A responsible and professional individual who has no need for silly 
comments, inane banter or bizarre "in-jokes" in his signature file.  


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

Date: Thu, 08 May 1997 11:34:56 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: Finding a pattern in a file
Message-Id: <3371AC50.3DF0@unl.ac.uk>

Query??? wrote:
> 
> Hi,
> 
>        Would appreciate any pointers to the following problem:-
> 
>        I would like to find if a pattern exist in a certain file.
>        If it does output the finding into another file.
>        Both input and output file name is in a variable.
> 
>         e.ga:-
>         $infile="/tmp/abc";
>         $outfile="/tmp/out";
> 
>         grep $pat $infile > $outfile;

One way to do it:

open (IN, "/path/to/infile") || die "Can't open infile: $!";
@hits = grep {/$pattern/} <IN>;
close (IN) || die "Can't close infile: $!";
open (OUT, "> /path/to/outfile") || die "Can't open outfile: $!";
print OUT @hits;
close (OUT) || die "Can't close outfile: $!";

That will output every line with the pattern in it to the new file.

You can also filter the contents of infile with:

@hits = grep {/pattern/} `cat infile`;	# this does the same job as the
first three lines of code above.

Alastair.


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

Date: Wed, 07 May 1997 19:29:56 -0700
From: galfano@ucla.edu (Steven Galfano)
Subject: Half of GD.pm working with Perl 5.003_07
Message-Id: <galfano-0705971929560001@164.67.58.21>

I am using:
----------
PERL 5.003_07 (Build 306) on an NT 4.0 Server.
Got the latest GD.pm and GD.pll (from ftp.roth.net)

What works
----------
When I am working directly from the server, the test perl scripts spit out
the nice GIF binary code just perfectly (and saves GIFs to files).  This
indeed makes me happy.

What annoys me
--------------
However, when I use the same script as a CGI on the WWW, I get "Document
contains no data" and a broken image.  It almost seems like GD.pm is
trying to create a temp file somewhere that the INET_** user does not have
permission to write.

Any insight?

Thanks!!

-Steve


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

Date: Thu, 08 May 1997 12:29:12 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: Help a Newbie (please)
Message-Id: <3371B908.6BFD@unl.ac.uk>

Eric A. Backlund wrote:
> 
> I am looking for script that will allow users to download a file to
> their disk, through a web page. The file has an .exe extentension, and
> when I create a link to the file, it load the text into the browser
> intstead of bringing up a Save As dialog box. Any help will be greatly
> appreciated.

1) Not a perl question.

2) This is a security issue - if you can do it, I could too and send you
a very nasty cyberflu bug.

3) Plugins are runnable modules that can be run inside a browser to
display non-html files, shockwave and vrml are two examples.  These are
more or less secure methods of running externally loadable files.

4) Java or Javascript it.  This is what those languages are for.

Alastair.


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

Date: Thu, 08 May 1997 05:12:38 -0400
From: "Darren Bentham" <darren.bentham@cmc.co.uk>
Subject: Help with opening socket to port 25
Message-Id: <01bc5b8f$6f9332e0$0980e0c3@darren.bentham.cmc.co.uk>

Can Some-one please please please tell me how I connect to the mail daemon
at port 25 and communicate with it.  The book example I've been playing
with goes as follows:

Answers via e-mail would be greatly appreciated.

#!/usr/local/bin/perl
$port = 25;
getservbyport($port, "tcp");
($d1, $d2, $prototype) = getprotobyname("tcp");
($d1, $d2, $d3, $d4, $rawclient) = gethostbyname("aztec");
($d1, $d2, $d3, $d4, $rawserver) = gethostbyname("aztec");
$clientaddr = pack ("Sna4x8", 2, 0, $rawclient);
$serveraddr = pack ("Sna4x8", 2, $port, $rawserver);
#socket(SOCKET, 2, 1, $prototype) || die ("No Socket");
#bind(SOCKET, $clientaddr) || die ("can't bind");
connect(SOCKET, "127.0.0.1 25");

$LINE = <SOCKET>;
print("$LINE\n");
close (SOCKET);     




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

Date: 8 May 1997 11:26:05 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Help with opening socket to port 25
Message-Id: <5ksd8d$pk6@news-central.tiac.net>

In article <01bc5b8f$6f9332e0$0980e0c3@darren.bentham.cmc.co.uk>,
Darren Bentham <darren.bentham@cmc.co.uk> wrote:
>Can Some-one please please please tell me how I connect to the mail daemon
>at port 25 and communicate with it.  The book example I've been playing
>with goes as follows:

Which book?

>Answers via e-mail would be greatly appreciated.

Mailed too...

The perlipc man page with perl 5.00x contains an example:

#!/usr/local/bin/perl -w

require 5.002;
use strict;
use Socket;
my ($remote,$port, $iaddr, $paddr, $proto, $line);

$remote  = shift || 'localhost';
$port    = shift || 2345;  # random port
if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
die "No port" unless $port;
$iaddr   = inet_aton($remote)               || die "no host: $remote";
$paddr   = sockaddr_in($port, $iaddr);

$proto   = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto)  || die "socket: $!";
connect(SOCK, $paddr)    || die "connect: $!";
while (defined($line = <SOCK>)) {
  print $line;
}

close (SOCK)            || die "close: $!";
exit;

__END__

which will get the sendmail greeting if you specify your hostname and port
on the command line.  Note that the Socket module gets you things like
PF_INET, SOCK_STREAM as routines which return the correct value for your
system - watch out for hard coded "constants" which vary between operating
systems (e.g. SunOS 4.x vs SunOS 5.x values.)

A first edition of the camel book (Programming Perl) has a simple sample
client program in the Real Perl Programs section which you can use as a
template if you're stuck with perl 4, but check that the hard coded
constants are correct.

If you want to "do" mail and have perl 5 it may be worth picking up the
libnet module from CPAN (http://www.perl.com/CPAN/ is one way of getting
there) which contains the Net::SMTP module, lifting bitd from the man
page:

  This example sends a small message to the postmaster at the SMTP server
  known as mailhost:
                     

      #!/usr/local/bin/perl -w

      use Net::SMTP;

      $smtp = Net::SMTP->new('mailhost');

      $smtp->mail($ENV{USER});
      $smtp->to('postmaster');

      $smtp->data();
      $smtp->datasend("To: postmaster\n");
      $smtp->datasend("\n");
      $smtp->datasend("A simple test message\n");
      $smtp->dataend();

      $smtp->quit;

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@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 8 May 1997 07:53:28 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: How to add line of text to Random Image Displayer?
Message-Id: <5ks0po$99l@info.abdn.ac.uk>

John M Cole of jcole@wavenet.com wrote in comp.lang.perl.misc:
: Hello,

: I'm working with one a Random Image Displayer script from Matt's Script
: Archive, and I'd like to add a different and specific line of text to each
: image being displayed.  

: Does anyone know of an easy way to do this?

Yes!

: Thanks!

--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac   |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com  |University or AUCC, thankfully.***** |always!

-- 
Random sig of the day:
Sir, a transmission from zone 669881a - a transmission of priviledged code!


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

Date: Thu, 08 May 1997 10:31:04 -0700
From: Philip Lee <phil_lee@dial.pipex.com>
Subject: HP-UX 9.05 binaries
Message-Id: <33720DD8.2A69@dial.pipex.com>

I'm trying to set up a small intranet here to show the benefits to senior 
managers.  I've designed the pages but they do not interact with the 
user.  I don't know C and hence Perl appears to be the best bet for 
creating CGI scripts.  I've got the source code but it won't compile 
without *loads* of errors.  I've tried to find Perl binaries on the net 
without success.  There are some available but for HP-UX 10.x from the 
HP-UX Porting Centres.

Does anybody know where I might obtain binaries for HP-UX 9.05 ?

Thanks

Philip Lee
Research Officer
British Steel Strip Products - Welsh Technology Centre
Port Talbot Works
Port Talbot
Wales, UK



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

Date: 7 May 1997 15:52:55 GMT
From: lparillo@newshost.li.net (Parillo)
Subject: Re: Loosing clpm regulars (was Re: Perl auto-replier)
Message-Id: <5kq8gn$e7r@linet06.li.net>

Can you whisper it in my ear to lparillo@suffolk.lib.ny.us?
I think the reply to in my tin is broken.
So I guess I am one of those who munge(?).

Eli the Bearded (usenet-tag@qz.little-neck.ny.us) wrote:

: The hierarchy which cannot be mentioned uses several other strong
: tools, including arbitrary killing of stuff from certain providers.


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

Date: 08 May 1997 08:24:04 +0000
From: Tom Grydeland <tom@eiscat.uit.no>
Subject: Re: Moving a file
Message-Id: <7xohamtlqz.fsf@eiscat.uit.no>


> Alastair Aitken wrote:
> > I think rename is just mv by any other name.

Douglas Seay <seay@absyss.fr> writes:
> I don't think so, although since I've never read the source, I'm stating
> opinion, not fact.  I think that rename calls rename(2), a Unix system
> call to rename a file on the same filesystem.  If perl's rename called
> /bin/mv (or whatever), then it would have been called "move" or "mv" or
> something of the sort.  And why isn't there a "copy" or "cp" function
> too?  The same logic holds for symlink calling symlink(2) but there
> being no equivalent for a hard (non-symbolic) link.

Re: mv.  On Solaris, the manpage for mv(1) says:

     If source and target_dir are on different file  systems,  mv
     copies the file and deletes the original; any links to other
     files are lost.

You could easily do the same.

Re: cp.  There's always File::Copy

Re: hard links.  What do you think the link function does?


> > > I'd really rather
> > > not write my own copy function although this seems like the best way
> > > off the top of my head followed by an unlink call.

Don't write it yourself.  Use File::Copy.

> - doug

--
//Tom dot Grydeland at phys dot uit dot no
- I don't write children's books or "Crotch Sniffing for Dummies" - E. Naggum
        The case of Randal Schwartz - http://www.lightlink.com/fors/


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

Date: Thu, 8 May 1997 09:40:46 GMT
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: need help w/forms and Perl
Message-Id: <Pine.A41.3.95a.970508113252.100960E-100000@sp058>

On Thu, 8 May 1997, Geoffrey Hebert wrote:

> Check out the Perl site!
            ^^^
I'd be happy to, if you'd give us its URL.

> http://www.microserve.net/~soccer/

_THAT's_ "the" Perl site???  

Who are you trying to fool??

> use password perlmisc

What on Earth is the point of having a password and then telling it
to everyone?

> Geat tool for Developers>
  ^^^^

Really?  It'll be interesting to hear what the Perl regulars have to
say about this.



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

Date: Thu, 08 May 1997 12:50:59 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: Need help with PERL script!
Message-Id: <3371BE23.6527@unl.ac.uk>

Brian Locascio wrote:
> 
> Hello!
> 
> I am looking for some ideas/help on how to take information from a
> space delimited text file that looks like this (see below) and imput
> each line to the BSDI "adduser" program.  This script will save me the
> trouble of entering account information manually for 1000+ users!
> 
> {username} {password} {First Name} {Last Name} {shell}
> 
> The script will need to read the information from this text file and
> imput it to the "adduser" program with a few switches.
> 
> Example of  BSDI "adduser" command line:
> 
> adduser -g {groupname} -h {user home directory} -P {password}
> 
> At this point I am not looking for anyone to write the script for me
> (of course I would pay).  However, if you could give me ideas or setup
> the framework for the small script, I would be in debt to you!

Some partially tested simple code fragments (the system call to adduser
was not tested because I don't actually want to do that to my system):

#! /usr/local/bin/perl -w

require 5.003;
use strict;

my ($userfile,@users,@fields,$home);

$userfile = `cat users.dat` || die "Can't open userfile: $!";
@users = split(/\n/,$userfile);
foreach (@users) {
    @fields = split(/\s+/,$_);
    $home = "/home_dir/" . $fields[0];		# home directory is made up from
a home root and username
    system ("adduser -g $fields[0] -h $home -P $fields[1]") || print
"Can't add user: $fields[0]";
}

exit 0;

That will add the users using the sample command you listed above.  It
doesn't specify the shell for the user nor specify any personal
information (fname, lname) but modding the adduser command to include
those fields should be relatively easy.

Alastair.


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

Date: Tue, 06 May 1997 13:32:02 -0700
From: zonycat <zonycat@flash.net>
Subject: Re: New Perl programmer in need of tutorials
Message-Id: <336F9542.3CE3@flash.net>

zonycat wrote:
> 
> Katharine Osborne wrote:
> >
> > If anybody knows of any online tutorials on getting started with Perl
> > please email me.  It would be especially helpful if they were slanted
> > from C\C++ or Java, I've only had the barest minimum exposure to shell
> > programming.  Also please don't ask me to read the FAQ's from this
> > newsgroup, I've been down that road already.
> >
> > Thanks in advance-
> > KaOs
> > kosborne@rocketmail.com
> 
> Katharine,
> 
> There are a lot of books on the market to help with the beginner.  I
> should know, as I am learning more every day.  Several of the books have
> CDs or tell you where to reference their examples for exercises they
> have in their books.  "60 Minute Guide to CGI Programming "  is a good
> book and has some examples on line with IDG BOOKS in their online
> bookstore.
> 
> So find a book with a CD and you got it made.


Another book that has exapmles on the WEB is found at:
http://www.ora.com/catalog/pperl2/noframes.html

(Programming Perl)

Don't forget the sites: http://www.activeware.com/ or
http://www.perl.com/perl/index.html as they has examples and references.


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

Date: 8 May 1997 10:46:15 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Newbie question alert! Strip characters during split.
Message-Id: <5ksatn$no3@news-central.tiac.net>

In article <5krbbd$1v@news.aus.world.net>,
Jerry Cashman <jcashman@eba.com.au> wrote:

>I am reading a bunch of records from a comma-seperated, quote delimited
>text file and want to assign them to a group of named var's for further
>processing.
>
>I am currently assigning the var's using SPLIT on the comma which seperates
>the fields, but would like an easy way to strip the quote delimiters from
>the resulting strings at the same time.

You might want to look at the Text::ParseWords module which comes with
perl 5.xxx or get hold of a copy of Jeffrey Friedl's O'Reilly book,
Mastering Regular Expressions.  The former can be used like this:

#!/usr/local/bin/perl -w

use Text::ParseWords;

while (<DATA>) {
  chomp;
  @words = &quotewords (',', 0, $_);
  print "got (", join (')(', @words), ")\n";
}

__END__
"foo","bar","baz"
"foo, bar",baz,0

(but old versions may drop the last 0 field, this is a recent one...) and
Jeffrey's book covers how to do it yourself.

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@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Thu, 08 May 1997 07:53:21 -0400
From: Scott Blanksteen <sibsib@hotmail.com>
Subject: Re: Newbie question alert! Strip characters during split.
Message-Id: <3371BEB1.7C67EBD3@hotmail.com>

Jerry Cashman wrote:
> I am reading a bunch of records from a comma-seperated, quote delimited
> text file and want to assign them to a group of named var's for further
> processing.
> 
> I am currently assigning the var's using SPLIT on the comma which seperates
> the fields, but would like an easy way to strip the quote delimiters from
> the resulting strings at the same time.

Note that, in general, you can't just split on ',', since there may
be commas embedded in your data fields.

You may want to look at Jeffrey Friedl's O'Reilly book, "Mastering
Regular Expression."  [ISBN 1-56592-257-3]  He has sample code for 
doing just what you want.

You could also try Text::ParseWords - however, Friedl mentions that
there are some problems with the module.

Scott

-- 
Scott I. Blanksteen
sib (at) worldnet (dot) att (dot) net


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

Date: Wed, 07 May 1997 22:44:41 -0400
From: "Robert H. Eisner" <rheisner@worldnet.att.net>
To: Eric Harley <erich@powerwareintl.com>
Subject: Re: ODBC driver for Informix and Perl
Message-Id: <33713E19.6EF4@worldnet.att.net>

Eric Harley wrote:
> 
> Does anybody know of an ODBC driver for Informix that is compatible with
> the Win32::ODBC module?
> 
> Thanks!
> Eric Harley
> erich@powerwareintl.com

Trifox has a product, VORTEXodbc.  It talks to multiple RDBMS,
and works with all version of Informix 5, 6 & 7.

Trifox also has VORTEXperl.  It talks to multiple RDBMS.
It uses Perl Sockets so there is no need to re-build the Perl
runtime.  It also works with all versions of Informix 5, 6 & 7.

Please see http://www.trifox.com for details.

Regards,

Bob Eisner
408.369.2392


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

Date: 08 May 1997 11:33:18 +0300
From: abel@netvision.net.il (Harvey J. Stein)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <m2u3keuzw1.fsf@blinky.bfr.co.il>

In article <5k4uqv$8a@m1.cs.man.ac.uk> fellowsd@cs.man.ac.uk (Donal K. Fellows) writes:
   In article <3364DD2D.86195F2@physik.tu-muenchen.de>,
   Christopher Eltschka  <celtschk@physik.tu-muenchen.de> wrote:
   [ ... ]
   > BTW, what would the following possible C++ interface for menus look
   > like in tcl/tk?
   > 
   > MenuBar MainMenu
   > (
   >   Menu("Main")
   >     .Item
   >       (
   >         Menu("~File")
   >           .Item(Command("~Open", cmOpenFile), helpOpen)
   >           .Item(Command("~Save", cmSaveFile), helpSave)
   >           .Item(Command("~Save ~As", cmSaveFileAs), helpSaveAs)
   >           .Separator()
   >           .Item(Switch("Make ~Backup", BackupFlag), helpBackup)
   >       )
   >     .Item
   >       (
   >         Menu("~Search")
   >           .Item(Command("~Find"), cmFind), helpFind)
   >           .Item(Command("~Replace"), cmReplace), helpReplace)
   >           .Separator()
   >           .Item(Command("Find ~Again"), cmFindAgain), helpFindAgain)
   >       )
   > )
   > 
   > Here cmXXX specifies the Action (or Message, as usual in GUIs),
   > while helpXXX specifies an optional help context for online help.

How about something similar from STk:

(define-method make-menu ((self <dbwidget>) menu-parent window)
;;;      Menu structure
;;;      File        DO      Sort      Filter     ...  Help
;;;        -Save       -Set    -Set     -Set             -help
;;;        -Meta-add   -Do 1   -Do 1    -Do 1
;;;        -Undo       -Do 2   -Do 2    -Do 2
;;;        -Save
;;;        -Quit       -Do 3   -Do 3    -Do 3

  (define (make-cmd-list name-cmd-pairs f slot)
    (cond ((null? name-cmd-pairs) ())
	  (else
	   (cons (list
		  (caar name-cmd-pairs)
		  (lambda ()
		    (f self (cadar name-cmd-pairs))
		    (slot-set! self slot
			       (cadar name-cmd-pairs))))
		 (make-cmd-list (cdr name-cmd-pairs) f slot)))))

  (let* ((menu-list `((" File"
		       ("Reload"
			,(lambda () (open-dbase self)))
		       ("Meta Add"
			,(lambda ()
			   (set-new-record-of 
			    *master-db*
			    (list-insert! (get-state-of self) 2 ""))
			   (add-record *master-db*)))
		       ("Undo"
			,(lambda () (undo self)))
		       ("Save"
			,(lambda () (save-dbase self)))
		       ("")
		       ("Edit Current"
			,(lambda () (edit-record-popup self)))
		       ("")
		       ("Quit"
			,(lambda ()
			   ((quit-hook-of self) self)
			   (close-dbase self)
			   (destroy window))))
		      (" Do "
		       ("Add" ,(lambda ()
				 (get-doer self menu-parent)))
		       ("Edit" ,(lambda ()
				  (edit-slot "Command"
					     'cmd-list
					     self menu-parent)))
		       ("")
		       ,@(make-cmd-list (cmd-list-of self)
					(lambda (s f)
					  (execute-do-cmd-on-current s f))
					'cmd))
		      (" Sort "
		       ("Add" ,(lambda () (get-sort-popup self menu-parent)))
		       ("Edit" ,(lambda ()
				  (edit-slot "Sorter" 'sort-list self menu-parent)))
		       ("")
		       ,@(make-cmd-list (sort-list-of self)
					(lambda (s f) (sort-data-of s f))
					'sorter))
		      (" Filter "
		       ("Add" ,(lambda () (get-filter self menu-parent)))
		       ("Edit" ,(lambda ()
				  (edit-slot "Filter" 'filter-list self menu-parent)))
		       ("")
		       ,@(make-cmd-list (filter-list-of self)
					(lambda (s f) (filter s f))
					'filter))
		      ((" Help " :side "right")
		       ("dbzone" ,(lambda () (stk:show-help-file *help-file*)))
		       ("General STk help" ,(lambda () (help)))))))
    (make-menubar menu-parent menu-list)))

This function puts a menu on a database viewer object.  The database
viewing object contains lists of data from which some of the menu
commands are generated.  For example, where you see:

  ,@(make-cmd-list (cmd-list-of self)
	(lambda (s f)
	   (execute-do-cmd-on-current s f))
		'cmd)

(cmd-list-of self) returns a list of the form:
   ((name1 fcn1) (name2 fcn2) ...)

@,(make-cmd-list...) then splices something like the following into
the menu list:

   ("name1" (lambda ()
                (execute-do-cmd-on-current self fcn1)
	        (slot-set! self 'cmd '(execute-do-cmd-on-current self fcn1))))
   ("name2" (lambda ()
                (execute-do-cmd-on-current self fcn2)
	        (slot-set! self 'cmd '(execute-do-cmd-on-current self fcn2))))
 ...

The slot-set! records the last action on the 'cmd slot in the database
viewer object.

-- 
Harvey J. Stein
Berger Financial Research
abel@netvision.net.il


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

Date: 8 May 1997 10:12:32 GMT
From: etltsln@etlxd30.ericsson.se ( Thomas Lachlan XMS x1893 )
Subject: Require assistance with function stat
Message-Id: <5ks8ug$r4i@newstoo.ericsson.se>

Good day everybody,
		I'm using stat in a script I'm writing, however
		due to extreme ignorance on my part I'm having difficulty
		deciphering the significance of the 5 digit $mode field
		returned by the afore mentioned function.
										 
		I would be most grateful if one of you groovy perl dudes
		could enlighten me on this subject. I.e. I know that the 
		number contains info pertaining to the mode and type of 
		file but how do I interpret this to something useful.
																												  
																																					  Thankyou for taking your time to read the above.
																																							   
																																									   Yours Tom Lachlan
																																																		
																																									etltsln@etlxdmx.ericsson.se



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

Date: Thu, 08 May 1997 01:23:05 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: standards
Message-Id: <comdog-0805970123050001@nntp.netcruiser>

In article <337141BF.7C1F@swbell.net>, walkerjl@swbell.net wrote:

> Does anyone know of a source for programming standards in Perl?

perhaps you want the perlstyle man page? or do you want to program
standards?

-- 
brian d foy                              <URL:http://computerdog.com>                       
unsolicited commercial email is not appreciated


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

Date: Thu, 8 May 1997 01:19:53 -0400
From: "Otis Gospodnetic" <otisg@panther.middlebury.edu>
Subject: Re: system () won't execute the called program.
Message-Id: <5krne2$19da$4@tiger.middlebury.edu>

are you sure you want to use && ?
I think you want | in place of &&

Otis
--
POPULUS, the Intelligent People Locator -- http://www.POPULUS.net/

 Ken Anderson wrote in article ...

>I have a perl program which has to execute an external
>c program, so i am using
>
>
> system("cprog -p prog.par") && die "cprog failed. $!\n";
>
>It simply does nothing. cprog never starts. no error message.
>What am i missing?





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

Date: Thu, 08 May 1997 03:00:50 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: system () won't execute the called program.
Message-Id: <comdog-0805970300500001@nntp.netcruiser>

In article <5krne2$19da$4@tiger.middlebury.edu>, "Otis Gospodnetic"
<otisg@panther.middlebury.edu> wrote:

>  Ken Anderson wrote in article ...

> > system("cprog -p prog.par") && die "cprog failed. $!\n";

> are you sure you want to use && ?
> I think you want | in place of &&


almost :)  that would be ||, although i prefer the looser bound "or"

-- 
brian d foy                              <URL:http://computerdog.com>                       
unsolicited commercial email is not appreciated


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

Date: Thu, 8 May 1997 06:32:27 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: system () won't execute the called program.
Message-Id: <bkdsk5.8i.ln@localhost>

brian d foy (comdog@computerdog.com) wrote:
: In article <5krne2$19da$4@tiger.middlebury.edu>, "Otis Gospodnetic"
: <otisg@panther.middlebury.edu> wrote:

: >  Ken Anderson wrote in article ...

: > > system("cprog -p prog.par") && die "cprog failed. $!\n";

: > are you sure you want to use && ?
: > I think you want | in place of &&


: almost :)  that would be ||, although i prefer the looser bound "or"


Nope. You want && when using system() because it returns zero for
success and non-zero for failure...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 8 May 1997 07:00:00 GMT
From: "Santiago Alvarez Rojo" <santiago@gambito.com>
Subject: Re: Where do I get PERL?
Message-Id: <01bc5b7d$6677d420$7131a8c0@sg059pcs>

Wyatt,

you can get perl distribution from CPAN at:
	http://www.perl.com/CPAN/src
>From CPAN you also can get documentation, modules, scripts and author's
directories.

Hope this helps.
Santiago
+------------------------------------------------------------------+
| Santiago Alvarez Rojo                                            |
|    santiago@gambito.com                                          |
|    http://www.gambito.com/santiago                               |
|                                                                  |
| PGP public-key: http://gambito.com/santiago/pgp.txt              |
|   fingerprint = D2 BB 9F DD 48 84 9F 5B  80 41 50 D2 28 12 1C 59 |
+------------------------------------------------------------------+

Wyatt <wwyatt@alltel.net> escribis en artmculo
<33711EFF.5E55E46A@alltel.net>...
> Could someone point me in the direction of the perl software? I'm tring
> to set up a counter on my computer (server) and it says that I need
> perl. Thanks
> 
> 
> Wyatt
> 
> 


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

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

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