[9570] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3164 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 15 13:07:19 1998

Date: Wed, 15 Jul 98 10:00:35 -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           Wed, 15 Jul 1998     Volume: 8 Number: 3164

Today's topics:
        Editing files in Perl tim221175@my-dejanews.com
    Re: forms and sub routines <maierc@chesco.com>
        Help with this regex: s/(foo)([^l])/$1x$2/g <nobody@nowhere.net>
    Re: Help with this regex: s/(foo)([^l])/$1x$2/g (Sean McAfee)
    Re: How to get proccess info in perl (Steve Linberg)
    Re: inconstant behavior of constants (Craig Berry)
    Re: inconstant behavior of constants (M.J.T. Guy)
        Need help with extension and nested packages... (Subotai)
    Re: newbie question on pattern match (Craig Berry)
    Re: Perl Beautifier Home Page <jdporter@min.net>
    Re: Perl Beautifier Home Page (Craig Berry)
    Re: Perl Beautifier Home Page <jdporter@min.net>
    Re: Perl Beautifier Home Page (Alan Barclay)
    Re: perl embedding on win32 (Steve Linberg)
    Re: Perl Setup on NT (Steve Linberg)
    Re: Perl to PostgreSql problem (Steve Linberg)
    Re: ping scan (Steve Linberg)
        Please Help Me! (Matt's Script BB Problem) Sniper308@qconline.com
    Re: Please Help Me! (Matt's Script BB Problem) (Steve Linberg)
    Re: Pre-pending data to a database or file. <aqumsieh@matrox.com>
    Re: Problems creating files CGI-Unix <guillaume@deepend.co.uk>
    Re: Q: Changing IP address via perl <p-fein@uchicago.edu>
        SMB and Timestamps <brentj@ext.msstate.edu>
    Re: Sticking in NULL after split <franzen@pmel.noaa.gov>
    Re: The three properties of programmers (Steve Linberg)
    Re: working on /etc/passwd in a multi-user env. (Steve Linberg)
    Re: Working with Frame (Steve Linberg)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 15 Jul 1998 16:26:30 GMT
From: tim221175@my-dejanews.com
Subject: Editing files in Perl
Message-Id: <6oil7m$vdc$1@nnrp1.dejanews.com>

In article <MPG.1016c3dc3bf9e9499896b2@news.surfnet.nl>,
  real@earthling.net wrote:
> tim221175@my-dejanews.com wrote;
> >  Is there an easy way of editing a file. I want to append a line of text in
> > the middle of a text file. Will I have to cut the file in two halves and
then
> > concatenate them with new line in the middle or is there an easy way to do
> > this in perl?
>
> Yes it is possible but you'll have to specify 'the middle of a text
> file'. Is this after a certain number of lines, etc, etc, ?  Once this is
> determined, a simple Perl script can do something like;
>
>   - read (next) line of file #1
>   - middle of file encountered ?   if yes: write extra line
>   - write line of file #1
>
> Cheers,
> Real
>

What I want is to add a line of text in the middle of a file. I have a file
handle <FILE> and I want a line of text "new line\n" to be added after a
certain amount of <FILE> have been read by a function like this

$t = 0;
while (<FILE>)
{
 $temp = $_;
 $t ++;
 if ($t = 29) { ADD NEW LINE }
}

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 15 Jul 1998 15:51:00 GMT
From: Charles Maier <maierc@chesco.com>
Subject: Re: forms and sub routines
Message-Id: <35AADF66.27D7@chesco.com>

Dave Paules wrote:
> 
>     I needed to know if there was a way to link an HTML form submit
> button to
> a subroutine written in PERL. Usually there is a <form> tag with
> action=some script name. But what I want is not another script to be
> executed. I want the button to execute a sub routine of the current perl
> script that created the HTML where the <form> is. I would like to stick
> these little subroutines in a library later so that the main script
> would simply be some calls to subroutines that are linked to form
> buttons. Is this possible?
>     Dave Paules, senior, University of Delaware
>     Summer intern, ARL


I do this sort of thing routinly. The only 'trick' is to include some
parameter in the generated HTML form to 'stear' the script to know what
to do with THIS submit. i generally have done it with a hidden field..
its contents are then put through  if..elseif..else (case/switch)
statements to decide what to do. This way you don't have to maintain a
number of 'recieving' scripts.


-- 
Chuck Maier
CDM Consulting Services
http://www.cdmcon.com
(610) 943-2726


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

Date: 15 Jul 1998 07:22:03 GMT
From: Stephen Lee - Post replies please <nobody@nowhere.net>
Subject: Help with this regex: s/(foo)([^l])/$1x$2/g
Message-Id: <6ohlar$jq6$1@trotsky.cig.mot.com>

Can somebody tell me why this regex work this way with "foofoo"?
I expected "fooxfoox" in return, not "fooxfoo".

Context:  I was trying to repair some broken HTML files that looked like
"&quot&gtSome &gttext" and tried 's/&(quot|gt)([^;])/&$1;$2/g'.

I am surprised [^;] matches $ (end of line) too.  I need getting more used
to perl.

Stephen

$ perl -p -e 's/(foo)([^l])/$1x$2/g'
foo
foox
foobar
fooxbar
foobarfoo
fooxbarfoox
foobarfoobarfoo
fooxbarfooxbarfoox
foofoo
fooxfoo
foofoofoo
fooxfoofoox
^D
$ perl -v

This is perl, version 5.004_04 built for sun4-solaris

Copyright 1987-1997, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.



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

Date: Wed, 15 Jul 1998 16:18:18 GMT
From: mcafee@breakout.rs.itd.umich.edu (Sean McAfee)
Subject: Re: Help with this regex: s/(foo)([^l])/$1x$2/g
Message-Id: <eD4r1.3868$24.22190785@news.itd.umich.edu>

In article <6ohlar$jq6$1@trotsky.cig.mot.com>,
Stephen Lee - Post replies please  <nobody@nowhere.net> wrote:
>Can somebody tell me why this regex work this way with "foofoo"?
>I expected "fooxfoox" in return, not "fooxfoo".

>Context:  I was trying to repair some broken HTML files that looked like
>"&quot&gtSome &gttext" and tried 's/&(quot|gt)([^;])/&$1;$2/g'.

>I am surprised [^;] matches $ (end of line) too.  I need getting more used
>to perl.

It doesn't.  [^;] is matching the newline character at the end of the line.

>$ perl -p -e 's/(foo)([^l])/$1x$2/g'
>foo
>foox
>foofoo
>fooxfoo

When matching globally, the pattern match picks up after the point where
the last match left off.  The pattern first matches "foof", which is
replaced with "fooxf".  The rest of the string is "oo", which doesn't match
the pattern, so the substitution ends.  What you really want is a lookahead
assertion (see the perlre manpage):

s/foo(?!l)/foox/g;

Or, in the cast of your html problem:

s/&(quot|gt)(?!;)/&$1;/g;

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Wed, 15 Jul 1998 12:36:21 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: How to get proccess info in perl
Message-Id: <linberg-1507981236210001@projdirc.literacy.upenn.edu>

In article <35ABEAF4.732B6B6D@gs.com>, Xiangdong Xu <xiangdong.xu@gs.com> wrote:

> Hi folks,
> Is there a perl module to collect the process info just like ps does?
> Thanks in advance,
> 
> Xiangdong

#!/usr/bin/perl

$info = `ps`;
print $info;
__END__
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: 15 Jul 1998 16:18:38 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: inconstant behavior of constants
Message-Id: <6oikou$kqu$3@marina.cinenet.net>

Larry Rosler (lr@hpl.hp.com) wrote:
: > Never mind, Larry Rossler just posted the answer to this.  LSNED...
: 
: LSNED???

"Learn something new every day."

: The theme of last Sunday's New York Times crossword was "If I had a 
: nickel for every dollar I put in the bank, I'd have 1/20 of what I have 
: now."  If I had a nickel for every extra 's' in my name, I'd be lots 
: richer than I am now. :-)

Sorry...feel free to keep my extra 's' as a spare in case anything happens
to the one you have. :)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 15 Jul 1998 16:47:53 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: inconstant behavior of constants
Message-Id: <6oimfp$f1u$1@pegasus.csx.cam.ac.uk>

