[8927] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2545 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 9 00:08:19 1998

Date: Fri, 8 May 98 21:00:29 -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           Fri, 8 May 1998     Volume: 8 Number: 2545

Today's topics:
    Re: 'die' outside eval returns 0 (Charles DeRykus)
    Re: Comparing references (Mark-Jason Dominus)
    Re: COUNTING DAYS UNTIL 2000 <upsetter@shore.net>
    Re: Expanding arrays in strings (TomH)
        grep question from newbie <vhhawk@worldnet.att.net>
        GuestBookSource <sirius@southern.co.nz>
    Re: GuestBookSource (brian d foy)
    Re: GuestBookSource <zenin@archive.rhps.org>
    Re: how to create name for temporary file <jhoglund@mirage.skypoint.net>
    Re: How to make a "Please wait" page during script proc (David Adler)
    Re: Logic of split() ? <jdf@pobox.com>
    Re: MEmeory problem IN CGI bidyut@yahoo.com
    Re: MODULE MANIA STRIKES (Was Re: What does this do?) (Michael J Gebis)
    Re: MODULE MANIA STRIKES (Was Re: What does this do?) (Scratchie)
    Re: MODULE MANIA STRIKES (Was Re: What does this do?) <sowmaster@juicepigs.com>
    Re: Newbie troubles <sowmaster@juicepigs.com>
    Re: Newbie troubles <btate@primary.net>
    Re: Passing long command line to shell, best way? <vallon@pearl.fi.bear.com>
    Re: perl  -e filenamewith_regex datafiles question <vallon@pearl.fi.bear.com>
    Re: Perl Conference (David Adler)
    Re: PErl Functions (Craig Berry)
    Re: PErl Functions (Kevin Reid)
    Re: Perl in background <jsd@gamespot.com>
    Re: Perl/Wall lingo question (David Adler)
    Re: Perl/Wall lingo question (brian d foy)
        Win32::ODBC; NEW doesn't work <dmitri-b@usa.net>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 9 May 1998 00:08:22 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: 'die' outside eval returns 0
Message-Id: <Esnxpy.BGB@news.boeing.com>

In article <35522E78.D130A9D1@world.northgrum.com>,
James M. Stern <jstern@world.northgrum.com> wrote:
>This program:
>
><snip>
>#!/usr/local/bin/perl -w
>use strict;
>print system('perl -we \'$! = 0; $? = 1 << 8; die "failed"'), "\n";
></snip>
>
>prints
>
><snip>
>failed at -e line 1.
>0
></snip>
>
>The last line is the exit code.  However, my (mis?)reading of the
>perldoc entry for 'die' says that 'die' exits as follows, in effect:
>
>    exit($! || ($? >> 8) || 255);
>
>Thus the 'die' exit code can never be 0.
>
>My configuration is:
>
>% perl -v
>
>This is perl, version 5.004_04 built for aix
>
>% oslevel
>4.1.4.0
>

Check out wait(2). The WEXITSTATUS(status) is defined as
the low-order 8 bits of the argument that the child passed
to exit or _exit.

So, modifying 1<<8 to 1<<7  works as you'd expect:

print system('perl -we \'$! = 0; $? = 1 << 7; die "failed"'), "\n";
failed at -e line 1.
32768

HTH,
--
Charles DeRykus


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

Date: 8 May 1998 23:15:51 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Comparing references
Message-Id: <6j0hp7$dca$1@monet.op.net>
Keywords: exaggerate glare IR malnutrition


In article <6j00io$8o5@netline.jpl.nasa.gov>,
Peter Scott <psf@euclid.jpl.nasa.gov> wrote:
>I want to check whether two references refer to the same thingy,
>and a quick test appeared to show that I could use either == or eq:

Yup, and all your guesses are right:

>Would I be right in saying that testing with
>eq compares the stringified references ("ARRAY (0xabcdef)")?  

Bingo.

It's funny, but this extention to references makes perl's `eq' almost
identical to lisp's `eq', which I assume wasn't a real high design
priority.



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

Date: 8 May 1998 23:05:16 GMT
From: Art Cohen <upsetter@shore.net>
Subject: Re: COUNTING DAYS UNTIL 2000
Message-Id: <6j033c$od5@fridge.shore.net>

