[9907] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3500 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 21 11:08:34 1998

Date: Fri, 21 Aug 98 08:00:33 -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, 21 Aug 1998     Volume: 8 Number: 3500

Today's topics:
    Re: [Upgrade Prob] 5.005 causes "to late for -T" errors <Matthew.Wickline@usa.net>
    Re: [Upgrade Prob] 5.005 causes "to late for -T" errors <Matthew.Wickline@usa.net>
        AS perl and module installation dturley@pobox.com
    Re: COBOL and Perl foochre@my-dejanews.com
    Re: Converting to lowecase <mikeg@slpma8.ed.ray.com>
        Followup: why doesn't this work as expected... newsgrp@business-heaven.com
    Re: help, @INC doesn't contain /usr/lib/perl5 dzuy@my-dejanews.com
    Re: how can i encode data to cgi program? (Steve Linberg)
    Re: How to get data from Access-Database via CGI (Steve Linberg)
        installing modules on perl for AS/400 <tgray@smlny.com>
    Re: Locking files on Window 95 server dturley@pobox.com
    Re: NEWBIE Question: Perl Script in Unix vs. NT dzuy@my-dejanews.com
        Perl on linux (Kevin Thorley)
        Posting images from a mSQL database sbernard@mail.esiea.fr
    Re: Problem with $^I in W95 ppoo99@my-dejanews.com
    Re: Reading from files (I.J. Garlick)
    Re: Recommend a good editor dturley@pobox.com
    Re: Same subroutine name in require files dzuy@my-dejanews.com
        Search of Large files (Alvin Chao)
    Re: Strange characters while writing in files <gcoulomb@gpu.srv.ualberta.ca>
    Re: Strange characters while writing in files (Andrew M. Langmead)
        Substitution issue. <kevin@templegames.com>
    Re: Substitution issue. (Sean McAfee)
        swap words in regexp <NOSPAMchenyangNOSPAM@mashie.ece.jhu.edu>
        system commands (James Stout)
    Re: what is 'sub f () {555};' (Andrew M. Langmead)
    Re: why doesn't this work as expected... <conmara@tcon.net>
    Re: why doesn't this work as expected... huntersean@hotmail.com
    Re: why doesn't this work as expected... <jdw@dev.tivoli.com>
    Re: Yet another invocation line mystery (does seem to b <mgregory@asc.sps.mot.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 21 Aug 1998 08:48:23 -0500
From: Matthew Wickline <Matthew.Wickline@usa.net>
To: ts <decoux@moulon.inra.fr>
Subject: Re: [Upgrade Prob] 5.005 causes "to late for -T" errors in scripts
Message-Id: <35DD7A9F.7E91@usa.net>

"M" == Matthew Wickline <Matthew.Wickline@usa.net> writes:
"D" == ts <decoux@moulon.inra.fr> writes:

M> My #! did have -wT before

D> perl -cT your_script


Thanks! :)

So this will scan and catch any potential runtime taint issues as well?
The scripts in question are CGI scripts, and I've always previously used
a #! with -wT (under 5.003) so that if I made a taint no-no, the script
would just die and I'd see why in the error log.

If I remove -T from all my cgi scripts' #! lines, will pre-checking with
-cT be enough to ensure that they're taint-safe?

-matt


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

Date: Fri, 21 Aug 1998 08:58:16 -0500
From: Matthew Wickline <Matthew.Wickline@usa.net>
To: ts <decoux@moulon.inra.fr>
Subject: Re: [Upgrade Prob] 5.005 causes "to late for -T" errors in scripts
Message-Id: <35DD7CEF.50C7@usa.net>

"D" == ts <decoux@moulon.inra.fr> writes:

D> It's best to don't remove -T on the first line


thx again :)

Actually, as soon as I sent off that last message, my mind finally
linked what you'd just said w/ what I'd read in perldiag... and I
realized that I hadn't actually seen any of my CGI scripts break over
the 'net, I just figured they would since they failed perl -c... but I'd
already hit send by then. :)

I'm suprised I didn't see a rash of threads like this in dejanews circa
the 5.004 release: maybe I just wasn't searching well enough...

Well, thanks for the help! :)

-matt


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

Date: Fri, 21 Aug 1998 13:04:51 GMT
From: dturley@pobox.com
Subject: AS perl and module installation
Message-Id: <6rjr9j$8ag$1@nnrp1.dejanews.com>

