[12522] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6122 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 25 00:07:29 1999

Date: Thu, 24 Jun 99 21:00:17 -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, 24 Jun 1999     Volume: 8 Number: 6122

Today's topics:
        Binding arrays to PL/SQL stored proc output tables in D <melnyk@tradeout.com>
    Re: CGI.pm, hashes, passing by reference and two differ (Eric Bohlman)
        DBI and ODBC (on NT-server) <Kelbo@rhk.dk>
    Re: Dynamic Page Generation (Eric Bohlman)
    Re: Error in my CGI that a can't find!  Need help debug (Andrew Allen)
        Help a newbie! <bbridges@seark.net>
    Re: Help a newbie! (Martien Verbruggen)
    Re: Help with PPM <david@medal.force9.net>
    Re: How can I read a whole file in one go ? (Michael Stillwell)
    Re: How can I read a whole file in one go ? (Eric Bohlman)
    Re: How can I read a whole file in one go ? <tchrist@mox.perl.com>
    Re: How can I use Perl variables in Javascript ? (David Glasser)
    Re: Process id for fork()ed process (Martien Verbruggen)
        Programming job <newart@shell11.ba.best.com>
    Re: Read a file starting a a certain point in the middl (Eric Bohlman)
    Re: Regex question (i think) <revjack@radix.net>
        Regular Expression - Doubt <nsunitha@cse.unl.edu>
    Re: Regular Expression - Doubt (Larry Rosler)
    Re: should be how to remove ^M from middle of variable? <kazuma@my-deja.com>
    Re: Writing to a terminal from a perl script (Alan Curry)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 24 Jun 1999 21:24:51 -0400
From: Mike Melnyk <melnyk@tradeout.com>
Subject: Binding arrays to PL/SQL stored proc output tables in DBI??
Message-Id: <3772DA62.9430BB4A@tradeout.com>

This is a multi-part message in MIME format.
--------------9AA01CE55723AEEC02074F81
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi all,

With DBI, how do I bind an array (or array reference) to a PL/SQL 'OUT'
parameter that's a table?

I've seen several people ask this question in the past year, but I have
not seen a an answer.

Binding to OUT scalar parameters is simple enough -- use the
DBI->bind_param_inout() method. It seems that the bind value *has* to be
a reference to a scalar, and I can't find a way to bind an array to an
output table without the DBI->execute() or DBI->bin_param_inout()
methods barfing...

Every example of calling a stored proc from perl/DBI assumes the proc
args are all scalars. Scary.

If I can't bind perl arrays easily, how do you retrieve data arrays from
PL/SQL stored procedures? Creating and inserting into temp tables?
Returning a cursor variable?

Help!!

Thanks,

Mike Melnyk
TradeOut.com, Inc.
(949) 632-7496


--------------9AA01CE55723AEEC02074F81
Content-Type: text/x-vcard; charset=us-ascii;
 name="melnyk.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Mike Melnyk
Content-Disposition: attachment;
 filename="melnyk.vcf"

begin:vcard 
n:Melnyk;Mike 
tel;cell:(949) 632-7496
tel;home:(617) 623-4641
x-mozilla-html:TRUE
adr:;;;;;;
version:2.1
email;internet:melnyk@tradeout.com
fn:Mike Melnyk
end:vcard

--------------9AA01CE55723AEEC02074F81--



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

Date: Fri, 25 Jun 1999 03:37:21 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: CGI.pm, hashes, passing by reference and two different results?
Message-Id: <ebohlmanFDv629.9Cr@netcom.com>

