[8183] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1801 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 3 19:12:16 1998

Date: Tue, 3 Feb 98 16:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 3 Feb 1998     Volume: 8 Number: 1801

Today's topics:
    Re: A Scoping Related Question (Andrew M. Langmead)
    Re: can variables be generated on the fly (Andrew M. Langmead)
        comparing dates <monte@ispi.net>
    Re: Crazy Idea (Ilya Zakharevich)
        Debuggin w/o shell <pjmone@symbioticinc.com>
    Re: Debuggin w/o shell (Nathan V. Patwardhan)
    Re: Deleting directories (Jonathan Nicholson)
    Re: Destroying any and all elments of an array.. how? (Craig Berry)
    Re: dump bit/hex question (Andrew M. Langmead)
    Re: Error with analysis of system () return value on Pe (Jonathan Feinberg)
    Re: Good Perl editors (Jonathan Stowe)
    Re: Good Perl editors (Dustin Mollo)
    Re: Help on Perl on Win32 with ODBC32 (Steve Linberg)
    Re: I am female, blonde and stupid! (Bart Lateur)
        Is file locking necessary? <bill@fathead.net>
        Job opening for  CGI programmer (Daniel Cody)
    Re: loading images (Nathan V. Patwardhan)
    Re: LOW LEVEL PERL HELP (Jonathan Stowe)
    Re: New core dump on long-working troff2html <jspath@mail.bcpl.lib.md.us>
    Re: New core dump on long-working troff2html (Ilya Zakharevich)
    Re: Perl in a datawarehouse environment (Eric Weiss)
    Re: Public Response to Private Flame (albeit machine-ge (Martien Verbruggen)
        Quickie: regexp for valid e-mail addresses <dsanders@u.washington.edu>
    Re: replacement for ls command? <shimpei+this+address+is+NOT+munged+.mil+.gov@socrates.caltech.edu>
    Re: TTY Devices? (Andrew M. Langmead)
    Re: using unix commands in perl <gbrown@cae.ca>
        using variables in regexp, updating from data file <erik@peak.mrc.montana.edu>
        Win32::ODBC and Oracle 7.3 (Allan Paicius)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 3 Feb 1998 22:28:17 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: A Scoping Related Question
Message-Id: <EntqF5.MFM@world.std.com>

"V. Chandrasekhar" <vchandra@mail.delcoelect.com> writes:

>I am using Perl 5.004.

>I have a program that I first wrote and tested under Perl 4.
>I am in the process of getting this to work under Perl 5.004.
>Also, I am reviewing the blue Camel book and am trying to get
>into good habits for future programs.

>My 'main' sets several variables. It calls several subroutines.
>Even though main's variables are global, in each subroutine call,
>I explicitly pass variables used. I do this so that it will be 
>obvious what variables are used in the subroutine. 

>From the way it sounds, you could probably turn your dynamically
scoped variables into lexically scoped variables without changing the
logic of your program.

You could try declaring the variables with the "my" operator near the
top of the script outside of any subroutine, and changing the "local"
operators to "my" operators inside the subroutine and see if the
program still executes correctly.

My bet is that you find at least one dormant bug in your script when
you modify it. (A bug that existed in the previous version, but went
undetected.)

-- 
Andrew Langmead


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

Date: Tue, 3 Feb 1998 22:00:36 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: can variables be generated on the fly
Message-Id: <Entp52.My4@world.std.com>

chip@mail.atlantic.net (Chip Salzenberg) writes:

>>However, they do have there uses, especially when obtaining a reference
>>to an object can be quite troublesome if you restict your self to hard
>>references only.

>And obtaining hard references is difficult exactly when?

Well, its a little easier to turn input into a soft reference than a
hard reference. To get the hard reference, you have to set some sort
of mapping between string and the reference.

%hash = (sub_a => \&sub_a, sub_b => \&sub_b);

But on the other hand, I'm not sure if I'd want a syntax error in the
input to call any arbitrary subroutine of my program as in:

     &{shift @ARGV};

-- 
Andrew Langmead


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

Date: Tue, 03 Feb 1998 17:20:35 -0600
From: Monte Ohrt <monte@ispi.net>
Subject: comparing dates
Message-Id: <34D7A643.97722C07@ispi.net>

Hi,

Is there an easy way to get the difference between two dates (in seconds
preferrably)
without the need of installing a perl module? I'm writing a script
that I want to redistribute, and I do not want the end user to hassle with
installing
a module just for this one function. (I know I can use date_time_difference in
Date::Calc to do this)

Thanks

Monte


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

Date: 3 Feb 1998 22:38:58 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Crazy Idea
Message-Id: <6b86a2$ij$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Chip Salzenberg
<chip@pobox.com>],
who wrote in article <6b813q$rto$1@cyprus.atlantic.net>:
> According to Larry D'Anna <ldanna@hotmail.com>:
> >m{ 
> >    \d+
> >  | (?:
> >      \(
> >      (?RECURSE)
> >      \)
> >    )
> >  | (?:
> >      (?RECURSE)
> >      [-+*/]
> >      (?RECURSE)
> >    )        	
> >}x
> 
> Actually, the plan is more like:
> 
>  $pat = qr{ 
>             \d+
>           | (?:
>               \(
>               (?d $pat)
>               \)
>             )
>           | (?:
>               (?d $pat)
>               [-+*/]
>               (?d $pat)
>             )        	
>           }x ;
> 
> Not in 5.005, maybe in 5.006.