Once again, someone who could bother to inform me that he was emailing a
cc of a posting, not a personal email. Anyway...

Bob Trieger <sowmaster@juicepigs.com> wrote:
: Art Cohen wrote:
:> 
:> Well, I can take a simple script like this:
:> 
:>         #!/usr/bin/perl
:>         use Date::Manip;
:>         print "Hello World\n";
:> 
:> and time the load time with my WRISTWATCH (approx 2.5 seconds). That's not
:> anything I would ever want to put in a cgi script.

: Benchmark: timing 100000 iterations of importsub, module, no_module...
:  importsub: 11 secs (11.75 usr  0.00 sys = 11.75 cpu)
:     module: 12 secs (11.59 usr  0.00 sys = 11.59 cpu)
:  no_module: 12 secs (11.68 usr  0.00 sys = 11.68 cpu)

[code snipped]

Well, I have to say that I don't know enough about Benchmark or about how
Perl imports modules to comment on this. I did a Benchmark of "use
Date::Manip" and it said that it took 0.00 seconds, so I have to take that
with a grain of salt. 

Also, it looked like you were importing Date::DateCalc and not
Date::Manip.

At any rate, I wrote two simple perl scripts. One (helloDate.pl) looks
like this:

	#!/usr/bin/perl
	use Date::Manip;
	print "Hello World\n";

The other (hello.pl) looks like this:

	#!/usr/bin/perl
	#use Date::Manip;
	print "Hello World\n";

I then wrote a shell script that looks like this (not very pretty but I
never claimed to be a shell programmer):

#!/bin/sh

date
helloDate.pl
helloDate.pl
helloDate.pl
helloDate.pl
helloDate.pl
helloDate.pl
helloDate.pl
helloDate.pl
helloDate.pl
helloDate.pl
date
hello.pl
hello.pl
hello.pl
hello.pl
hello.pl
hello.pl
hello.pl
hello.pl
hello.pl
hello.pl
date

The results of which looked something like this:

Fri May  8 19:01:04 EDT 1998
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Fri May  8 19:01:28 EDT 1998
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Fri May  8 19:01:29 EDT 1998

~24 seconds vs. ~1 second. I won't be using Date::Manip in any cgi scripts
if I can help it.

--Art

PS: I'm also tickled that I timed Date::Manip by hand as taking 2 1/2
seconds to load, which appears to be fairly accurate.

National Ska/Reggae Calendar: www.ziplink.net/~upsetter/ska/calendar.html
        Boston Ska Home Page: www.ziplink.net/~upsetter/ska/index.html



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

Date: Thu, 07 May 1998 19:34:02 GMT
From: beans@bedford.net (TomH)
Subject: Re: Expanding arrays in strings
Message-Id: <35520c37.922261@news.bedford.net>

The problem is you are using single quotes instead of double:

##############
$\ = "\n";

$bar = 1;
$foo[1] = "Hello";

$text = 'this has a $foo[$bar] in it';
print $text;

$text = "this has a $foo[$bar] in it also";
print $text;


On Fri, 08 May 1998 18:55:42 GMT, nikitins@infoservriga.lv wrote:

>PERL FAQ describes the situation when expanding single variables.
>
>    $text = 'this has a $foo in it and a $bar';
>    $text =~ s/\$(\w+)/${$1}/g;
>
>I need to have
>
>    $text = 'this has a $foo[$bar] in it';
>
 ...


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

Date: Fri, 8 May 1998 22:29:45 -0500
From: "Victor Hawk" <vhhawk@worldnet.att.net>
Subject: grep question from newbie
Message-Id: <6j0i8b$qae@bgtnsc01.worldnet.att.net>

Had an accidental brush with perl a few days ago. Being an old
nawk-n-grep'r - but NOT a programmer by trade - I was sucked in pretty fast
and have spent a little time trying to do the following task.

I have an 11,000+ element list of patterns in file1. I have a 50,000+ list
of records in file2. I am trying to find any element in file1 in any field
in file2. If I find it, I want to pass the entire file2 record (variable
length) out to file3. If I don't find it, pass it to file4.