John Warner (john.warner@tivoli.com) wrote:
: sub getLinks{
:  my ($m) = @_;
:  my $urlcount = 0;
:  my ($topic,$t);
:  open URLFILE, "links.txt";

You failed to check if your open was successful.  If you're running this 
as a CGI script, your current directory may very well not be what you 
think it is, and I'll bet that if you check your open status and print 
out a nice diagnostic message, you'll find that there simply isn't a 
links.txt in your current directory.  In CGI scripts, you should always 
either open files with full pathnames or chdir to the desired directory 
first.

: why do I get different results from the command line than I do from the
: browser?  From the command line, I get the exact HTML I wanted.  My
: browsers (Netscape 4.51 and IE 5) only display the header information.
: Nothing from inside the foreach loop in sub printLinks is sent to the
: browser.

I'm going to go into pedantic mode and snipe at you for saying "from the 
browser."  Browsers do *not* run CGI scripts.  *Servers* do.  When you 
run a script from the command line, that script is running as user you.  
When you fire up a browser and access the URL corresponding to the CGI 
script, user you is running the *browser*, but user somebodyelse 
(whatever user the server runs as) is running your *script*.  User 
somebodyelse does *not* know where your current directory is.  It does 
not know about your login settings.  It does not have the same access 
rights as you.



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

Date: Fri, 25 Jun 1999 04:27:15 +0200
From: Kristian Elbo <Kelbo@rhk.dk>
Subject: DBI and ODBC (on NT-server)
Message-Id: <3772E903.5C9B921B@rhk.dk>

This is a multi-part message in MIME format.
--------------940AAF70816C0AB2661691D3
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I'm trying to use an Access-database for storage of some data, and I'm
trying to exstract these data using sql and ODBC under NT.
The following use of the DBI module in Perl5 works, with the 'official'
perl5-release, but the server on which I have to place the script uses
an interpreter from ActiveState based on perl5, and when I run the
script I get a strange error message that DBI is not a part of @INC ??.
meaning .. ?????

The relevant part of the script looks like this :

use DBI;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
#......
#......cutout
#......
$dbName = "DBI:ODBC:hardwork";
$dbUserName = "";
$dbPassword = "";


{    $dbh = DBI->connect($dbName,
                         $dbUserName,
                        $dbPassword);
    $dataObject = $dbh->prepare($sql);
    $dataObject->execute();
    @dbRows = $dataObject->
              fetchall_arrayref();

Can anybody see what the problem may be, or maybe somebody has an idea
on how it can be done ??

Thanks
Kristian@why.can't all.interpreters.be.compatible.hehe:-)

--------------940AAF70816C0AB2661691D3
Content-Type: text/x-vcard; charset=us-ascii;
 name="Kelbo.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Kristian Elbo
Content-Disposition: attachment;
 filename="Kelbo.vcf"

begin:vcard 
n:Elbo;Kristian
tel;cell:20 68 84 27
tel;home:+45 35392666 - 528
x-mozilla-html:TRUE
org:University of Copenhagen;August Krogh
adr:;;Jagtvej 120, room 528;Copenhagen;;2200 N;Denmark
version:2.1
email;internet:Kelbo@rhk.dk
title:Stud. Human Physiology
fn:Kristian Elbo
end:vcard

--------------940AAF70816C0AB2661691D3--



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

Date: Fri, 25 Jun 1999 03:53:22 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Dynamic Page Generation
Message-Id: <ebohlmanFDv6sy.ABp@netcom.com>

Laran Coates (lcoates@bu.edu) wrote:
: I'm writing a script to take fields from a form and populate and display
: another html page using those values.  I would ultimately like to have the
: script email the new document to an email address specified by the user.
: 
: Has anyone got any good ideas.
: 
: I know that this is basically the most common of all perl scripts but I'm
: new to the language and have been stuck now for a few days on this.
: 
: The matter is somewhat pressing so any and all help would be appreciated.  \

While very simple for an experienced Perl programmer, this is way too big 
a task for someone "new to the language."  If your time is limited, I'd 
really suggest you hire someone to write it for you.

In particular, if a script like this is buggy, it can accidentally
mailbomb people.  If this happens, most of the sites that received your
accidental duplicates, tripiclates, dodeciplicates, etc. will respond by
configuring their mail systems to refuse mail from your IP address.  If
you have virtual hosting, that means those systems will refuse mail from
*anyone* hosted on your provider.  This will make those other customers on
your provider very unhappy, which will in turn make your provider
extremely unhappy with you.  You will probably owe your provider money for
the cost of cleanup and lost business, and if you go to another provider,
you will have to explain to them that you were kicked off your previous
provider for e-mail spamming (which is what it was, even though you didn't
intend to do it).  You do not want things like this to happen. 

Anyone who writes such a script will need to put in safeguards to prevent 
third parties from using it as a mailbombing or spamming service.



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

Date: 24 Jun 1999 23:53:51 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Error in my CGI that a can't find!  Need help debugging!
Message-Id: <7kugef$q1t$5@fcnews.fc.hp.com>

Wayne Venables (wvenable_net@iname.com) wrote:
: But the script fails, I get no output!  It seems to me the script is
: probably failing at compile-time while importing a particular module.

So maybe you want to put your __DIE__ and __WARN__ handlers in a BEGIN
block, before any other 'use's? Or just

          use CGI::Carp qw(fatalsToBrowser);

and let somebody else's code do it.

: (Keep in mind, I have no access to the server whatsoever except to
: upload files!)

Are you a customer or slave to your webhoster? (Hint: are you paying
money, or do you remember a 3-month journey chained at the bottom of a
cargo ship?)

Andrew



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

Date: 25 Jun 1999 00:45:14 GMT
From: "Bob Bridges" <bbridges@seark.net>
Subject: Help a newbie!
Message-Id: <01bebea2$f19b0380$6264f5d0@bbridges.seark.net>

I'm a newbie Perl programmer and i'm looking for a couple of commands.  I
need a command to read a opened file and copy all of its text content into
a scalar variable.  I also need one to put the date (month day, year)
and/or time (hh-mm-ss, not the UNIX second counter) into a scalar variable.
 Please help me.  Thank you.



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

Date: Fri, 25 Jun 1999 02:27:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Help a newbie!
Message-Id: <GOBc3.197$MJ1.7266@nsw.nnrp.telstra.net>

In article <01bebea2$f19b0380$6264f5d0@bbridges.seark.net>,
	"Bob Bridges" <bbridges@seark.net> writes:
> I'm a newbie Perl programmer and i'm looking for a couple of commands.  I

You can find all the commands in the documentation. If you're a
beginner, you should buy one of the good books (see
http://www.perl.com for details)

> need a command to read a opened file and copy all of its text content into
> a scalar variable.  

# perldoc -f open
# perldoc -f close
# perldoc perlop
(look for the "I/O operators section)

FYI: perldoc is the tool shipped with perl to get easy access to the
documentation. The two pices of documentation used above are perlfunc
and perlop. Maybe you need to access them with man, or if you're on a
tool-poor box, you may have html files or something installed.

> I also need one to put the date (month day, year)
> and/or time (hh-mm-ss, not the UNIX second counter) into a scalar variable.
>  Please help me.  Thank you.

# perldoc -f localtime

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd.       | make up 3/4 of the population.
NSW, Australia                      | 


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

Date: Fri, 25 Jun 1999 01:07:03 +0100
From: "David Cooper" <david@medal.force9.net>
Subject: Re: Help with PPM
Message-Id: <9Nzc3.3001$BS6.2454@wards>

I get this problem from clean installs of ActiveState perl.

The fix suggested by David Cassell is at
http://www.activestate.com/PPM/
I believe. None of the fixes there worked for me, but maybe you'll have more
luck.

If you don't have any joy getting PPM to work, you could use the binary
modules from
http://www.activestate.com/packages/zips/

HTH
David


David Cassell <cassell@mail.cor.epa.gov> wrote in message
news:3771AC2E.287E3988@mail.cor.epa.gov...
> [courtesy cc sent to poster]
>
> pjd wrote:
> >
> > Whats the matter with this PPM ?
> > I just cant seem to get this right.
> > I have the latest version of perl from ActiveState installed.
> > Here is a sample session.
> >
> > [SNIP]
> > no element found at line 1, column 0, byte -1 at
> > C:/Perl/site/lib/XML/Parser.pm
> > line 153
>
> Hmm, it looks like you've munged XML::Parser.  Did you
> try to install it using ppm?  That's bad, because ppm
> uses XML::Parser to do the installs.  I believe there's
> a fix for this on the ActiveState site, although you'd
> think that they would just put a line in ppm to keep it
> from trying to install XML::Parser incorrectly...
>
> David
> --
> David Cassell, OAO                     cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician




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

Date: 25 Jun 1999 01:35:13 GMT
From: mist@yoyo.cc.monash.edu.au (Michael Stillwell)
Subject: Re: How can I read a whole file in one go ?
Message-Id: <slrn7n5n6g.dqo.mist@fangorn.cs.monash.edu.au>

Tom Christiansen <tchrist@mox.perl.com> wrote:

:     On very rare occasion, you may have an algorithm that demands
:     that the entire file be in memory at once as one scalar. The
:     simplest solution to that is:
:
:         $var = `cat $file`;

Is there any other language where the recommended way to read an
entire file into memory involves a shell command?  I find this
extraordinary---and more than a little inelegant.



Michael

-- 
 .. ABSOLUT .SIG. ..
 .. Michael Stillwell ..
 .. mist@yoyo.cc.monash.edu.au ..
 .. http://yoyo.cc.monash.edu.au/~mist/ ..


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

Date: Fri, 25 Jun 1999 02:57:20 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: How can I read a whole file in one go ?
Message-Id: <ebohlmanFDv47K.7Jw@netcom.com>

Michael Stillwell (mist@yoyo.cc.monash.edu.au) wrote:
: Tom Christiansen <tchrist@mox.perl.com> wrote:
: 
: :     On very rare occasion, you may have an algorithm that demands
: :     that the entire file be in memory at once as one scalar. The
: :     simplest solution to that is:
: :
: :         $var = `cat $file`;
: 
: Is there any other language where the recommended way to read an
: entire file into memory involves a shell command?  I find this
: extraordinary---and more than a little inelegant.

I think this is one place where Tom's anti-Microsoft sentiments, however 
justifiable, are warping his judgment.  As Kernighan and Plauger pointed 
out in _Software Tools_, a set of combinable tools is almost always 
better than a hundred-bladed Swiss Army knife, but at the same time (this 
comes up in the chapter on macro processing), the fact that you can do 
anything with a set of Turing machine-level primitives doesn't imply that 
they're the best way to get the job done.

Shelling out to cat to read a file is, IMHO, on the level of shelling out
to expr to evaluate a simple arithmetic expression.  Much of the reason
that Perl exists is that there are certain things that *can* be done in
shells using a set of distinct tools, but are tedious and error-prone, not
to mention inefficient, to do that way.  Some operations are so
fundamental that it makes sense to build them into a language rather than
externalize them.  Some operations are best performed at a granularity
finer than that of a process.  There's no way to objectively determine the
exact level of granularity, but it's possible to come up with good
approximations.  Microsoft's view that a Web browser should be an integral
component of an OS kernel is an extreme example of a granularity mistake
(in this case, one made deliberately);  calling cat or expr from Perl code
in preference to using Perl operations is an extreme example of a
granularity mistake in the other direction. 

A good example of appropriate granularity is Perl's sort() function.  
Sure, anything it can do can also be done by calling the Unix sort 
program, but in many cases that means writing lots of marshalling code.  
At the same time, there are cases (huge volumes of data, etc.) where 
shelling out to a purpose-built tool is the best approach, and the extra 
marshalling effort pays off.  The Perl approach of having a built-in 
sorting function, but keeping it simple and letting you use an external 
tool if you have rare-but-complicated needs, is a good compromise.  It 
would, IMHO, be a granularity mistake to try to extend Perl's sort() to 
handle sets of data too large to fit in virtual memory.  It would also be 
a granularity mistake to drop it altogether.

Integration level is not a dichotomy between having bloatware (like 
"Internet browsers") and a mathematically elegant super-minimal set of 
process-per-operation primitives.  The real solution is usually somewhere 
in between.



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

Date: 24 Jun 1999 21:45:41 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How can I read a whole file in one go ?
Message-Id: <3772fb65@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    mist@yoyo.cc.monash.edu.au (Michael Stillwell) writes:
:Is there any other language where the recommended way to read an
:entire file into memory involves a shell command?  

Yes: bash, sh, ash, bsh, csh, tcsh, ksh, and zsh--just to name a few. :-)
You'll have to check wish, er, tclsh, er, tcl on your own.

:I find this
:extraordinary---and more than a little inelegant.

Gosh, you certainly have an, um, interesting notion of inelegant.
Let's compare...

    $buff = `cat $path`;
    die "ENOKITTY: $path--bailing out" if $?;
    printf "$0: read %d bytes from $path\n", length($buff);

versus

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <sysexits.h>
    #include <errno.h>

    main(ac, av)
	char **av;
    {
	char       *path = av[1];
	int         fd;
	char       *buff;
	off_t       len, count, pos;
	struct stat sb;

	if (ac != 2) {
	    fprintf(stderr, "usage: %s filename\n", av[0]);
	    exit(EX_USAGE);
	} 

	if ((fd = open(path, O_RDONLY)) < 0) {
	    fprintf(stderr, "%s: cannot open %s: %s\n",
		    av[0], path, strerror(errno));
	    exit(EX_NOINPUT);
	} 

	if (fstat(fd, &sb) < 0) {
	    fprintf(stderr, "%s: cannot fstat %s on fd %d: %s\n",
		    av[0], path, fd, strerror(errno));
	    exit(EX_SOFTWARE);
	} 

	len = sb.st_size;

	if (len != 0 && (buff = malloc(len)) == NULL) {
	    fprintf(stderr, "%s: cannot allocate %ld bytes for %s: %s\n",
		    av[0], len, path, strerror(errno)); 
					/* XXX: %ld != off_t */
	    exit(EX_OSERR);
	} 

	for (pos = 0; pos < len; pos += count) { 
	    if ((count = read(fd, buff, sb.st_blksize)) < 0) {
		fprintf(stderr, "%s: read failed on %s at byte %ld: %s\n",
			av[0], path, pos, strerror(errno));
					/* XXX: %ld != off_t */
		exit(EX_IOERR);
	    } 
	    if (count == 0) {
		break;   		/* XXX: too early? */
	    } 
	} 

	printf("%s: just read %ld bytes from %s\n", av[0], pos, path);
					/* XXX: %ld != off_t */

	exit(EX_OK);
    } 

Now, which one did you say was more elegant? :-)

I think you just have a different measure of these things than I do.
Note that, as I essentially go on to say in the cited FAQ, I see
surpassingly scant justification for ever reading the whole file into
memory at once in the first place.  It's usually the sign of some
overzealous neophyte going after a mosquito with a howitzer.

--tom
-- 
"In any organisation, there will always be one person who knows what is going 
 on.  This person must be fired."
				- Colin J. Wynne


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

Date: Thu, 24 Jun 1999 23:12:21 -0400
From: glasser@iname.com (David Glasser)
Subject: Re: How can I use Perl variables in Javascript ?
Message-Id: <1dtxbfs.1mtqzwa5umw4gN@usol-209-186-16-69.uscom.com>

Bart Lateur <bart.lateur@skynet.be> wrote:

> Nina Mayor wrote:
> 
> >      <!-----------   $myvariable is not anderstood in this Javascript
> >--------------->
> >        java_variable = $myvariable;    <-- <-- <--
> 
> Of course it isn't. You have to fill in the value for that Perl
> variable, which, BTW, I think you do. Only, you have to make it look
> like a constant for Javascript. In other words: I *think* (my Javascript
> experience is extremely limited) that it might work as is for numbers,
> but for text strings, you'll have to provide some quotes.
> 
>         java_variable = "$myvariable";
> 
> So that the HTML turns out like
> 
>       java_variable = "Hello, world!";

This won't work either, because Nina was using <<EndOfHTML, which won't
interpret the variable anyway.

You could make that into <<"EndOfHTML", but then you'd have to be
careful of interpolation in a host of other places.  If you're only
using interpolation in a few places, a good way to go would be to end
heredoc the line before the variable needs to be interpolated, print
that line using <<"EndOfHTML", and then go back to <<EndOfHTML.

Or you could do something entirely different.

-- 
David Glasser: glasser@iname.com       | http://www.uscom.com/~glasser/
DGlasser@ifMUD:orange.res.cmu.edu 4001 | raif FAQ http://come.to/raiffaq


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

Date: Fri, 25 Jun 1999 03:09:25 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Process id for fork()ed process
Message-Id: <FpCc3.215$MJ1.8705@nsw.nnrp.telstra.net>

In article <19990624152852.22212.00000400@ng-cg1.aol.com>,
	jamesgpage@aol.com (JamesGPage) writes:
> I can get the process id of the perl process in the $$ variable.
> I can code: $child = fork()  which returns 0 if te executing process is the
> parent and a process id if the thread is the forked child. However, within the
> child $$ still refers to the perl top level process.  Is there a way to
> determine the process id of the child from within the child without passing
> $child around?
> 

Let me insert some comments:

> #!/usr/local/bin/perl

You should use -w, and use strict;
You should set a signal handler for $SIG{CHLD}

> 
> print ">>1 parent=$$<<\n";
> $child = fork();

You should check that the fork succeeded.

> if($child)
> {

    # I'm the parent

>   my $rc = thread("a", "b", "c");

The 'child' mentions in the next string are a bit confusing, since
this is the parent. Maybe you have your logic wrong?

>   print ">>child=$child rc=$rc \n";

You should wait for the child, unless you want zombies

> }
> else
> {

    # I'm the child

>   print ">>2 ($child)<<\n";
>   wait;
> }

# Both will do this

> print ">>3 ($child)<<\n";
> exit;
> 

# This sub will only be called by the parent, NOT by the child

> sub thread
> {
>   my @parms = @_;
>   my $x = @parms;
>   print "Thread: " . $$ . " ($x) " . join('*', @parms) . "\n";
>   return ($x);
> }
__END__
>>1 parent=27365<<
>>2 (0)<<
>>3 (0)<<
Thread: 27365 (3) a*b*c
>>child=27366 rc=3 
>>3 (27366)<<

lines 1, 4, 5 and 6 are from the parent, lines 2 and 3 from the child.
Nowhere in the above code do you make the child print out its pid ($$).

Try the following code, slightly simpler, and slightly more robust:

$SIG{CHLD} = sub{ wait };
defined (my $pid = fork) or die "Fork failed: $!";

if ($pid)
{
	print "Parent: $$ -> $pid\n";
	waitpid($pid, 0);
}
else
{
	print "Child : $$ <- $pid\n";
}
__END__
Child : 27494 <- 0
Parent: 27493 -> 27494

Martien
-- 
Martien Verbruggen                  | My friend has a baby. I'm writing down
Interactive Media Division          | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd.       | I can ask him what he meant - Steven
NSW, Australia                      | Wright


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

Date: 25 Jun 1999 03:07:31 GMT
From: "newart@newart.com  " <newart@shell11.ba.best.com>
Subject: Programming job
Message-Id: <3772f273$0$210@nntp1.ba.best.com>

Looking for some to write a couple of programs in Perl for processing a large number of test files.

Basically we have a directory of files created by a discussion forum script, and we need a perl 
program to go through a directory and to add a header to each file (some text at the start of the file)
and possibly some at the end, and then copy the file into a specified directory.

If you are interested please email : adolf@tio.com

and let me know whea your hourly rate is. If you email me  - I can provide more specific detail.

Thanks
 .
`


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

Date: Fri, 25 Jun 1999 03:13:41 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Read a file starting a a certain point in the middle
Message-Id: <ebohlmanFDv4yt.8C7@netcom.com>

Mesarchm (mesarchm@aol.com) wrote:
: I currently have a perl scripts that reads IIS logs and grabs specific
: elements.  However, this script will run against an entire directory of log
: files.  Because of this it needs to know if it already read a file, and if it
: did pickup where it left off.  I can not make any changes to the logs.  Some of
: these files are very large.  Ranging from 100MB to GB's.  Because of that I
: need it to not read the file from the begging, but pick up from that
: predetermined line.

Sounds like you want to use a persistent hash (i.e. a dbm file) to store 
the names of the files you've read and the offsets (as given by tell()) 
of where you left off, so you can then use seek() to resume reading.



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

Date: 25 Jun 1999 01:34:48 GMT
From: Nazi Triceratops <revjack@radix.net>
Subject: Re: Regex question (i think)
Message-Id: <7kumbo$opg$2@news1.Radix.Net>
Keywords: Hexapodia as the key insight

Gene Dolgin explains it all:

:How can i use regex to extract an email from a $string?

There are way too many permutations associated with e-mail address formats
for a manageable regex to catch them all. You might want to look at
RFC822: 

  http://www.faqs.org/rfcs/rfc822.html

to get an idea of the possibilities.

If you just want what's on either side of the @ sign, that's a different
story.



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

Date: Thu, 24 Jun 1999 20:31:25 -0500
From: Sunitha <nsunitha@cse.unl.edu>
Subject: Regular Expression - Doubt
Message-Id: <3772DBEC.F64C178C@cse.unl.edu>

Hi:

Thanks for the help on my hash-table question. I have another problem
dealing with
Regular Expressions.

sub Validate_Sentence{
    local ($string) = @_;
    local($ch);
    while (/&#([^;]*);/g) {
           $ch=sprintf("%c", $1);
           $string =~ s/&#[^;]*;/$ch/;
       }
$string;}

For eg:  if my line is : o[.sub]2[/]-electrode
it should return me $string = "sub electrode"

Could you please correct me?

Thanks so much
Sunitha



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

Date: Thu, 24 Jun 1999 19:18:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regular Expression - Doubt
Message-Id: <MPG.11dc86d291ae002f989c40@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <3772DBEC.F64C178C@cse.unl.edu> on Thu, 24 Jun 1999 20:31:25 
-0500, Sunitha <nsunitha@cse.unl.edu> says...
 ...
> sub Validate_Sentence{

This is a rather weird name for the functionality you are after.

>     local ($string) = @_;
>     local($ch);

These are lexical variables in the bubroutine, so should be declared 
with 'my', not 'local'.

>     while (/&#([^;]*);/g) {

This regex matches against $_, but you want it to match against string.

>            $ch=sprintf("%c", $1);
>            $string =~ s/&#[^;]*;/$ch/;
>        }

The loop is wonky.  What you want can all be done in one s///:

       $string =~ s/&#(\d+);/sprintf '%c', $1/eg;
                       ^^^
Not [^;]* because you want to have a string of digits here for $1.

I would use 'chr $1' instead of sprintf.

> $string;}
> 
> For eg:  if my line is : o[.sub]2[/]-electrode
> it should return me $string = "sub electrode"

I have no idea what the above means.  Sorry.


sub Converted_String {
    my $string = shift;
    $string =~ s/&#(\d+);/chr $1/eg;
    $string
}

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 25 Jun 1999 01:23:57 GMT
From: Kazuma <kazuma@my-deja.com>
Subject: Re: should be how to remove ^M from middle of variable?
Message-Id: <7kuln3$mj4$1@nnrp1.deja.com>


> Okay, using vi on the output shows ^M in the middle of my variable,
> coming from the browser.  Can someone please explain what's going
> on?  Perhaps my URL unencoding isn't right?  I'm using:
> $val =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

To be sure, I would do:

$val =~ s/\r//g;       # remove ^M, the var is now 'unix like'
$val =~ s/\n/ /g;      # subsitute newline with space

this because if the variable is generated by a 'dos' browser, it has
\r\n, while if is generated by a unix system it has only \n.

$val =~ s/\r\n/ /g;    # will only work with 'dos' browsers
$val =~ s/\n/ /g;      # will only work with 'unix' browsers


   Best Regards,
      Kazuma

--
Cos'e' il genio: fantasia, intuizione,
   colpo d'occhio e velocita' d'esecuzione...


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 25 Jun 1999 02:39:12 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: Writing to a terminal from a perl script
Message-Id: <kZBc3.1329$8F2.43858@news3.ispnews.com>

In article <7kt41t$33b$1@nnrp1.deja.com>, Ronny  <ronald_f@my-deja.com> wrote:
>In article
><Pine.BSF.4.05.9906231451060.13773-100000@lister.acm.wwu.edu>,
>  Shane Fisher <fishers@lister.acm.wwu.edu> wrote:
>> So, I'm wondering if there is an
>> environment variable that the perl script can use to "find" the
>terminal
>> to write to.
>
>I don't see how you would decide automatically which terminal to chose.
>Say you running an X session, and you have 4 xterm windows open - which
>one should receive your mail notice?

The traditional answer is "the one with the least idle time". You find this
by stat'ing them all and taking the one whose st_atime is most recent.
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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