I'm not sure how the parser will be able to do this (?d) stuff...  Too
many new states of the lexer - at least for the implementation I see.

On the other hand, the same with qr{}xd looks *very* feasible.

Ilya


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

Date: Tue, 03 Feb 1998 18:06:18 -0500
From: Paul Mone <pjmone@symbioticinc.com>
Subject: Debuggin w/o shell
Message-Id: <6b87vk$dv8@bgtnsc03.worldnet.att.net>

Due to the elitest nature of the body of programmers who reside here, I
am forced to both use a proper subject and be as specific as I can.
I have a script, written in Perl, no problems with the code, no problems
with the file attributes/permissions...so don't send me any emails.
My dilemma is that, of course "it doesn't work", but I am curious as to
the best ways to go about debugging when you don't have shell/telnet
access...I can ftp or http to the domain I'm working on, no more, no
less.  I am getting the vaguest of the vague error messages in return
for my hard work...one of the latest is: 
CGIwrap Error: System Error: execv() failed

Error: No such file or directory (2)

but this is nonsense...there is such file or directory.  Basically, I
want to find out more specific information about whats gone
wrong...where did it reach this error, which file is it trying to
access?  Why the hell does my Web-hosting service not give me telnet
access to my "virtual" server? 
				Yours,
				   Paul


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

Date: 3 Feb 1998 23:27:29 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Debuggin w/o shell
Message-Id: <6b8951$ktr@fridge.shore.net>

Paul Mone (pjmone@symbioticinc.com) wrote:
: Due to the elitest nature of the body of programmers who reside here, I
: am forced to both use a proper subject and be as specific as I can.

Dear Person,

I don't think this approach will work for you, either.  Why don't you
just ask the question without all of this sarcasm and the accusatory
tone?  It's quite a turn-off this way; now you've been
killfiled. *plonk*

--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: 3 Feb 1998 08:34:44 -0000
From: jono@nospam.nowhere.noorg (Jonathan Nicholson)
Subject: Re: Deleting directories
Message-Id: <6b6kr4$26f$1@acme.demon.co.uk>

In article <6b5vo8$a47$1@news.ml.com>,
Michael Wang <mwang@alhena.ibk.ml.com> wrote:
>
>OK, but do you include above subroutine in every perl script
>which needs it? or what do you do? Thanks. 

At the moment I've only needed it in one program I've written, if there
was sufficient demand for it then it could be incorporated into a module,
it may already be, I didn't check! It took me about 5 minutes to write (20
minutes to convince myself it was OK, and a further hour to benchmark it
'cos I didn't believe the performance of it!) 

Regards,