Any more mini-dilemmas I should know about?  <jefpin@bergen.org> wrote:
>
>ok.  Firstly, in a hash assignment, $hash{foo} => $hash{"foo"}.  Therefore,
>$myarr{STARTYEAR} => $myarr{"STARTYEAR"}, which is the literal string
>"STARTYEAR".

Wrong (or at least misleading).   It's nothing to do with hash assignment.
A hash subscript which is a bareword is _always_ treated as a string.

>	$myarr{@{[ STARTYEAR ]}} = 1984;
>as messy as that may be.

You don't need to obfuscate like that.   Any of $myarr{+STARTYEAR},
$myarr{&STARTYEAR} or $myarr{STARTYEAR()} would do, according to taste.


Mike Guy


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

Date: 15 Jul 1998 16:24:01 GMT
From: subotai@aol.com (Subotai)
Subject: Need help with extension and nested packages...
Message-Id: <1998071516240100.MAA29961@ladder03.news.aol.com>

Hi, I am having a problem getting an extension I created to work
with nested packages. Let me explain:

I am building a module, lets say called First.pm.
I wanted it to be an interface to another module called Second.pm.

I have used h2xs -A -n to create the "First.pm" module.
I then made the "Second.pm" module in a "First/" subdirectory.
So it will be the nested package First::Second;