I've been playing with the ActiveState build 5.005_02. I've noticed that when
installing modules I cannot pick my own directory structure. Something like:

perl makefile.pl PREFIX=d:\newMods

is ignored. According to thier web site ActiveState was "formed in 1997 by
Dick Hardt and O'Reilly and Associates", I see no mention of Microsoft so
this "you must install where I tell you to" attitude is not expected.

This can certainly be a problem when updating perl on a system where lots of
modules have been installed. (could this mean no updates are planned? :-)

Has anyone found a way to get around this? This is supposed to be core perl,
right?

cheers,

david

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


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

Date: Fri, 21 Aug 1998 13:59:48 GMT
From: foochre@my-dejanews.com
Subject: Re: COBOL and Perl
Message-Id: <6rjugj$cmr$1@nnrp1.dejanews.com>

In article <3298230.76649.23593@kcbbs.gen.nz>,
  riplin@kcbbs.gen.nz (Richard Plinston) wrote:
> In message <<6re8o6$vb5$1@nnrp1.dejanews.com>> foochre@my-dejanews.com writes:
> > >
> > > Please supply an informed explanation for your alledged mirth.
> >
> > People who enjoy their job are better at it
> > Perl is really fun to program in, allowing freedom of expression
> > for the programmer.
> > COBOL is a dog to program in, forcing the programmer to type in
> > reams and reams of nastily formatted junk.
>
> Well I had asked for an _informed_ opinion, I didn't expect to
> get one, and I didn't.

I've used COBOL, I've used perl.  That's informed enough for me.

> > Perl and COBOL are on the opposite ends of the spectrum.  If you
>
> That is correct, as are the problems that the languages are
> aimed at.

Agreed, and also the mindsets they were created for and by.

> Most businesses want their Cobol programs to work the way the
> business operates.  They do not want the programmers
> 'creatively' doing 'interesting' things that do nothing to
> help run the business.  In general an undisiplined approach
> results in a mess of undocumented patches and half-completed
> tasks (where the programmer got bored) that have no formal
> structure and no consistency.

I'd argue that the best approach is to have creative programmers
and good management - so that creativity has direction.

> This 'creative' approach means that when one programmer leaves
> all his work may as well be thrown out as no other 'creative'
> programmer would agree to work on it, 'preferring' to start
> again with his own ideas.

I wouldn't dream of it -- that would be a waste.  Prototyping
is an important part of design, but throwing away something that
works is a ridiculous idea that a good manager would hopefully
prevent.

> These creative programmers may be happy, they just move on
> to another site for new challenges and leave a trail of
> destruction behind them.

On the contrary, creative programmers are generally over-proud
people who want their work to be admired and used, so produce
excellent documentation.  POD allows high quality documentation
to be intertwined with perl code in a highly pleasing and
maintainable manner.

> Perl is excellent for small simple tasks that can be coded
> and maintained by one person.  Simple prototypes, even for
> CGI scripts.  For replacing AWK and sed scripts, for
> playing with toys.

Indeed.  It's also excellent for everything else too.

> To develop a system that outlast the life of its creator(s),
> that will be worked on by generations of programmers, that
> will run the business and will grow with it, a far more
> formalised approach is required.

I see strange irony in this statement considering the amount of
money that is being ploughed into fixing up old cobol programs
at the moment.

> A skateboard may be ridden creatively and is far more
> exciting, but you need a truck to shift the goods,
> boring though it may be to drive.

Tenuous, irrelevant, wrong.  You're getting mixed up.  Perl is
a *huge* language.  Much bigger than cobol, particularly if you
take into account the *massive* library of modules available
through CPAN.  Because perl is so rich a language, perl programs
are smaller.  You're getting mixed up between big languages and
big programs.  Having a big language is good if you only need to
know a very small subset of it to produce useful programs.
Having a small language means you have to produce huge lines of
code to get anything done, which is depressing from the point of
view of a programmer.

If anything, Perl is the truck, and COBOL is a morris minor that
is about to break down.

I've put comp.lang.perl.misc back into the group list, not
quite sure why you took it out.


Alex

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


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

Date: Fri, 21 Aug 1998 08:41:30 -0400
From: Michael Genovese <mikeg@slpma8.ed.ray.com>
Subject: Re: Converting to lowecase
Message-Id: <35DD6AFA.7FEE@slpma8.ed.ray.com>