Jonathan

-- 
| Jonathan Nicholson (jono at acme dot demon dot co dot uk)  0973 199 983   |
|            TV doesn't rule my life, it just has a casting vote            |


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

Date: 3 Feb 1998 23:23:46 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Destroying any and all elments of an array.. how?
Message-Id: <6b88u3$o8s$1@marina.cinenet.net>

Jeff (dilcher@cueva.nospam.com) wrote:
: Can someone tell me the most efficient way to destroy any and all
: elements that are contained within an array?  This seems like it
: should be a simple matter, but I don't have an idea of how to do this.

Not sure precisely what you mean by 'destroy any and all elements', but

  undef @ary;

will cause the array to become undefined, and hence its former contents 
will be forgotten.  Naturally, references to those contents may still 
exist from other variables, in which case they'll still 'exist'.

In some circumstances,

  @ary = ();

may be prefered.  This is almost but not quite the same thing; rather 
than an undefined array (which will trigger warnings if you try to use it 
to do array-ish things), this gives you a zero-element array.

HTH!

---------------------------------------------------------------------
   |   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: Tue, 3 Feb 1998 22:20:58 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: dump bit/hex question
Message-Id: <Entq30.GD1@world.std.com>

Jeff Gleixner <jgleixn@uswest..com> writes:

>I haven't found the magic combination for this and I was hoping someone
>could answer it.

>I want to convert 0->255 to it's binary equivalant.  I know I can do
>something like:
>printf "%s\n", join('',unpack("B*", "\x255"));
>giving me  '11111111'.

Don't you mean "\xff" will give you "1111111"?

>But what's the magic to having the "255" part a variable?

$variable = 255; # or 0xff
printf "%s\n", unpack 'B*', pack 'C',$variable;