I have functions declared in the Second.pm file that I export and can access
fine if I include:
use First::Second in my test script.

I also have a First.xs file that conatins a C function that I want "Second.pm"
to be able to access. The module specified in the .xs file is" First". The
package specified in the .xs file is "First::Second". I also "require
First::Second;" in the First.pm module. 

  For some reason the Second.pm module can not see the function that was
declared in the First.xs file. I can build and install the module without a
problem. But when I test it, it dies when I try to access the function that was
declared in the First.xs file. The error message that I recieve is that it cant
find a .al file for the function I am calling.

   I have tried this without using a nested package with just one module and I
could access the function declared in the First.xs file with no problems. It is
only when I introduce nested packages and multiple .pm files that I run into a
problem. Can anyone tell me what I need to specify so that the Second.pm module
will be able to access the function declared in the First.xs file? 

Thanks In Advance!!


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

Date: 15 Jul 1998 16:13:45 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: newbie question on pattern match
Message-Id: <6oikfp$kqu$2@marina.cinenet.net>

Abigail (abigail@fnx.com) wrote:
: wings (xuchu@iscs.nus.edu.sg) wrote on MDCCLXXIX September MCMXCIII in
: <URL: news:6oh5uk$eb13@id4.nus.edu.sg>:
: ++ thx for all replies. i am clear now:) yes, my original thought was
: ++ 	s/(\d)(\d\d\d)(\D)*/$1,$2/; and s/(\d)(\d\d\d)(\D)+/$1,$2/;
: ++ but neither of them worked. i was confused at that time coz the output
: ++ ate the trail of my original string.
: 
: Note that all the proposed solutions, correct or not, suffer from
: one thing: they are quadractic in the size of the number. Note a
: problem if you numbers are below a million, but a potential one
: if the numbers are huge.

Note that N here is not the size of the number in the sense of its
magnitude, but rather in the sense of its left-of-the-decimal digit
count...which is roughly the base-10 logarithm of the (absolute value of
the) number.  I don't think even a quadratic algorithm is a problem for Ns
in perhaps the low teens at most (which takes us up into the trillions). 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Wed, 15 Jul 1998 16:03:58 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl Beautifier Home Page
Message-Id: <35ACD491.37A3@min.net>

Michael J Gebis wrote:
> 
> ... Wall & Associates can define deprecated any way they want...

Right.  Weren't you one of the ones saying rms can define "free"
any way he wants, too?

-- 
John Porter

We have enough youth, how about a fountain of smart?


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

Date: 15 Jul 1998 16:05:26 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6oik06$kqu$1@marina.cinenet.net>