M.J.T. Guy wrote:
> 
> Scott Erickson <Scott.L.Erickson@HealthPartners.com> wrote:
> >
> >Not necessarily true. The sysadmin who installed Perl on my system,
> >for whatever reason, did not install perldoc. Eventually it was
> >installed, but, please, do not assume that if you have perl, you have
> >perldoc
> 
> But the standard install procedure always installs perldoc (at least on
> Unix platforms  -  dunno about the rest).    So if you don't have
> perldoc, you don't have a correctly installed Perl.
> 
> Mike Guy

Too true. Bit it STILL happens.
On many of our systems here, until quite recently, we had the main
perl executable and debugger and little else. NOT the docs or perldoc or
many of the various packages/libraries.  This problem is (slowly) being
fixed, but there are still "incorrectly installed" perls on some of
our systems. (*sigh*)


-- 
Mike Genovese, Sr. S/W Engineer
Software Engineering Laboratory, Raytheon, Marlborough, MA
508-490-3891
My opinions are my own, and not necessarily those of my employer.


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

Date: Fri, 21 Aug 1998 14:03:30 GMT
From: newsgrp@business-heaven.com
Subject: Followup: why doesn't this work as expected...
Message-Id: <6rjuni$d3r$1@nnrp1.dejanews.com>

Thanks for the replies, the main issue being that tr doesn't use regular
expressions.

Am I right is assuming that the following commands are equivalent. ie both
escape all the .'s in a string.

$_ = "a.b.c"  trying to produce $_ = "a\.b\.c"

$_=~s/\./\\\./g;

is the same as

$_=~tr/./\./;

I'm finding it very difficult to test this cause or the escaping of
characters. What I'm trying to do is compare the ip address returned from
REMOTE_ADDR with a stored ip address. The REMOTE_ADDR contains all the
relevant chars escaped (I understand)

Thanks for any input
Terry



In article <6rji71$upn$1@nnrp1.dejanews.com>,
  newsgrp@business-heaven.com wrote:
> This is the script....
>
> #!/usr/bin/perl
>
> $ip = " test.|test1.|test2";
> print "tst1: $ip\n\n";
> $ip =~ s/(\W)/\\$1/g; 		#putting in escape for non chars
> print "tst2: $ip\n\n";
> $ip =~ s/\\\|/\|/g;		#remove the escaping of the |
> print "tst3: $ip\n\n";
> $ip =~ tr/./\./;	        #??? why isn't this changing everything to a .
> print "tst4: $ip\n\n";
>
> exit;
>
> Creates this output......
>
> tst1:  test.|test1.|test2
>
> tst2: \ test\.\|test1\.\|test2
>
> tst3: \ test\.|test1\.|test2
>
> tst4: \ test\.|test1\.|test2
>
> Why isn't the output tst4:.... all .'s
>
> Thanks
> Terry
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum
>

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


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

Date: Fri, 21 Aug 1998 13:56:12 GMT
From: dzuy@my-dejanews.com
Subject: Re: help, @INC doesn't contain /usr/lib/perl5
Message-Id: <6rju9s$cl7$1@nnrp1.dejanews.com>

In article <6rh9be$8s7$1@nnrp1.dejanews.com>,
  nana@my-dejanews.com wrote:
> I've just installed latest perl on my linux on intell. actually it was
> installed with linux, but then I needed some additional modules. I tryed to
> use CPAN shell to install them and finally ended up installing the latest
> perl5.00502.
>
> Now my problem is that it can't find any module which is in /usr/lib/perl5
> (strict.pm for example) and reason is that @INC contains
> /usr/lib/perl5.00502, /usr/lib/perl5/site_perl, etc, except /usr/lib/perl5.
> Is this a way it sould be, or do I need somehow to include /usr/lib/perl5 in
> @INC and how to do that?
>
> thanks
>

	There are many ways to do this.  One is using the environment variabble
	PERL5LIB pointing to your /usr/lib/perl5 (for global effect or local).
	Another way is push it in the @INC array in your script (local to script
	only).  And if you're brave enough, re-config and re-compile.

	Dzuy

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

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


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

Date: Fri, 21 Aug 1998 09:18:57 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: how can i encode data to cgi program?
Message-Id: <linberg-2108980918570001@projdirc.literacy.upenn.edu>