The "pack 'C', will make a single character that corresponds to the
ASCII value of the supplied number. Then the unpack will make a
bitstring of that value. (Notice that the "join()" is not needed since
unpack() returns a bit string, not a bit array. Its a bit unintuitive.

>printf "%s\n", join('',unpack("B*", "\x$variable));
>printf "%s\n", join('',unpack("B*", "0x$variable"));

The "\x" and 0x constructs are taken care of by the perl parser when
it is converting your source text into code. The same way that the
word "print" is turned into the value of the op_print opcode. To
convert bases or formats at runtime you need to do it yourself
explicitly.
-- 
Andrew Langmead


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

Date: Tue, 3 Feb 1998 16:55:14 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: Error with analysis of system () return value on Perl book page 230
Message-Id: <MPG.f415c4ec9ab14329896b4@news.concentric.net>

(Concerning the difficulty in handling the return value of system())

Isn't this ripe for a module?  Unix::System or some such?  Or would
it be too hairy, too system-dependent?

-- 
Jonathan Feinberg    jdf@pobox.com    Sunny Brooklyn, NY


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

Date: 3 Feb 1998 23:08:05 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Good Perl editors
Message-Id: <6b880l$rqk$4@plutonium.btinternet.com>

In article <34D78787.1036@best.com>, sweiss@best.com says...
>

>> 
>> I prefer $EDITOR
>> 
>> Just use whichever makes you most productive.
>> 
>> tony
>What is $EDITOR?  is that part of perl, or something I download
>somwhere?  if so, what is the ftp site?
>
>I'm running linux, so unless it's native, I'll have to recompile it.
>

Yeah I had the same problem with $PATH, I ended up having to edit 
 .bash_profile took me ages to find out how but now its better :-)

Jonathan 



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

Date: 3 Feb 1998 23:11:10 GMT
From: dustin@sonic.net (Dustin Mollo)
Subject: Re: Good Perl editors
Message-Id: <6b886e$u3l$1@ultra.sonic.net>

Wes Gamble (weyus@worldnet.att.net) wrote:

<SNIP>

: Any ideas are welcomed.

Have you tried http://reference.perl.com?  There is a whole section devoted
to Perl editing enviroments, including info on CodeWright.

-Dustin


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

Date: Tue, 03 Feb 1998 17:24:00 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Help on Perl on Win32 with ODBC32
Message-Id: <linberg-0302981724000001@projdirc.literacy.upenn.edu>

In article <01bd30cb$6b3c9a30$190d47a5@rasokol>, "Alex Sokol"
<asokol@jhancock.com> wrote:

> I just installed Perl 5 Win32 by ActivateState, build 315 and
> ODBC32 version 970208 to connect to my MS SQL server.
> 
> I use "use Win32::ODBC"
> 
> when i start up my script i get an error (text is not exact):
> "Can not locate module Win32/ODBC.pm"

Standard stupid questions here: are you sure you put the OBDC module in
the right place, and ODBC.pll?  That would be the main culprit in my
mind.  The readme file explains where they go.

-- 
Steve Linberg                  |    National Center on Adult Literacy
Systems Programmer etc.        |           University of Pennsylvania
linberg@literacy.upenn.edu     |        http://www.literacyonline.org


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

Date: Tue, 03 Feb 1998 22:26:18 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: I am female, blonde and stupid!
Message-Id: <34dc9931.11093367@news.tornado.be>

Kati Gaebler <dont@mailmehere.com> wrote:

>Subject: I am female, blonde and stupid!

If that is your opinion about yourself, I'm not in the least inclined to
help you.

	Bart.


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

Date: Tue, 3 Feb 1998 17:04:44 -0600
From: "Bill Genzer" <bill@fathead.net>
Subject: Is file locking necessary?
Message-Id: <6b887e$i1o$1@news1.iamerica.net>

I am very new at PERL and I have just started writing my own CGI scripts
(really editing other scripts).  I have to admit it seems very simple and
easy to learn.  My question is if it is necessary to lock files before
reading or writing to files?  If it is necessary, how do you do it?  I've
seen a few ways other people do it, but it seems very complicated,  I've
heard of using something called flock?  But not knowing hardly anything
about PERL I have no Idea how to use it.

I've done a few small tests myself to see what would happen if a user tried
to update the same file at the same time and I can't seem to get it to mess
up, Is there some kind of file locking/sharing feature built in to PERL?  Or
do you have to still do it manually?

Thanks
-Bill




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

Date: Tue, 3 Feb 1998 16:20:20 -0600
From: codyd@NOSPAM.cc.sdstate.edu (Daniel Cody)
Subject: Job opening for  CGI programmer
Message-Id: <MPG.f415422f67cfa1298968a@rc.sdstate.edu>

A position has opened up at a major website for webmasters and web site 
designers in the areas of VRML, CGI, and ActiveX programming.  Will need 
to write 2-4 articles per month on how the above languages affect and can 
help webmasters and site designers.  Please mail if interested, include 
experience and current position.

-- 
Daniel Cody
-Webmaster-
South Dakota State University
http://marvin.sdstate.edu


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

Date: 3 Feb 1998 22:10:23 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: loading images
Message-Id: <6b84kf$epb@fridge.shore.net>

Edward Yeh (Eyeh@cris.com) wrote:
: has anyone loaded images into a sql server database ?

You mean GIFs or something?  I guess this has *something* to do with
Perl, but you're just hiding that special something from us.  :-)

To answer your question in Perl terms: I've used the DBI/DBD modules
to access various (sql-like) databases.  I've never stored images in
any of them -- particularly for the web; I've always just stored URLs
or other locations that get instantiated into a webpage that's
generated with CGI.pm.  ;-)

--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: 3 Feb 1998 22:59:51 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: LOW LEVEL PERL HELP
Message-Id: <6b87h7$rqk$3@plutonium.btinternet.com>

In article <MPG.f415b1511a47459896b3@news.concentric.net>, jdf@pobox.com 
says...
>
>Gellyfish@btinternet.com said...
>> I will be prepared to 
>> take a bite of one of my girlfriends hats if you get much more than this 
:-}
>
>Do you mean "the hat belonging to one of my girlfriends," or "one of the 
hats
>belonging to my girlfriend?"  Will ioctl() help me?  Is this a FAQ?
>