I can do this easy with grep, but it is so damn slow. And, due to I guess
machine restrictions I had to split my file1 into a bunch of 400 record
files.

grep -f file1 file2 > file3

How can this be done in perl?

Thanks,
Victor Hawk




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

Date: Sat, 09 May 1998 12:10:04 +1200
From: Dennis <sirius@southern.co.nz>
Subject: GuestBookSource
Message-Id: <35539EDC.3F41@southern.co.nz>

I have just started Perl/CGI programming. Can anyone tell me where I can
download the source code of a guest book programme so I can see how it
is put together.
sirius@southern.co.nz
 Thanks


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

Date: Fri, 08 May 1998 21:04:21 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: GuestBookSource
Message-Id: <comdog-ya02408000R0805982104210001@news.panix.com>
Keywords: from just another new york perl hacker

In article <35539EDC.3F41@southern.co.nz>, sirius@southern.co.nz posted:

>I have just started Perl/CGI programming. Can anyone tell me where I can
>download the source code of a guest book programme so I can see how it
>is put together.

this may sound unhelpful, but it's not:

if you want to create a better mousetrap - don't basae it on the 
old ones.  figure out what you want yours to do and save the coding
for later.  this is especially true in this case since you are going to
find source that sucks in lots of ways.  you wouldn't want to pick up
bad habits too early. :)

other than that, search for "guestbook" in some search engine.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
haven't seen a non-sucky guestbook yet.


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

Date: 9 May 1998 02:06:49 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: GuestBookSource
Message-Id: <894680062.381479@thrush.omix.com>

brian d foy <comdog@computerdog.com> wrote:
	>snip<
: if you want to create a better mousetrap - don't basae it on the 
: old ones.

	Agreed.  Most all of the current guest books around are really
	bad kluges with tons of security holes and generally bad programming
	practices.  Build it from scratch, because you'd have a hard time
	writinge more bugs then most of the ones currently available.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: 9 May 1998 00:07:50 GMT
From: Jamie Hoglund <jhoglund@mirage.skypoint.net>
Subject: Re: how to create name for temporary file
Message-Id: <6j06om$s0b$1@shadow.skypoint.net>

- <root.noharvest.\@not_even\here.com> wrote:
: Jonathan Feinberg <jdf@pobox.com> Said this:

:>Jeff Trawick <trawick@ibm.net> writes:
:>
:>> Are there any functions in the standard Perl 5.004 
:>> distribution to create names for temporary files
:>> (like tmpnam() in C Standard Library)?
:>
:>A quick search through the docs reveals:  POSIX::tmpnam()
:>

: This sounds unnecessary.  This is the reason Microsoft succeeds in the
: computer business - people are indecisive and can't make decisions on
: their own, they need someone (or something) else to do it for them.

: Just use $$ or some variant.  Make up your own temporary file, it's
: not that hard.  You don't need someone else to do it for you.

: Here........