In article <6rijsu$4v0@netnews.hinet.net>, "vega" <vega@acer.net> wrote:

> as title:
> i write a porgram ,and it must communicate with cgi program,
> so how can i encode my input data to cgi program?
> thanks a lot!

Ask in comp.infosystems.www.authoring.cgi.
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Fri, 21 Aug 1998 09:20:34 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: How to get data from Access-Database via CGI
Message-Id: <linberg-2108980920340001@projdirc.literacy.upenn.edu>

In article <6rjqih$jgg$1@sun579.rz.ruhr-uni-bochum.de>, "Alexander
Marquart" <info@kptkip.com> wrote:

> Hello there!
> 
> I4ve got the problem to connect our Web-Server via CGI to the data on our
> Access- Server.
> 
> Does anybody know if it is possible to get the data out of the database with
> CGI to implement these in my HTML-pages?

Yes, it is.  Go to www.activestate.com and look for Win32::ODBC; that's
one way.  Then use dejanews and search this group's archives for code
samples.  Good luck!
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Fri, 21 Aug 1998 09:24:42 -0400
From: "Tim Gray" <tgray@smlny.com>
Subject: installing modules on perl for AS/400
Message-Id: <6rjsen$7ak$1@m5.stny.lrun.com>

I would like to start making some use out of our AS/400 so I figured perl
could help me do that.  But I have it installed and now I am kind of at a
stand still.  The instructions for installing modules using the make command
wont work.  Can anyone tell me how to install libnet on a 400?  Or if you
have any good pointers for as/400 perl sites I would appreciate it.  Thanks.




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

Date: Fri, 21 Aug 1998 12:50:35 GMT
From: dturley@pobox.com
Subject: Re: Locking files on Window 95 server
Message-Id: <6rjqer$738$1@nnrp1.dejanews.com>

In article <6rhb9q$34s$1@news2.xs4all.nl>,
  h.benne@library.uu.nl (Hugo Benne) wrote:
> Hello !
>
> I tried to use the command "flock (FILE,2);" to lock a file on our Win95
> webserver.

flock is not implemented on Win95 because it is not a multi-user system,
therefore there should be noone else trynig to access the file. (some would
claim it's barely a single-user system) If you are going to run a windows web
server, you should at least go to NT.

As other responces have pointed out, the FAQs do list techniques that will
accomplish locking, but they are imperfect for a really busy system.

cheers

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


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

Date: Fri, 21 Aug 1998 14:22:24 GMT
From: dzuy@my-dejanews.com
Subject: Re: NEWBIE Question: Perl Script in Unix vs. NT
Message-Id: <6rjvr0$ear$1@nnrp1.dejanews.com>

In article <35dc5766.267568342@uphs1>,
  NOjcjSPAM@mail.med.upenn.edu (Mr. Mirthful) wrote:
>
> >	Use vi on UNIX to edit your script.  If you see an ^M at the end
> >	of every line, this is your problem.  This is also a problem if
> >	you try to read in a DOS format file, UNIX cannot find the end of
> >	line.  You need to strip off all ^M.  Type
> >
> >		<shift>:1,$s/<ctrl>v<shift>m//g
> >
> >	This will strip all ^M.
>
> In vi and Emacs, every line did have ^M (which did not show up in
> Pico). Actually, vi couldn't find the pattern ^M even though i could
> see it, so i loaded the page in Pico, made a small change, and
> reloaded it in vi and all of the ^M characters were gone.

	I thought I saw someone who used DOS edit and save it as *.txt file
	and that works too, but I'm not sure.  I don't know anything about
	Pico, but it sounds like it removes them automatically. To type
	^M in vi, you'd have to type <ctlr>v<ctlr>m (I apologize for my error
	in the previous post).
>
> Thanks for the assist.
>
> -Jerrold
>
> --remove NOSPAM to reply
>
> --
> My Father Always Believed That   | I want        | The Acquisition
> Laughter Was The Best Medicine,  |    to         |   of Information
> I Guess That's Why Several Of     |   believe.    | is an Advantageous
> Us Died Of Tuberculosis! :^)       |   - X-Files   |   Expedition.
>
> http://mail.med.upenn.edu/~jcj
>

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


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