Those damn apostrophes again, I have spent all day trying to explain that 
dont is not a new rude word to a colleague.

What I meant is examine the Documentation for the ioctl system call on the 
relevant system.  Unfortunately my girlfriend has no documentation and the 
hats look pretty inedible right now.

Jonathan



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

Date: 3 Feb 1998 21:52:55 GMT
From: "Jim Spath" <jspath@mail.bcpl.lib.md.us>
Subject: Re: New core dump on long-working troff2html
Message-Id: <6b83jn$4kg$1@news.abs.net>

>   From: chip@mail.atlantic.net (Chip Salzenberg)
>   Date: Tue, 03 Feb 1998 21:16:04 GMT
>   References:
>          <6b6tok$5jn$1@news.abs.net>
>According to Jim Spath <jspath@mail.bcpl.lib.md.us>:
>>A 400-line troff file core dumps under the current perl (5.004)
>The current perl is 5.004_04, not 5.004.  Maybe if you try that one it
I'm running 5.004_04 where the dumps occur.
>Or you may be overflowing your stack due to ill-behaved regexes.
Here's the line that seems to be the baddie:
    # records are a command, optional args, newline, optional text
    # This leaves $args with all extra 1st line spaces
    ($command, $args, $text) = /^(\S+)(.*)\n?((.|\n)*)$/;

I'm no regexpert, but that could probably misbehave.  Suggestions?


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

Date: 3 Feb 1998 22:43:41 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: New core dump on long-working troff2html
Message-Id: <6b86it$ij$2@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Jim Spath
<jspath@mail.bcpl.lib.md.us>],
who wrote in article <6b83jn$4kg$1@news.abs.net>:
> >   From: chip@mail.atlantic.net (Chip Salzenberg)
> >   Date: Tue, 03 Feb 1998 21:16:04 GMT
> >   References:
> >          <6b6tok$5jn$1@news.abs.net>
> >According to Jim Spath <jspath@mail.bcpl.lib.md.us>:
> >>A 400-line troff file core dumps under the current perl (5.004)
> >The current perl is 5.004_04, not 5.004.  Maybe if you try that one it
> I'm running 5.004_04 where the dumps occur.
> >Or you may be overflowing your stack due to ill-behaved regexes.
> Here's the line that seems to be the baddie:
>     # records are a command, optional args, newline, optional text
>     # This leaves $args with all extra 1st line spaces
>     ($command, $args, $text) = /^(\S+)(.*)\n?((.|\n)*)$/;
> 
> I'm no regexpert, but that could probably misbehave.  Suggestions?

If you have a very short stack (less than 4-6M) this may segfault on
longer input.  The latter star can take eat up to 32K chars, taking
100-200 bytes of stack per char.

This will not happen with newer Perls (4_55 and later) since (.|\n)*
is optimized to use no recursion.

Ilya



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

Date: Tue, 3 Feb 1998 16:50:08 -0500
From: eweiss@winchendon.com (Eric Weiss)
Subject: Re: Perl in a datawarehouse environment
Message-Id: <MPG.f415b1b63836bcc9896a1@news.dgsys.com>

[This followup was posted to comp.lang.perl and a copy was sent to the cited author.]

Perl is in general good at this type of thing.  It will usually run 
faster than a shell script.  It has a built in debugger which is a plus.

The real strength of Perl is probably its string handling and regular 
expressions.  You can match or not match just about anything.  And coming
soon (...real soon :-) ) is a Perl compiler.

Another advantage is that 99% of Perl will run on virtually any platform.

Eric


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

Date: 3 Feb 1998 23:01:45 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Public Response to Private Flame (albeit machine-generated)
Message-Id: <6b87kp$327$1@comdyn.comdyn.com.au>

[CC to poster]

In article <34D3FC01.3F2@earthling.net>,
	Rich Grise <lovegod@earthling.net> writes:

[Snipped lots of interesting views]

Dear Sir,

Since you obviously have found a way to redefine stupidity, a concept
that has been around since the invention of neural cells, you have
just won the prestigious booboo award. You will be listed, together
with other people of the same quality of thought, in my ~/.killfile
and ~/.procmailrc. 