: srand($$^TIME);
: $num = int(rand(1000);
: $tempfile = $num * $$;
: $tempfile .= ".tmp";

: Now you have a nice temporary file.  No loading of some huge module
: just to do something you were afraid to do on your own.

: If you like things neat and orderly, substr $tempfile before appending
: the .tmp onto it, say at 8 characters for you dos-nuts.


There are some problems with symbolic links and other conditions. (I've
never tried them, only read about them, they seem logical. Here's an
example:

ln -s /etc/passwd /tmp/random.1234

If you know root will be running a program that creates temporary files
that begin with random.xxx it's possible to have them overwrite files.
(especially if you know the process ID of the command they are running,
and that the temp file will be: string.<process_id>


I usually either:

1.) Don't worry about it.

    It's pretty unlikely to happen, unless someone is really bored. :-)

2.) Run a loop that checks for a file:

Assign a variable 1,

while /tmp/base.1234.variable exists I'll increment that variable

Then, immediately create that file. (so someone can't create a symbolic
link) I think there's a race condition here, but exploiting it seems very
unlikely.

It's probably less then optimal, and in most cases it's probably
not something to worry about, but temp files do have some security
problems in multi-user environments.  (I don't like loading modules for
things like that either, so I go for a compromise)

Jamie


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

Date: 8 May 1998 23:53:49 GMT
From: dha@panix.com (David Adler)
Subject: Re: How to make a "Please wait" page during script processing?
Message-Id: <6j05ud$hh1@news1.panix.com>

On Thu, 07 May 1998 16:41:20 -0400, Ala Qumsieh <aqumsieh@matrox.com> wrote:
>Am I the only person that finds Randal's .sig confusing ?!?!
>(not to mention amusing!)

Well, I don't know about the sig, but it certainly sounds like an
accurate description of Randal.  :-0

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"We're dumber than squirrels.  We hear voices and do what they
command.  I have broccoli in my socks." - Dilbert's boss


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

Date: 08 May 1998 21:42:09 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: "Jeremy Goldberg" <jgoldberg@pipex.com>
Subject: Re: Logic of split() ?
Message-Id: <3eekupvi.fsf@mailhost.panix.com>

"Jeremy Goldberg" <jgoldberg@dial-but-dont-spam.pipex.com> writes:

> This is far from vital information, but I'm curious about it now, and I
> couldn't see much of info in the perl docs:

You must have missed the documentation for split:

   C:\> perldoc -f split

> Why does:
> 
>  ( $time, $dummy, $day ) = split( /\s+(GMT on)?\s?/, $str );
> 
> give the same as:
> 
>  ( $time, $dummy, $day ) = $str =~ /(\S*)\s+(GMT on)?\s?(.*)/;

Use the non-capturing parens (?: foo ) as documented in perlre.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Sat, 09 May 1998 00:01:11 GMT
From: bidyut@yahoo.com
Subject: Re: MEmeory problem IN CGI
Message-Id: <6j06c7$b3e$1@nnrp1.dejanews.com>

Thanks Tom,
the problem was not there. the proble was with Perl accessing SQl server. So
when there was a null value, the SQL statement was failing making the perl to
hang.. so i fixed that problem now.
Anyway thanks for looking into my code..
regards
bidyut


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 8 May 1998 23:24:22 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: MODULE MANIA STRIKES (Was Re: What does this do?)
Message-Id: <6j0476$bqg@mozo.cc.purdue.edu>

Art Cohen <upsetter@shore.net> writes:

}Of course, you might be justified in pointing out that there is plenty of
}documentation available to explain how the read function works, and that
}it's a little lazy and annoying to post a question like that to this ng
}without consulting said documentation first, but to proclaim -- simply on
}the basis of one line of code -- that he *should* be using CGI.pm (simply
}because it exists) is kind of idiotic. 

I could agree with what you are saying for some
other modules, but...

We're talking about CGI.pm, which has few (does it even have any?)
dependencies, has awesome documentation, is easy to use, does 
all the common-but-tricky things correctly, and is a hell of a lot
easier to maintain that anything else.  CGI.pm makes life easier
for everyone.

So in other words, he really *should* be using CGI.pm.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Fri, 08 May 1998 20:54:10 -0400
From: upsetter@ziplink.net (Scratchie)
Subject: Re: MODULE MANIA STRIKES (Was Re: What does this do?)
Message-Id: <upsetter-0805982054100001@mfs-01-17.port.shore.net>

In article <6j0476$bqg@mozo.cc.purdue.edu>, gebis@albrecht.ecn.purdue.edu
(Michael J Gebis) wrote:

: We're talking about CGI.pm, which has few (does it even have any?)
: dependencies, has awesome documentation, is easy to use, does 
: all the common-but-tricky things correctly, and is a hell of a lot
: easier to maintain that anything else.  CGI.pm makes life easier
: for everyone.

I found a bug in it this week, and I still haven't found any bugs in
cgi-lib.pl that keep me from using it.

--Art

---------------------------------------------------------------------
                     National Ska & Reggae Calendar
            http://www.ziplink.net/~upsetter/ska/calendar.html
---------------------------------------------------------------------


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

Date: Fri, 08 May 1998 23:13:53 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: Art Cohen <upsetter@shore.net>
Subject: Re: MODULE MANIA STRIKES (Was Re: What does this do?)
Message-Id: <3553C9F1.5531@juicepigs.com>