Date: Fri, 21 Aug 1998 14:48:38 GMT
From: kthor@mail.idt.net (Kevin Thorley)
Subject: Perl on linux
Message-Id: <6rk1bm$o7n@nnrp2.farm.idt.net>

Hi!  I've been writing perl scripts for awhile on Win95, but recently
decided to install linux on my computer.  Now I can't even get a
simple script to run!  Perl is located at /usr/bin/perl, but when I
add this command as the first line of the script, it doesn't work :
#!/usr/bin/perl.  The error message says something like program not
found. When I run the following from the command line though, it works
great: 

	/usr/bin/perl perltest.pl

Whats going on here?  i didn't install perl myself, it came with the
RedHat 5.1 installation.  Any ideas?

	Kevin Thorley
	kthor@idt.net



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

Date: Fri, 21 Aug 1998 13:53:46 GMT
From: sbernard@mail.esiea.fr
Subject: Posting images from a mSQL database
Message-Id: <6rju5a$ccs$1@nnrp1.dejanews.com>

  Hi all,

  Well, I'm in trouble because I don't manage to send a variable as an image.
Well, I've made a script to upload a image file, and put it in a database. All
is ok, but then, I want to put this image into an HTML page, and I just can't
make the browser print it by a simple :
  print "Content-type : image/jpeg\n\n";
  print $image;

  Well $image contains my image, it is a concatenation of many bytes handled
as if they are characters (the same thing in fact).

  If someone can helps ...
                                                  Sebastien BERNARD

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


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

Date: Fri, 21 Aug 1998 13:29:01 GMT
From: ppoo99@my-dejanews.com
Subject: Re: Problem with $^I in W95
Message-Id: <6rjsmu$aao$1@nnrp1.dejanews.com>

In article <6rga9h$el4@fumnix.metronet.com>,
  tye@fumnix.metronet.com (Tye McQueen) wrote:
> louie@visca.com (Louie) writes:
> )
> ) I'm trying to use the $^I in-place edit variable in Win95 (running the
> ) GSAR version 5.004_02). The following works as expected:
> [...]
> ) However, when I try $^I = 'old/*.bak'; (the c:/texts/old/ directory
> ) exists), the original file is erased and no backup is made.
>
> If the old file was named "file.ext", then Perl tried to create
> a backup called "file.extold/*.bak" and failed.
>
> ) In fact, this happens whenever a * is used.
>
> Who said you could use "*" in $^I values?  Granted, the
> documentation on this feature is a bit slim (at least the best of
> what I found, which was in perlrun.pod), but I don't think it
> even hints that what you are trying is supported.

I regret having lost my source, but I read recently that you could use $^I =
'old/*.bak' to shove the .bak file into a subdirectory. In the same source I
read why $^I cannot be undefined in MS-DOS (something to do with the way
MS-DOS names and renames files).

I've grepped both my hard drives for $^I, but can't find the doc in question.
In all events, thanks for your response.

>
> ) Finally, if I try $^I = 'bak'; the
> ) original file is erased and a 0 byte copy (numbers.txtbak) is created.
> )
> ) Is this just MS-DOS weirdness? Thanks.
>
> Well, this last one might be an MS-DOS weirdness.  The rest are
> just Perl.

Lou

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


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

Date: Fri, 21 Aug 1998 08:45:15 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: Reading from files
Message-Id: <Ey16zF.BIy@csc.liv.ac.uk>

In article <1de2vj0.1skiare1qhwqwhN@bay1-279.quincy.ziplink.net>,
rjk@coos.dartmouth.edu (Ronald J Kimball) writes:
> I.J. Garlick <ijg@csc.liv.ac.uk> wrote:
> 
>> close FH; # should have a die/error report here as well
> 
> For some reason, this line of code strikes me as very amusing...
> Taken to extremes:
> 
> #!/usr/local/bin/perl -- # should use -w here
> 
> # should use strict here
> 
> # should iterate over input here
> #    should process current input block here
> 
> # should print results here
> 
> # should exit here
> 
> # should define various subroutines here
> 
> 
> ;-)

Ok Ok. I never put a die there, I know I should but I never do. This was
supposed to only give the relevant bit, I wasn't going to the trouble of
writing a complete script.

FYI I always run with -w and 'use strict' but i figure if others don't
want to I won't get pedantic about it, after all it's there funeral.

> 