Sincerely,
Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd.       | negative.
NSW, Australia                      | 


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

Date: Tue, 03 Feb 1998 15:07:30 -0800
From: Dan Sanderson <dsanders@u.washington.edu>
Subject: Quickie: regexp for valid e-mail addresses
Message-Id: <34D7A332.A23634B2@u.washington.edu>

I know it's been done before, so I thought I'd ask before trying to compile my
own.

What's a good regexp that will only match valid e-mail addresses (i.e.
name@subdomain.whatever.domain), that includes all the valid characters that
can be seen in the domain name, etc., and requires the @ symbol?

Many thanks!

______________________________________________________________________
Dan Sanderson                                dsanders@u.washington.edu
University of Washington      http://weber.u.washington.edu/~dsanders/


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

Date: 3 Feb 1998 20:52:08 GMT
From: Shimpei Yamashita <shimpei+this+address+is+NOT+munged+.mil+.gov@socrates.caltech.edu>
Subject: Re: replacement for ls command?
Message-Id: <6b801o$llf@gap.cco.caltech.edu>

-Chen,P.W. <pwyc@ctcgp1.ih.lucent.com> writes:
>
>Why, yes, that's a main reason I use perl.  Not to mention being a superset of
>awk, sed, etc.  Several people have suggested using readdir, etc., I was
>hoping there's a library somewhere that does this kind of thing so I don't
>have reinvent it.  Heck, if someone thought it useful to provide "basename",
>I'd think a "ls" would be at least as useful.
>
>To rephrase my original question, I'm looking for something like:
>	@found=&ls ("$pattern");
>Surely someone has written something like that?  And before you flame me for
>being lazy, please note laziness is one of the virtues extolled in the Camel
>book.

Well, if you really want ls, you can have it.

#! /opt/bin/perl

use Shell qw(ls);

@found=ls(<*>);
print "output of ls:\n", @found;

-- 
Shimpei Yamashita               <http://www.patnet.caltech.edu/%7Eshimpei/>
The address I have listed in the headers is a working address. It just
looks like it's an invalid address in order to fool spammers collecting
addresses from newsgroups.


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

Date: Tue, 3 Feb 1998 23:19:00 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: TTY Devices?
Message-Id: <Entsro.Hpy@world.std.com>

greg@geographe.com.au (Greg Wake) writes:

>Does anyone know of a module which interfaces to TTY devices in a Unix
>environment??

>Alternatively, any docs on the net showing simple input/output to a
>TTY device would be good.

Take a look at the C libraries termios man page, and the
POSIX::Termios section of the POSIX module. Once sufficiently
confused, take a look at the book "Advanced Unix Programming" by W R
Stevens (again, in C, not perl.) for clarity.

-- 
Andrew Langmead


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

Date: Tue, 03 Feb 1998 17:47:33 -0500
From: Gil Brown <gbrown@cae.ca>
Subject: Re: using unix commands in perl
Message-Id: <34D79E85.794B@cae.ca>

Kimbrough Gray wrote:
> 
> I'm trying to copy a file from one directory to another.
> I've been typing in
> cp help.html fun/help.html;
> And I have been getting an error which reads
> "Search pattern not terminated at add.cgi line 14"
> Line 14 is "cp help.html fun/help.html;"
> I thought I had heard that you could type in Unix commands directly
> into your perl code but maybe I am incorrect.

In Perl4 I use to put qx%cp help.html fun/html%;

Don't know if it has changed in Perl5
-- 
Gil Brown
System Administrator Dept.80
CAE Electronics Ltd
gbrown@cae.ca

			"It's not denial."
"I'm just very selective about the reality I accept." --Calvin


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

Date: Tue, 03 Feb 1998 17:12:56 -0600
From: Erik Guss <erik@peak.mrc.montana.edu>
Subject: using variables in regexp, updating from data file
Message-Id: <886546766.910819333@dejanews.com>