John Porter (jdporter@min.net) wrote:
: IMHO, tabs suck hard, especially if you're working in a multi-programmer
: environment.  Each guy has his own preferences for tab width.  And
: when one guy loads a file created by another guy who likes a different
: tab width, it just looks like hell...   The first thing the guy does is
: go and reformat the entire file so it looks good in his editor.

Amen to that.  In every multi-person software project I've ever worked on,
an early decision has been made to use spaces *only* for indents.  Any
reasonable editor can make them 'feel like' tabs as you edit (either by
using 'soft tabs', or real tabs during editing which are detabified on
write).

Now, um, as to what this has to do with Perl, ah...tabify and detabify are
really easy to write in Perl.  Yeah, that's it. :-)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Wed, 15 Jul 1998 16:08:02 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl Beautifier Home Page
Message-Id: <35ACD585.3D4@min.net>

Ilya Zakharevich wrote:
> 
> [A complimentary Cc of this posting was sent to Tom Christiansen
> <tchrist@mox.perl.com>],
> who wrote in article <6ob6ql$rd8$1@csnews.cs.colorado.edu>:
> > :CPerl works on Perl code.  What is at this URL is not Perl.
> >
> > Yeah, right.  My Perl compiler works find on it, and so does yours.
> 
> Which proves nothing.  It is not Perl4, since it uses isn't_programmer
> without leading &, and is not Perl5 since it uses isn::t_programmer
> without ::.  Thus it is not Perl.

Whoa.
If what you're saying is true, then there is no Perl interpreter;
the machine we have does not conform to the specification.

Personally I favor the notion that the interpreter defines the
language, and the documentation exists to express the behavior of
the interpreter for human readers.  I.e. that there is a doc bug.

But you take the opposite viewpoint.

-- 
John Porter

We have enough youth, how about a fountain of smart?


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

Date: 15 Jul 1998 16:31:36 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Perl Beautifier Home Page
Message-Id: <900520293.613101@elaine.drink.com>

In article <6ograf$bj3@mozo.cc.purdue.edu>,
Michael J Gebis <gebis@albrecht.ecn.purdue.edu> wrote:
>lr@hpl.hp.com (Larry Rosler) writes:
>
>}In "standards-speak" 'deprecated' has a very specific meaning:  "May be 
>}removed from the language in a future revision of the standard."  This 
>}isn't a value judgment about the feature or its use, just a warning that 
>}it may go away some day. 
>
>That meaning of deprecated isn't very standard.  Or at least Bjarne
>doesn't think so:

Of course, the meaning of 'deprecated' isn't very relevent in this
discussion, as using ' isn't deprecated, according to the quote given
above. It says that :: is the preferred seperator in perl5, a very
different meaning.

Coding with everything stuck to the left margin, all in lower case and
using variables comprised only of vowels isn't the preferred coding style,
but I don't think that perl is going to stop understanding such code at
any point in the future.


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

Date: Wed, 15 Jul 1998 12:25:53 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: perl embedding on win32
Message-Id: <linberg-1507981225530001@projdirc.literacy.upenn.edu>

In article <6oh2ek$n8f$1@nnrp1.dejanews.com>, livshits@acm.org wrote:

> Hi, I am trying to embed a perl interpreter into my C program.
> I managed to build perl sources using Visual C successfully. However,
> when I try to #include EXTERN.h and perl.h into my program, I get
> compiler messages complaining about things like
>   extern void PerlIO_init _((void));
> in perlio.h.
> 
> Has anyone else had similar problems?

Similar to what?  What is the error message?
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Wed, 15 Jul 1998 12:27:24 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Perl Setup on NT
Message-Id: <linberg-1507981227240001@projdirc.literacy.upenn.edu>

In article <6ogu63$nje$1@news-2.news.gte.net>, "tdean" <tdeanatgtedotnet> wrote:

> I want to execute my perl scripts from within the Dos box on NT4SP3 from C:\
> I have added the following to the path environment variable:
> C:\;C:\Perl\bin and rebooted the machine to take effect
> when I then open a NT Dos box which defaults to c:\ and I try to execute a
> perl script:
> perl perlscript.pl  I get the following msg:
> "can't open perl script perlscript.pl. No such file or directory"
> guys, whats the fix for this?