-- 
--
Ian J. Garlick
ijg@csc.liv.ac.uk

Every word is like an unnecessary stain on silence and nothingness.
                -- Beckett


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

Date: Fri, 21 Aug 1998 12:54:50 GMT
From: dturley@pobox.com
Subject: Re: Recommend a good editor
Message-Id: <6rjqmq$7dh$1@nnrp1.dejanews.com>

In article

Gee, i've always though that Jon Orwant was a pretty good "perl editor.' :-)

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


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

Date: Fri, 21 Aug 1998 14:04:25 GMT
From: dzuy@my-dejanews.com
Subject: Re: Same subroutine name in require files
Message-Id: <6rjup8$d48$1@nnrp1.dejanews.com>

In article <35DC2CB2.80DFCC73@mitra.com>,
  Phuong Le <ple@mitra.com> wrote:
> require 'f1.pl';
> require 'f2.pl';
>
> f();
>
> If both f1.pl and f2.pl implement a subroutine f.  When f is call Perl
> cannot resolve to which f to call and so it hang.
>
> Is there a way to resolve this ambiguity without rename one the
> subroutine name?
>
	You can use package to resolve it.

	package f1;	# in f1.pl
	package f2;	# in f2.pl

	Then call your function of choice f1::f() or f2::f()

	Dzuy

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


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

Date: Fri, 21 Aug 1998 13:55:35 GMT
From: chaoaj@jmu.edu (Alvin Chao)
Subject: Search of Large files
Message-Id: <35dd7bb7.93868496@news>

I'm looking for information on algorithms/methods in PERL for
searching a extracting a record from a HUGE(75MB) flat file.  
If anyone knows of any processor efficient and stable search algos for
big files please point me in the right direction.  Any general tips
for searching would also be appreciated.

Thanks,

Alvin Chao
JMU - SA/Web Programmer
email:chaoaj@jmu.edu


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

Date: Fri, 21 Aug 1998 08:00:30 -0600
From: Greg Coulombe <gcoulomb@gpu.srv.ualberta.ca>
Subject: Re: Strange characters while writing in files
Message-Id: <35DD7D7E.E37E990F@gpu.srv.ualberta.ca>

joumdane@hotmail.com wrote:
> 
> Hi,
> I'm writing a program whitch is handling files. When I write in any file a
> string, i find the string written but with more characters at the end of the
> string. a sample program whitch gives this is :
> 
> $file = 'tmp1';
> open(TEST, ">$file" );
> print TEST "HI" ;
> close <TEST> ;

Try using 'close TEST' instead of 'close <TEST>'. <TEST> refers to the
contents of the file, not the file handle itself.

-- 
Greg Coulombe
Programmer, Orlando Project
Faculty of Arts
University of Alberta
coulombe@cs.ualberta.ca

Don Diego de la Vega (Hopkins): Do you know how to use that thing?
Alejandro (Banderas): Of course, the pointy end goes into the other man.
		-Mask Of Zorro
		(They were talking about a sword, you pervert)

"It is easier to port a shell than a shell script."
			-- Larry Wall


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

Date: Fri, 21 Aug 1998 14:25:55 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Strange characters while writing in files
Message-Id: <Ey1Mr7.n37@world.std.com>

joumdane@hotmail.com writes:

>Hi,
>I'm writing a program whitch is handling files. When I write in any file a
>string, i find the string written but with more characters at the end of the
>string. 


The <> construct is not part of the name of a file handle, it is the
readline operator which takes the name of a filehandle as its infix
argument. So your line:

close <TEST>;

is reading from the filehandle TEST (the filehandle you opened for
writing) returning a line (of junk) and using that line as the name of
the filehandle to close. The act of reading from your write-only
filehandle is messing up perl's (or more accurately the standard C
libraries) file buffers, and junk is being appended to your file.

Change that line to:

close TEST;

and things should be fine.

(And by the way, thank you for your clear explaination of your problem
and your small test case that demonstrates it.)

-- 
Andrew Langmead


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

Date: Fri, 21 Aug 1998 10:04:06 -0400
From: Kevin Holbrook <kevin@templegames.com>
Subject: Substitution issue.
Message-Id: <35DD7E56.3C3C0227@templegames.com>

Hello All.

I am trying to substitute all commas in a string between double quotes
with carats.

I have tried :