I am reading a file of changes to be made into an array
with SPLIT. Then searching a series of files for those
changes, and using s/$from/$to/gi  to make the change.
The problem is that $to has string literals which are
not being interpolated. $from is being interpolated fine.

Here's the program:

#!/usr/bin/perl -w

# Define Variables

$basedir = "/home/erik/btnf";	# base directory
$metdir = "met";		# new metadata files put here
$rawdir = "old";		# original files directory
$datafile = "data.txt";		# list of files to work on, initially only a few
$changesfile= "changes.txt";	# list of changes to make

unlink "$basedir/$metdir/abatch\.chg";#deletes old CHANGES file
open(FILES,"$basedir/$datafile");
@filenames = <FILES>;
close(FILES);

# read the changes file into an array
open(CHANGESTOMAKE,"$basedir/$changesfile");
while ($chline = <CHANGESTOMAKE>) {
	@tmp= split("!",$chline);
	push @changes, [ @tmp ];
}
close(CHANGESTOMAKE);

# open a batch changes file  "abatch.chg" to write changes to
open(CHANGES,">$basedir/$metdir/abatch\.chg") or die "Can't open it $!\n";

foreach $filename (@filenames) {
	unlink "$basedir/$metdir/$filename";	#deletes old NEW file
	open(RAW,"$basedir/$rawdir/$filename") or die "Can't open it $!\n";
	open(NEW,">$basedir/$metdir/$filename") or die "Can't open it $!\n";

	while ($line=<RAW>) {
		for $i (0 .. $#changes ){
			$from=$changes[$i][0];
			for $j (0..$#{$changes[$i]}) {
				$to=$changes[$i][1];
				chomp $to;
				if ($line=~ /$from/) { #if match, write it to changes file
					chomp $filename;
					print CHANGES "$filename:Line $.\nFr:$line";
					$line=~ s/$from/$to/gi;
					print CHANGES "To:$line\n";
				}
			}
		}
		print NEW $line;
	}
}
#end


data.txt looks like this:

besobet.doc
besoply.doc
besopts.doc
bnd_idx.doc

changes.txt looks like this:

^Date:!Metadata Date:
^Documented By:!Metadata Contact:
^Description:!Identification Information:\nCitation:\n\t\tTitle:
^Data Custodian:!Point of Contact:


besobet.doc looks like this:

METADATA for besobet ---------------------------- GENERAL INFORMATION
---------------------------- File Name: besobet Date:
11-SEP-1996:09:10:24.00 Documented By: l.warren Description: Bridger-East
soil survey: level C order 4 Data Custodian: 'GIS Coordinator, USDA
Forest Service, Bridger-Teton National Forest,	Box 1888, Jackson, WY
83001 (307)739-5500' Distribution Limitations: none some other text....



Thanks for any help!

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


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

Date: Tue, 03 Feb 1998 23:20:24 GMT
From: apaicius@1234.ix.netcom.com (Allan Paicius)
Subject: Win32::ODBC and Oracle 7.3
Message-Id: <6b88pg$ser@dfw-ixnews10.ix.netcom.com>

 
I have Win32::ODBC module developed by Dave Roth et al.  
I am looking for any information on my situation.
 
1. I have ODBC working with MS SQL 6.5 and Informix 7.3.  
   - Inserting records.
   - Update on records.
   - Had to do some mods on my SQL Statments between the two formats.
 
2. Currently trying to test on ORACLE 7.3.
 
       $state = qq(SELECT lname FROM tem);
       $tst_con=$db2->FetchRow();
       ($f1) = $db2->Data();
       print qq( [$f1] -- data\n );
 
   I get blank returned on $f1 .. If I use SQLPlus 3.3 (yuk) it works.
  If I use $db2->DumpData; .. shows me the table column and blank below.
 
Does have any ideas for the cause or maybe it was never tested for ORACLE.
I know that there is a DBD::ORACLE...  should I go that route ?
 
Thank you in advance for any help you may provide.
 
Allan Paicius

apaicius@1234.ix.netcom.com

Remove 1234 on e-mail ..... can't stand the spam.


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

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

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