[mailed & posted]

Art Cohen wrote:
> 
> Greg Bacon <gbacon@cs.uah.edu> wrote:
> : :               read(STDIN, $buf, $ENV{'CONTENT_SIZE'});
> 
> : It fails to use the CGI.pm module!  Get thee to the CPAN:
> 
> :     <URL:http://www.perl.com/CPAN/modules/by-module/CGI/>
> 
> Caution: rant ahead!
> 
> This is a perfect example of module-mania run amok. There are plenty of
> perfectly good reasons why someone might not want to use CGI.pm, yet the
> immediate knee-jerk reaction is "Use CGI.pm". If you don't want to tell
> him the answer, don't, but don't imply that using CGI.pm will make his
> life easier.
> 
> Maybe he's a beginning perl programmer, and maybe he doesn't know anything
> about modules, references or objects (believe it or not, it's possible to
> write working perl code for many different tasks without knowledge of any
> of these things). If he needs to write a cgi script, it makes infinitely
> more sense to learn cgi (the interface) on its own, based on a simple
> knowledge of perl, and then later -- iff he has complicated CGI
> programming needs -- learn enough about modules, references and objects to
> use CGI.pm.
> 
> Or maybe -- imagine this -- he's been using CGI.pm for a long time, but
> now he needs to write a script for a host that's running Perl 4. Not an
> ideal situation to be in by any means, but hardly beyond the realm of
> possibility.
> 
> Maybe he's just reading the source code of cgi-lib.pl and trying to
> analyze it. I've been writing perl for over two years and I've never used
> "read" ever, except in cgi-lib.pl, so it's not unreasonable that he's
> never seen this function before.
> 
> Of course, you might be justified in pointing out that there is plenty of
> documentation available to explain how the read function works, and that
> it's a little lazy and annoying to post a question like that to this ng
> without consulting said documentation first, but to proclaim -- simply on
> the basis of one line of code -- that he *should* be using CGI.pm (simply
> because it exists) is kind of idiotic.
> 
> End of rant.
> 

I think you miss the point here. the original poster was obvious
ignorant as to how to read the documentation for the read function or
just too lazy. By using CGI.pm he will only have to read one document
instead of the documentation for all the other functions used after the
read.


-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


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

Date: Fri, 08 May 1998 23:22:02 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: Jeff Giacomi <jwg@csulb.edu>
Subject: Re: Newbie troubles
Message-Id: <3553CBDA.4313@juicepigs.com>

Jeff Giacomi wrote:
> 
> Help.  I can get hello.pl to run from the command line but when I try to
> access through http://servername/scripts/hello.pl I get HTTP/1.0 404
> Object Not Found. Any ideas?  Thanks in advance.

If the script works from the command line your problem is not with perl.
Try the cgi or server newsgropups. You will get a lot more help there.

news:comp.infosystems.www.authoring.cgi
news:comp.infosystems.servers.ms-windows


HTH
-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


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

Date: Fri, 8 May 1998 22:33:39 -0500
From: "Bob Tate" <btate@primary.net>
Subject: Re: Newbie troubles
Message-Id: <3553ceb6.0@news.primary.net>

Jeff,

does your "hello.pl" code have this line in it?

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

Bob

Jeff Giacomi wrote in message <35538DC4.92412929@csulb.edu>...
>Help.  I can get hello.pl to run from the command line but when I try to
>access through http://servername/scripts/hello.pl I get HTTP/1.0 404
>Object Not Found. Any ideas?  Thanks in advance.
>
>-jeff
>



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

Date: 08 May 1998 21:53:22 -0400
From: Justin Vallon <vallon@pearl.fi.bear.com>
Subject: Re: Passing long command line to shell, best way?
Message-Id: <x6ehg30mcq5.fsf@pearl.fi.bear.com>

sherman@unx.sas.com (Chris Sherman) writes:

> Suppose I want to pass a 500 character command to the command line.
 ...
> Of course, the following doesn't work:
> 
>    @output = `cmd blah blah\
>      more blah blah\
>      even more blah`; 

It seems to be interpreted as newlines:

local $x = `date \
echo testing \
date`;

print "x '$x'\n";