where is perlscript.pl?
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Wed, 15 Jul 1998 12:29:00 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Perl to PostgreSql problem
Message-Id: <linberg-1507981229000001@projdirc.literacy.upenn.edu>

In article <35ABED8F.15B@2lm.com>, Paula Gibb <paula@2lm.com> wrote:

> Hi there,
> 
> First the good news: I finally installed the latest version of
> PostgreSql as well as the Postgres interface written by K. Vivek. onto
> my Linux server last week.  I could also successfully execute a little
> Perl script that would count the number of entries in a table (whoopee!)
> from telnet.
> 
> The bad news: When I try to execute the Perl script from an HTML form
> (read: from an HTML browser), I am receiving a server error.
> 
> Do I need to somehow indicate to the httpd server that I am doing a
> database process, or is there something else that I am completely
> missing?
> 
> Thanks for any input you can provide...
> 
> Paula G.

If your Perl script runs successfully from the command line, then you are
not having a Perl problem.  You are having a server configuration problem,
and should post to the appropriate groups.  Good luck.
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Wed, 15 Jul 1998 12:41:26 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: ping scan
Message-Id: <linberg-1507981241260001@projdirc.literacy.upenn.edu>

In article <Pine.HPP.3.96.980714160844.4449G-100000@hornet.ns.net>, James
Nessen <nessenj@ns.net> wrote:

> I was curious if anyone has developed a perl application that will ping a
> range of ip's to see if anything is alive, ie you give it
> xxx.xxx.xxx.xxx/24 and it will ping the entire class c? or a /26, /29 etc.
> 
> if anyone has, id be curious to see, ive been trying but i dont know where
> to start :-)
> 
> Jim

You could certainly do something like this:

for ($i=0; $i<256; $i++) {
   $info = `ping -c 5 foo.bar.baz.$i`;
}

There are probably better approaches, though.  Dig around CPAN and see
what you find.
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Wed, 15 Jul 1998 16:31:30 GMT
From: Sniper308@qconline.com
Subject: Please Help Me! (Matt's Script BB Problem)
Message-Id: <6oilh2$vsh$1@nnrp1.dejanews.com>

I've tried and tried and tried... I canNOT get the !#@%@#% BB to work at
https://www.armalite.com/wwwboard/wwwboard.html -- I've changed the
permissions, the works... everything I can figure out.	I've written to Matt
with no response.  I "REALLY" need to get this thing up and running!!!

HELLLLLLLLLLLLLLLLLLLLLLLLLP!!!

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 15 Jul 1998 12:56:35 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Please Help Me! (Matt's Script BB Problem)
Message-Id: <linberg-1507981256350001@projdirc.literacy.upenn.edu>

In article <6oilh2$vsh$1@nnrp1.dejanews.com>, Sniper308@qconline.com wrote:

> I've tried and tried and tried... I canNOT get the !#@%@#% BB to work at
> https://www.armalite.com/wwwboard/wwwboard.html -- I've changed the
> permissions, the works... everything I can figure out.  I've written to Matt
> with no response.  I "REALLY" need to get this thing up and running!!!
> 
> HELLLLLLLLLLLLLLLLLLLLLLLLLP!!!

I'll be glad to.  My contract rate is $125/hr.  Contact information below.

If you want free help, you should provide a lot more information about
specifically what's wrong.  "It doesn't work" isn't much to go on.  And
please remember that you should be polite and nice when asking for free
help.  

Finally, I can tell you right now that you are looking at a server
configuration problem or an HTML filename reference problem, not a Perl
problem, unless you have modified the scripts.  Matt's scripts are far
from perfect and roundly criticized here, but they do function.  So the
chances are that aren't in the right place -- again, unless you have
modified the scripts.

Good luck.
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Wed, 15 Jul 1998 10:37:55 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Pre-pending data to a database or file.
Message-Id: <35ACBEC3.99AE7DE7@matrox.com>

David Hemmer wrote:
> 
> I know that I can append information to a flatfile db or other file,
> 
> example:
> open (DATABASE, ">>./$data");
> 
> but is there some way to pre-pend the data to the specified file?
> 
> Thanks
> 
> Dave Hemmer

Well, There Is More Than One Way To Do It!!
The simplest approach would be using the unix 'cat' command .. but that
only works on Unix-like machines ... 
The second would be to re-write the cat command if you are on a Winblows
machine ;-)
The third would be to read your database .. open a new file .. print
whatever you want first and then print what you read from the database
 .. i.e something like:

open DATABASE, $data or die "Can't open database: $!\n";
open NEWDB, ">$new_file_name" or die "Can't open new DB: $!\n";
print NEWDB $data_that_you_want_to_preappend;
while (<DATABASE>) {
    print NEWDB $_;
}
close DATABASE or die "Can't close OLD: $!\n";
close NEWDB or die "Can't close NEW: $!\n";

The fourth, and by far BEST, approach is to read the standard FAQs that
come with the Perl distribution. In perlfaq5 I found:

     How do I change one line in a file/delete a line in a
     file/insert a line in the middle of a file/append to the
     beginning of a file?

The answer is too long for me to paste :-)