1 while ($string =~ s/\"(.*?)\,(.*?)\"/$1^$2/g);

Also :

$string =~ s/\"(.*?)\,(.*?)\"/$1^$2/gs;

But, I can never seem to replace more thjan the first instance of the
comma.

With both, "Hello, this, is, a, test" yields "Hello^ this, is, a, test".

I have tried all examples in the O'Reily Programming Perl book, checked
all FAQ's on the CPAN, to no avail.

Anyone have any ideas?

Thanks in advance,


-Kevin



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

Date: Fri, 21 Aug 1998 14:58:36 GMT
From: mcafee@galaga.rs.itd.umich.edu (Sean McAfee)
Subject: Re: Substitution issue.
Message-Id: <wWfD1.1524$QT4.7136515@newbabylon.rs.itd.umich.edu>

In article <35DD7E56.3C3C0227@templegames.com>,
Kevin Holbrook  <kevin@templegames.com> wrote:
>I am trying to substitute all commas in a string between double quotes
>with carats.

>Anyone have any ideas?

Yes:

my $flag;   # 1 if inside quotes, 0 otherwise
s/("|,)/$1 eq '"' ? (($flag = !$flag), '"') : ($flag ? '^' : ',')/ge;

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


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

Date: Fri, 21 Aug 1998 10:44:37 -0400
From: Chenyang Xu <NOSPAMchenyangNOSPAM@mashie.ece.jhu.edu>
Subject: swap words in regexp
Message-Id: <35DD87D5.41C6@mashie.ece.jhu.edu>

Hi,

   I would like to perform the following swap in PERL using regexp.

     UpperCaseWord -> CaseUpperWord
     AnotherUpperCaseWord -> UpperAnotherCaseWord
   
   Can anyone tell me how to do this? 

   Please reply me by email. Thanks.

-- 
Chenyang Xu

                              \\|//
                              (o o)
 --------------------------ooO-(_)-Ooo----------------------------------
   (o) 410-516-6819             |   Fax:410-516-5566
   chenyang@jhu.edu             |  
http://iacl.ece.jhu.edu/~chenyang      
         _________________________________________________________
        /          Image Analysis and Communication Lab          /
       /   Department of the  Electric and Computer Engineering /
      /         The Johns Hopkins University                   /  
     /             Baltimore, MD 21218                        /
 =======================================================================


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

Date: Fri, 21 Aug 1998 13:01:13 GMT
From: itxjcs@unix.ccc.nottingham.ac.uk (James Stout)
Subject: system commands
Message-Id: <35dd6ecc.15840367@news.nottingham.ac.uk>

Hi

I can't find the answer in my books or in the FAQ's.
On my system you have to type setup opeiningres2.0 before you can use
the db. I can't get the following script to work though. I get a
message saying that setuo couldn't be found.

Any ideas?

Thanks in advance

James Stout


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

system "setup openingres2.0";

exit;


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

Date: Fri, 21 Aug 1998 14:15:40 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: what is 'sub f () {555};'
Message-Id: <Ey1MA4.9p4@world.std.com>

kortbein@iastate.edu (Josh Kortbein) writes:

>: sub f () {555};

>It looks to me like it returns 555, regardless of the argument
>provided 

Close, it refuses to take any arguments, and returns 555. (The parens
between the subroutine name and the block contain the subroutines
prototype. A null prototype prevents the functions from getting
arguments)

You know one the neat things about perl is that it is so wasy to try
things out.


/usr/tmp>perl -e 'sub f () { 555 } printf f(2)'
perl -e 'sub f () { 555 } printf f(2)'
Too many arguments for main::f at -e line 1, at end of line
Execution of -e aborted due to compilation errors.
/usr/tmp>

-- 
Andrew Langmead


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

Date: Fri, 21 Aug 1998 14:56:34 GMT
From: Ken McNamara <conmara@tcon.net>
Subject: Re: why doesn't this work as expected...
Message-Id: <35DD6E86.FA459F2E@tcon.net>

Terry -

Now I know why I need to follow this news group.  Turns out 'tr///' does not use
regular expressions.  Probably obvious to long time Perl afficionados - but that
fact is a really obscure detail in the docs I have.

Thanks for posting this question - you saved me some grief!

KenMc

newsgrp@business-heaven.com wrote:

> This is the script....
>
> #!/usr/bin/perl
>
> $ip = " test.|test1.|test2";
> print "tst1: $ip\n\n";
> $ip =~ s/(\W)/\\$1/g;           #putting in escape for non chars
> print "tst2: $ip\n\n";
> $ip =~ s/\\\|/\|/g;             #remove the escaping of the |
> print "tst3: $ip\n\n";
> $ip =~ tr/./\./;                #??? why isn't this changing everything to a .
> print "tst4: $ip\n\n";
>
> exit;
>
> Creates this output......
>
> tst1:  test.|test1.|test2
>
> tst2: \ test\.\|test1\.\|test2
>
> tst3: \ test\.|test1\.|test2
>
> tst4: \ test\.|test1\.|test2
>
> Why isn't the output tst4:.... all .'s
>
> Thanks
> Terry
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum





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

Date: Fri, 21 Aug 1998 13:28:20 GMT
From: huntersean@hotmail.com
Subject: Re: why doesn't this work as expected...
Message-Id: <6rjslk$aah$1@nnrp1.dejanews.com>

In article <6rji71$upn$1@nnrp1.dejanews.com>,
  newsgrp@business-heaven.com wrote:
> This is the script....
>
> #!/usr/bin/perl
>
> $ip = " test.|test1.|test2";
> print "tst1: $ip\n\n";
> $ip =~ s/(\W)/\\$1/g; 		#putting in escape for non chars
> print "tst2: $ip\n\n";
> $ip =~ s/\\\|/\|/g;		#remove the escaping of the |
> print "tst3: $ip\n\n";
> $ip =~ tr/./\./;	        #??? why isn't this changing everything to a .

because "tr" isn't "s".  tr doesn't do regular expressions.
you want

$ip =~ s/./\./g;

> Thanks
> Terry
No worries.  BTW, if you actually want to quote things safely, check
out "quotemeta".

Sean H



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


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

Date: 21 Aug 1998 07:08:41 -0500
From: "Jim Woodgate" <jdw@dev.tivoli.com>
Subject: Re: why doesn't this work as expected...
Message-Id: <ob1zqar0za.fsf@alder.dev.tivoli.com>


newsgrp@business-heaven.com writes:
> $ip =~ tr/./\./;	        #??? why isn't this changing everything to a .
> print "tst4: $ip\n\n";

you want $ip =~ s(.)(\.)g;

tr doesn't use regex's, so tr (.)(\.); only really succeeds in
counting the number of '.'s in $ip

-- 
Jim Woodgate 
Tivoli Systems
E-Mail: jdw@dev.tivoli.com


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

Date: 21 Aug 1998 10:22:11 +0930
From: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: Re: Yet another invocation line mystery (does seem to be perl related)
Message-Id: <r8ogtf5f7o.fsf@asc.sps.mot.com>

Hans Mulder <hansmu@xs4all.nl> writes:

> Martin Gregory <mgregory@asc.sps.mot.com> wrote:
> >
> >In a previous post I observed that
> >
> >
> > #!/bin/sh
> > eval 'exec perl -w -S $0 ${1+"$@"}'   # Use the -*- perl -*- on our path.
> >      if 0; 
> >
> > print "yay\n";
> >
> >
> >does not work.
> >
> >How come it does work if you remove the #! line!?
> 
> In a response to your previous post, Quentin Fennessy quoted the
> relevant paragraph from perlrun:
> 
>    If the #! line does not contain the word "perl", the program named after
>    the #! is executed instead of the Perl interpreter.  This is slightly
>    bizarre, but it helps people on machines that don't do #!, because they
>    can tell a program that their SHELL is /usr/bin/perl, and Perl will then
>    dispatch the program to the correct interpreter for them.
> 
> Thus if you feed this:
> 
> 	#!/bin/sh
> 	echo "yay"
> 
> into perl, it will work, in the sense that perl will recognize the #!
> line and feed your script into /bin/sh .
> Obviously, if you leave off the #! line, this effect no longer occurs.

Sorry to be dense, but I don't understand this because I'm not feeding
the original script to perl, I'm feeding it to sh.

sh igonores the #! (right? or at worst invokes another sh)  

sh evals the exec and call perl -w blah.

Then what?  Why does something (sh?) end up complaining about -w?

Thanks!

Martin.


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

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


Administrivia:

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

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


The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 3500
**************************************

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