Gives:

x 'Fri May  8 21:43:35 EDT 1998
testing
Fri May  8 21:43:35 EDT 1998
'

> or how about:
> 
>    $cmd = "cmd blah blah " .
>           "more blah blah " .
>           "even more blah ";
> 
>    @output = `$cmd`;
> 
> Ugly, but I guess it works.  Is there a better way?

It works.

> If I do something like this:
> 
> $cmd = <<EndOfCmd;
>   cmd1
>   cmd2
>   cmd3
> EndOfCmd
> @output = `$cmd`;
> 
> This doesn't work right.  All the commands appear on one line with '^J's 
> separating them when you list the processes with `ps` (in Unix).

That works for me.  The ^J is unix's newline (\n).  The commands ran 
correctly for me:

local $cmd = <<EOF;
date
echo testing
date
EOF

local $x = `$cmd`;

print "x '$x'\n";

Gives:

x 'Fri May  8 21:45:43 EDT 1998
testing
Fri May  8 21:45:43 EDT 1998
'

> I suppose I could open /bin/sh and pipe the commands to it, but how do I 
> format the commands to be feed into the pipe?  Is there a best way for
> doing this that is easy to read and not that messy?

You could use open2 or open3.  open2(OUT, IN, "/bin/sh").  Then, write to OUT
a 'shell script', which is $cmd in the previous example.

However, open2+open3 are tricky.  You'll need to use select+sysread to make 
sure that you don't deadlock (parent blocks while feeding commands while child
blocks while producing output that won't be read by the parent since it is 
waiting to write all the commands, which won't be read since the child is 
waiting for the parent to...).

/bin/sh + open2 can be fun to write.

The `$cmd` will basically run `/bin/sh -c '$cmd'`.  This will pass only three
arguments to /bin/sh, which is probably ok, no matter the size of $cmd.  So, 
`$cmd` is probably sufficient and the simplest to understand+use.

Basically, though, the $cmd should be simple to build.  Build $cmds[k] 
where each command is terminated with "\n".  Then 
$cmd = join '', @cmds.  Then `$cmd`.

-- 
-Justin
vallon@bear.com


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

Date: 08 May 1998 21:35:13 -0400
From: Justin Vallon <vallon@pearl.fi.bear.com>
Subject: Re: perl  -e filenamewith_regex datafiles question
Message-Id: <x6eiungmdke.fsf@pearl.fi.bear.com>

Maybe you mean:

    perl -pi.bak regex_file.pl datafile(s)

 ...making the regex_file.pl the body of the program.


Tom Phoenix <rootbeer@teleport.com> writes:

> On Thu, 30 Apr 1998, Miten S Mehta wrote:
> 
> > I have put a bunch of regex in a file to operate on input file and this
> > does not work.
> > 
> > perl -pi.bak -e regex_file.pl datafile
> 
> You seem to be mistaken about what those command line options do. See
> perlrun. Hope this helps!


-- 
-Justin
vallon@bear.com


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

Date: 9 May 1998 00:37:56 GMT
From: dha@panix.com (David Adler)
Subject: Re: Perl Conference
Message-Id: <6j08h4$hh1@news1.panix.com>

On Mon, 04 May 1998 22:30:45 -0400, brian d foy <comdog@computerdog.com> wrote:
>In article <354E2F54.B57F2813@tribune.com>, wsanchez@tribune.com posted:
>
>>Can someone provide me with an ~ cost of attending the Perl Conference
>>last year.
>
>do you plan on the Buying-Randal-Drinks package or the Alone-In-My-Room
>package?  one costs significantly more...

Oh?  I thought the B-R-D package was the only one they were offering
this year.  Oh, why is O'Reilly always confusing me like that? :-)

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
All hail El Cabeza Del Oro!


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

Date: 8 May 1998 22:54:50 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: PErl Functions
Message-Id: <6j02fq$lg5$1@marina.cinenet.net>

Kenner Estes (kenner@xnet.com) wrote:
: What is obtuse and what are the arguments to it?

That was acute remark.

---------------------------------------------------------------------
   |   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: Fri, 8 May 1998 22:07:11 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: PErl Functions