-- 
Ala Qumsieh             |  No .. not Just Another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)


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

Date: Wed, 15 Jul 1998 17:12:22 +0100
From: Guillaume Buat-Menard <guillaume@deepend.co.uk>
To: "Guillermo Garcis" <ggarces@arrakis.es>
Subject: Re: Problems creating files CGI-Unix
Message-Id: <35ACD4E6.9424CB6A@deepend.co.uk>



Guillermo Garcis wrote:

> I can4t create files putting:    open NEW, "+>$PAGE" or die "Error
> opening$PAGE\n$!";
> i don4t know if the name is too long or i have to give permissions.
> I tried too: open NEW, ">$PAGE" or die "Error opening $PAGE\n$!"; but it
> don4t works....
> When i try to create files appears the next error: Permission denied
> What i have to do?
> Thanks.



You have to set the right permissions for the directory you want to write
in:
chmod 664 directory_where_the_file_must_be_created
and if it doesn't work it might be because the perl script runs under the
'other' permission so set it to:
chmod 666 directory_where_the_file_must_be_created

hope it helps,

Guillaume.

--
----------------------------------------------
Guillaume Buat-Menard
guillaume@deepend.co.uk
Deep End Design Ltd
40-42 Scrutton Street, London EC2A 4QL
+44 (0) 171 247 2999
http://www.deepend.co.uk
----------------------------------------------




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

Date: Wed, 15 Jul 1998 15:56:55 GMT
From: Peter A Fein <p-fein@uchicago.edu>
Subject: Re: Q: Changing IP address via perl
Message-Id: <opgzpeb3y60.fsf@harper.uchicago.edu>

Bullwinkle <at@whatsamattau.edu> writes:

> 
> I routinely move my laptop between the ethernet at work and an ethernet
> at home. I've got the changes needed down to just changing the IP
> address and rebooting. However, it's still kludgey.
> 
> 1) Is there a perl module that will let me write a script to change the
> machine's IP address?
> 2) Any conceivable way to "restart" just the ip stack, rather than the
> entire machine?

Umm, probably.  What OS are you on?

-- 
Peter A Fein                                           Summering in SF!
Home: 650-571-6476                                   Work: 650-628-2172
p-fein@uchicago.edu                             pfein@us.checkpoint.com
Gilette's Razor: The best a man can get.


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

Date: 15 Jul 1998 16:24:01 GMT
From: Brent Johnson <brentj@ext.msstate.edu>
Subject: SMB and Timestamps
Message-Id: <6oil31$aph$1@nntp.msstate.edu>

I am trying to write a Perl script which scans through a common
public directory and moves any files older than a certain date
to another directory.  Problem is, when someone saves a file to
a mounted SMB filesystem, it keeps the original file date.

Is there a way to 'touch' files when they are copied?  Or some
other way?  I've looked at the creation times (same as it is
on their PC's), modified times (no help there) and the 'atime' ..
which I have no idea what that is.. but it isnt correct.

Any help would be appreciated,

- Brent


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

Date: Wed, 15 Jul 1998 09:12:20 -0700
From: Nathan Franzen <franzen@pmel.noaa.gov>
Subject: Re: Sticking in NULL after split
Message-Id: <Pine.SOL.3.96.980715085123.29484A-100000@corona.pmel.noaa.gov>

On 15 Jul 1998, Mark-Jason Dominus wrote:

> I'd like to see people get out of the habit of saying `preferable to'
> when all they mean is `faster than'.
> 
> They aren't the same thing.

True enough.  I agree completely.  Mea culpa.  And using 'map' may be more
comprehensible. But I made a second point in my post, which is that: 

@array = split /,/, '1,2,3,,5,,,,,,,';

will return an array of length 5, not length 11.  If you want the *all*
the non-filled ',,'s filled with 'NULL', you're better off doing the
substitution first.  

And if you want ',,,' replaced with ',NULL,NULL,', the easiest thing to do
is C<1 while s/,,/,NULL,/;>.  (Although there are alternatives with
lookaheads, etc, which could be faster and depending on your point of
view perhaps preferable, too. :)  More than one way &c. )

-Nathan

p.s.  But how do you get an array of length 11 out of

@array = split /,/, '1,2,3,,5,,,,,,,'; ?

Here's how:

@array = split /,/, '1,2,3,,5,,,,,,,', -1;
pop @array;

But isn't that a little clunky?  







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

Date: Wed, 15 Jul 1998 12:20:30 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: The three properties of programmers
Message-Id: <linberg-1507981220300001@projdirc.literacy.upenn.edu>

In article <s7p3ec3ur6w.fsf@serinde.elsevier.nl>, Piers Cawley
<pdcawley@bofh.org.uk> wrote:

> "Mark Stang" <markstang@ncgroup.com> writes:
> 
> > I am racking my brain trying to remember the three properties of
> > programmers, as per the Camel book.  Alas, I do not have my copy with me.
> > 
> > I can remember 2 of them: laziness and hubris...please someone tell
> > me...what is the third?
> 
> So, rather than wait 'til you got to where your books were you got
> impatient and asked the 'net instead. Good call, not only are you too
> lazy to check the references yourself but you have sufficient hubris
> to think that everyone else would be interested.

Which means he's a good programmer!
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Wed, 15 Jul 1998 12:23:21 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: working on /etc/passwd in a multi-user env.
Message-Id: <linberg-1507981223210001@projdirc.literacy.upenn.edu>

In article <6oiek2$9gf$1@platane.wanadoo.fr>, "Freddy"
<fgueant@orka-intl.com> wrote:

> Hi!
> I want to write a script that edit /etc/passwd and/or /etc/shadow, but this
> script is going
> to be called by a http way... it mean two users can send this script, but i
> want the two
> to modify the file, one after the other, in their order of appearance...
> how can i manage it? i'm working on redhat4.2 with perl5.002 (or 3, or 4,
> don't remember..)
> thank you for helping me... scalp@orka.fr

Eeeek.  You're awfully brave.  Especially if you're going to tackle
something this dangerous without even knowing which version of Perl you're
using.

So what kind of help are you looking for?
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Wed, 15 Jul 1998 12:43:34 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Working with Frame
Message-Id: <linberg-1507981243340001@projdirc.literacy.upenn.edu>

In article <35ACAA91.112C061@uea.ac.uk>, Rattasit Sukhahuta
<R.Sukhahuta@uea.ac.uk> wrote:

> Is there a perl command to send an output to different frame?  The
> problem that I have is when I use the following command,
> 
> print "Content-type: text/html\n\n";
>  print "<html><head><title>Error Page</title></head>\n";
>  print "<center><font color=\"#8000FF\" size=+3>Error
> Page</font></center><br>\n";
>  print "<body>\n";
>  print "<font size=+2>$str</font><br>\n";
>  print "</body></html>\n";
> 
> it always send back to the first frame.  What I want to do is to send
> the error message to a different frame.

Perl doesn't output to frames.  Perl just outputs.  You have an HTML/CGI
question, which should be taken up somewhere appropriate.  Good luck.
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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