Message-Id: <1d8qchm.q6b3o4l0aqgsN@slip-32-100-246-119.ny.us.ibm.net>

Kenner Estes <kenner@xnet.com> wrote:

> What is obtuse and what are the arguments to it?

obtuse [-p[erson] name] [-a[bout] object] details

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Fri, 08 May 1998 18:25:51 -0700
From: Jon Drukman <jsd@gamespot.com>
Subject: Re: Perl in background
Message-Id: <3553B09F.F7AE8059@gamespot.com>

Carton Lao wrote:
> 
> Here is a bit of my experience with system("program &"):
> 
> system and backquotes seems to behave differently, but I can't find anything in
> the camel book that discuss the difference.
> 
> My take of system is that: that kind of syntax is actually wrong, the code
> should be written as system( "program", "&" ).  perl seems to handle the
> execution of the 'program' itself, and passing all those arguments to the
> program.  That's why the '&' has no effect, and in fact will probably cause your
> program to puke, if your program is not expecting an '&'.
> 
> perl handles backquotes ie. `program &` differently.  It seems to pass the whole
> string to a spawned off 'shell' to handle the parsing and execution.  Since & in
> a 'shell' usually means put it into background, that will work.
> 
> In short, I still haven't found a way to put system initiated program to
> background properly, maybe perl just can't do it.  Use `` instead.

don't use `` just to get this behavior.

first, see "How do I start a process in the background?" in perlfaq8.

now, allow me to amplify a bit:

the problem is you don't understand what is happening behind the scenes
with system.  system is really a combination of two unix system calls:
fork and exec.  fork creates a new process -- an identical copy of your
current one, in fact.  exec starts up a new program, destroying your
current process image.  so you basically clone your process, then
destroy it with a new executable.  meanwhile the first process (which is
still under perl control) waits for the other one to finish before
continuing.  it doesn't have to - that's just the way perl implements it
(it uses a third system call called "wait" to wait for the forked
process.)

in order to run stuff in the background, you need to take control of the
fork, exec, and wait stages by yourself manually.  there are many
examples of how to do this in the perlipc manpage, and also in perlfunc
under (surprise) "fork".



-- 
Jon Drukman                                            jsd@gamespot.com
-----------------------------------------------------------------------
Plan: Eat right, exercise regularly, die anyway.


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

Date: 9 May 1998 00:28:09 GMT
From: dha@panix.com (David Adler)
Subject: Re: Perl/Wall lingo question
Message-Id: <6j07up$hh1@news1.panix.com>

On Wed, 06 May 1998 23:58:56 -0400, brian d foy <comdog@computerdog.com> wrote:
>after my physics degree, my advisor told me it was time for religion :)

Ah.  So *that's* why you turned to perl. :-)

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"We're dumber than squirrels.  We hear voices and do what they
command.  I have broccoli in my socks." - Dilbert's boss


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

Date: Fri, 08 May 1998 20:58:37 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl/Wall lingo question
Message-Id: <comdog-ya02408000R0805982058370001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6j07up$hh1@news1.panix.com>, dha@panix.com (David Adler) posted:

>On Wed, 06 May 1998 23:58:56 -0400, brian d foy <comdog@computerdog.com> wrote:
>>after my physics degree, my advisor told me it was time for religion :)
>
>Ah.  So *that's* why you turned to perl. :-)

no - i turned to Perl for the cool Perl Mongers t-shirt.

i'm hardly religious about Perl though.  if something sucked less i'd
use it.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
especially since i got over the regex-for-everything disease.


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

Date: 8 May 98 18:50:52 GMT
From: "Dmitri Budchenko" <dmitri-b@usa.net>
Subject: Win32::ODBC; NEW doesn't work
Message-Id: <01bd7adc$30a42720$715992c6@senspro>

The following line always returns False:

if (!($O1 = new Win32::ODBC($DSN1))){....

I'm running Perl 5.004 and Roth's ODBC on Windows95 machine. I did all
required file copies required by ODBC installation instruction. Probably,
the problem is in some incorrect value in @INC. Actually, before this line,
script creates a proper DSN for a given Access database. Script has been
tested on other similar machine, and worked Ok.



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

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

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