[9633] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3227 Volume: 8

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

Date: Wed, 22 Jul 98 16:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 22 Jul 1998     Volume: 8 Number: 3227

Today's topics:
    Re: 'eval' and 'require' <pckizer@tamu.edu>
    Re: @INC not working from within prog? (Craig Berry)
    Re: comp.lang.perl.moderate (Jonathan Stowe)
        comparing files in perl ()
    Re: Copyright question (Tad McClellan)
        flock operators <coreyp@rc.gc.ca>
        getpwnam() for shadow <chapin@ecst.csuchico.edu>
    Re: getpwnam() for shadow <che@debian.org>
        has anyone attempted a script that can replicate itself jhestyr@my-dejanews.com
    Re: HELP!!!! DOS exitcodes rasta@my-dejanews.com
    Re: Is Perl y2k compliant? (Craig Berry)
    Re: Is Perl y2k compliant? (Andre L.)
    Re: Is Perl y2k compliant? <dean@mail.biol.sc.edu>
    Re: Mod User Reg Hives w/ Win32 Perl <kcjones@umich.edu>
    Re: Non-global from sub or parser problem?? (Tad McClellan)
        Perl -pi <benk@netscape.com>
    Re: Perl with SSI (Steve Linberg)
    Re: Please HELP.  Print problem (Tad McClellan)
    Re: printf syntax? (Tad McClellan)
    Re: question about split (Tad McClellan)
    Re: regexp vs. split (Craig Berry)
    Re: regexp vs. split (Tad McClellan)
    Re: Restricting refering domains access to script? <mattheis@iatcmail.ed.ray.com>
    Re: Save additional data (Tad McClellan)
    Re: Save additional data <fnemec@sti.com.br>
    Re: temp directory for both unix and windows platform <imoore-NOSPAM@erols.com>
    Re: The act of glueing one cat's nose to another's tail (Steve Linberg)
    Re: The act of glueing one cat's nose to another's tail (Craig Berry)
    Re: the low road (Tad McClellan)
    Re: the low road (Tad McClellan)
    Re: the low road <file@job.to>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 22 Jul 1998 20:39:07 GMT
From: Philip Kizer <pckizer@tamu.edu>
Subject: Re: 'eval' and 'require'
Message-Id: <6p5ilb$1mk$1@news.tamu.edu>

mgregory@asc.sps.mot.com (Martin Gregory ) wrote:
>How come I can't use eval to test require?

> eval 'require "foo";';
> !$@ or die "ERROR: perl couldn't parse foo: $@\n";

>(Note that I think that I have to use require because the file of
>interest is a user configuration file: needs to be executed at the
>right place in the program).

I do the same thing in one of my scripts, here's what I do:


  my($req_retval)=eval { require "$file" };

  if (!defined($req_retval)) {
    # Error branch for conditions like empty refire files(RF), RFs with bad
    # code and RFs that return 0.

  } else {
    # Success branch

  }


-philip

--
Philip Kizer <pckizer@tamu.edu>
Texas A&M CIS Operating Systems Group, Unix


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

Date: 22 Jul 1998 21:06:30 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: @INC not working from within prog?
Message-Id: <6p5k8m$mkn$4@marina.cinenet.net>

Tom Robert (trobert@wpine.com) wrote:
: Using -I on the command line works, but modifying
: the @INC variable doesn't seem to.  That is,
: 
: This works:
: perl -I/Perl/lib myprog.pl
: 
: This doesn't:
: unshift (@INC, '/Perl/lib');

Well, I'm sure they both 'work' in the sense that @INC ends up including
the new value; try printing out @INC and my bet is you'll see '/Perl/lib'
in there in both cases.  The problem is that the unshift form probably
isn't being executed soon enough.  If you're trying to add a place to look
for modules which you 'use', that won't work; uses are resolved
effectively at 'compile time' as if they were in a BEGIN block, while your
unshift (I'm betting) doesn't get executed until 'run time', after
use-resolution is completed.

The solution is to do 'use lib' (perldoc lib) like this:

  use lib '/Perl/lib';

before you 'use' the specific modules in the new lib.  'use lib' basically
does the unshift you're trying, but at compile time.

: [according to the doc, this is how I should add to the path]

You (may) need better doc.  Where did you find this advice?

: Also, how do I modify the @INC variable at a global level?

See 'perldoc perlrun'.

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


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

Date: Wed, 22 Jul 1998 22:59:29 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: comp.lang.perl.moderate
Message-Id: <35b66bb5.5577523@news.btinternet.com>

On Mon, 20 Jul 1998 20:50:45 -0400, Ronald J Kimball wrote :

>Zheng Yuan <zyuan@hercules.acsu.buffalo.edu> wrote:
>
>> Subject: comp.lang.perl.moderate
>
>As opposed to
>
<snip ;-}>
>
>comp.lang.perl.religious-right
>   sin() and die "You heathen!\n";
>
Actually I think this might be a place for a new keyword/Module:

use Fundamentalist;

sin() && burn_in_the_fire_of_hell "You heathen!\n";
>
>comp.lang.perl.anarchy
>   comp.lang.perl.misc
>
use Anarchy;

conform() || trash_your_computer $!, "\n";

Dunno, probably couldnt have been improved on innthe first place.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 22 Jul 1998 21:53:44 GMT
From: impactid@pantheon.yale.edu ()
Subject: comparing files in perl
Message-Id: <6p5n18$ei4@jupiter.planet.net>

 hi all: 

i'm wondering if there's a perl function or module that would
do what diff does in unix shell. 

please post or email cwu@geocities.com

thanks

charlie


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

Date: Wed, 22 Jul 1998 15:06:30 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Copyright question
Message-Id: <6og5p6.68b.ln@localhost>

Dustin Cobb (dcobb@cyberrealm.net) wrote:
: I'm a cgi programmer and I've written many scripts for the ISP I work
: for.  Recently, I've been told by someone else in our company that the
: scripts that we've written in Perl cannot be copyrighted due to the fact

: that Perl isn't a compiled language.  


   Bull.

   So books cannot be copyrighted because English in not compiled?  ;-)


: Therefore, we would have to
: re-write most of these scripts in another language (like C/C++) to
: obtain a copyright.  Is this true?  Can anyone give me an example of
: some software that is written entirely in Perl and is legitimately
: copyrighted?


   There is a newsgroup dedicated to discussion of intellectual
   property rights, where such things are discussed.

   Some shark^H^H^H^H^H attorneys even hang out there  ;-)


      misc.int-property



   Ignore the Real Estate ads that find their way there.

   Some folks just cannot get a clue...   ;-(

--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 22 Jul 1998 18:23:13 GMT
From: "Corey Parsons" <coreyp@rc.gc.ca>
Subject: flock operators
Message-Id: <EwIDtD.A63@rc.gc.ca>

Can someone tell me if the operators to the perl floc() command are OS
specific?
I'd check the perlfunc and perldoc manpages but - we don't have them
here...It's a long story.
Anyhow, can someone give me a little advice. BTW the OS is SCO.

Thanks
Corey
coreyp@plato.ucs.mun.ca




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

Date: Wed, 22 Jul 1998 14:03:01 -0700
From: Juan Guevara <chapin@ecst.csuchico.edu>
Subject: getpwnam() for shadow
Message-Id: <Pine.HPP.3.95.980722135708.18609A-100000@cancer.ecst.csuchico.edu>

Hello,

Is there a function like getpwnam() that works with the /etc/shadow
file instead of /etc/passwd?  If there is, is the same syntax used?
Please reply to => chapin@ecst.csuchico.edu
thanx,  -juan
--
Juan Guevara            
chapin@ecst.csuchico.edu        *Make every move as if it were your last*
http://www.ecst.csuchico.edu/~chapin         



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

Date: 22 Jul 1998 15:02:43 -0700
From: Ben Gertzfield <che@debian.org>
Subject: Re: getpwnam() for shadow
Message-Id: <ytthg09ee7w.fsf@gilgamesh.cse.ucsc.edu>

>>>>> "Juan" == Juan Guevara <chapin@ecst.csuchico.edu> writes:

    Juan> Hello, Is there a function like getpwnam() that works with
    Juan> the /etc/shadow file instead of /etc/passwd?  If there is,
    Juan> is the same syntax used?  Please reply to =>
    Juan> chapin@ecst.csuchico.edu thanx, -juan -- Juan Guevara
    Juan> chapin@ecst.csuchico.edu *Make every move as if it were your
    Juan> last* http://www.ecst.csuchico.edu/~chapin

There are patches floating around to make getpwnam() use the shadow
file if permissions allow so.

Check out
http://www.rosat.mpe-garching.mpg.de/mailing-lists/perl-porters/1998-03/msg01574.html
for the full patch.

Ben

-- 
Brought to you by the letters C and P and the number 12.
"Tahiti is not in Europe." -- Sneakers
Debian GNU/Linux -- where do you want to go tomorrow? http://www.debian.org/
I'm on FurryMUCK as Che, and EFNet and YiffNet IRC as Che_Fox.


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

Date: Wed, 22 Jul 1998 22:30:22 GMT
From: jhestyr@my-dejanews.com
Subject: has anyone attempted a script that can replicate itself and then run the copy?
Message-Id: <6p5p5u$qes$1@nnrp1.dejanews.com>

text

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


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

Date: Wed, 22 Jul 1998 21:48:36 GMT
From: rasta@my-dejanews.com
Subject: Re: HELP!!!! DOS exitcodes
Message-Id: <6p5mnk$nr5$1@nnrp1.dejanews.com>

Very easy......use the exit function to terminate
your script. Syntax would be "exit 0" or "exit 1"
depending what value you would like to return.
See page 143 in the old camel book....(I don't
have the 2nd revision....damn, I have to get that!)



In article <6p543b$tc5$1@nnrp1.dejanews.com>,
  mstorer@my-dejanews.com wrote:
> I realise this is probably quite simple but in defense I am a novice to this
> wonderful language!
>
> Is there any way of modifying the exitcodes that perl provides under
> DOS/Windows?
>
> Currently if the perl program succeeds perl returns a level of 0 if the perl
> script does not compile it returns a non 0.
>
> Is there a perl function/command to return a specific exitcode depending on
> script outcome?
>
> TIA
>
> Martin
>
>

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


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

Date: 22 Jul 1998 21:12:07 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Is Perl y2k compliant?
Message-Id: <6p5kj7$mkn$5@marina.cinenet.net>

Victor O. (vonyemelukwe@att.com) wrote:
: Is Perl y2k?

No, it's not.  We'll all be out of work in 17 months, and most of the Web
will come crashing down, too.  It's not going to be pretty.

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


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

Date: Wed, 22 Jul 1998 18:12:02 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Is Perl y2k compliant?
Message-Id: <alecler-2207981812020001@dialup-741.hip.cam.org>

In article <6p5kj7$mkn$5@marina.cinenet.net>, cberry@cinenet.net (Craig
Berry) wrote:

> Victor O. (vonyemelukwe@att.com) wrote:
> : Is Perl y2k?
> 
> No, it's not.  We'll all be out of work in 17 months, and most of the Web
> will come crashing down, too.  It's not going to be pretty.

ROTFL!

Hide the furniture, in case Tom C. comes in.

(Cause he wrote perlfaq4: "Does Perl have a year 2000 problem?")

There's also an article at http://www.perl.com.

A.L.


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

Date: 22 Jul 1998 18:16:44 -0400
From: Dean Pentcheff <dean@mail.biol.sc.edu>
Subject: Re: Is Perl y2k compliant?
Message-Id: <m367gpwmyb.fsf@mail.biol.sc.edu>

"Victor O." <vonyemelukwe@att.com> writes:
> Hello All,

Any reason you thought we'd all know the answer?

> Is Perl y2k?

Of course.  For some definition of 'y2k compliant'.  This has got to
be one of the more meaningless clauses of the late 20th century...  I
assume you've been asked to find out the y2k compliance of all
software in your unit.  So off go a bunch of queries.  Ahem.  Did you
think that you might possibly not be the first person to wonder about
this very issue?  No?

You might try checking the voluminous correspondence on this issue in
this newsgroup at http://www.dejanews.com

You might try checking the voluminous documentation regarding Perl,
particularly the Frequently Asked Questions list which is included
with your copy of Perl.  Or at http://www.perl.com

> Thanks,

You're welcome.  If I sound a touch testy, it's because we've been
deluged of late by queries from people who've contributed essentially
nothing to Usenet but expect us to help them out, when they don't even
glance at the documentation or check to see if their question has been
answered before.  No, I don't expect everyone to know offhand if their
question has been answered before, but I do expect people to do a
minimal amount of research on their own before coming to me for help.

-Dean
-- 
N. Dean Pentcheff                                          <pentcheff@acm.org>
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-7068)


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

Date: Wed, 22 Jul 1998 21:24:07 GMT
From: Kevin Jones <kcjones@umich.edu>
Subject: Re: Mod User Reg Hives w/ Win32 Perl
Message-Id: <XLst1.4810$24.28246948@news.itd.umich.edu>

In article <35B6A2AC.7AA2@comenius.ms.mff.cuni.cz> you wrote:
> Kevin Jones wrote:
>> 
>> I have version 5.00402 of the binary dist of win32 perl.  I'm trying to
>> open and modify a user's registry hive while logged in as a different
>> user.  I've tried everything I can think of, but haven't yet succeeded.
>> 
>> Any Ideas?

> I gues you ARE using something like :
> use Win32::Registry;
> $HKU->Load($username,"$ENV{WINDIR}\\Profiles\\$username\\ntuser.dat");
> $HKU->Open($username, $reg);
> ...
> $HKU->UnLoad($username);
> Try to post the code.
> BTW: What version of libwin32 do you have?
> I'm not sure what version is provided with the distribution, 
> but the newest is 0.12 (AFAIK). Try to get that one.
> Jenda

My code is almost exactly like yours.  My problem now is unloading the hive
Here is my test code:
#####START#####
use Win32::Registry;

$user = 'nt-user';

#load the hive
$HKEY_USERS->Load($user, "C:\\Winnt\\Profiles\\$user\\NTUSER.DAT");

#test to make sure the hive was loaded.
$HKEY_USERS->Open($user, $userkeys);
$userkeys->GetKeys(\@stuff);
print join("\n", @stuff);

#unload the hive
$HKEY_USERS->UnLoad($user) || die "Could not unload $user because $! \n";
#####END#####

for some reason.  I'm able to Load the hive, and mess around with entries
within the hive, but UnLoad fails every time.  Any Ideas?  What am I doing wrong?

Kevin

P.S. I have build 5.00402 of Win32 perl, running libwin32 0.12.
--								       
kevin jones					We are the music makers;    
kcjones@umich.edu			  We are the dreamers of dreams.        
 							 -Willy Wonka


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

Date: Wed, 22 Jul 1998 15:02:25 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Non-global from sub or parser problem??
Message-Id: <hgg5p6.68b.ln@localhost>

F.Quednau (quednauf@nortel.co.uk) wrote:
: However, I just overlooked that Perl doesn't seem to complain about
: $str. Now I am puzzled as well...
            ^^^^^^^^^^^^

Seek ye enlightment in the all-knowing perl documentation 
(perldiag, in this case):


--------------------
=item In string, @%s now must be written as \@%s

(F) It used to be that Perl would try to guess whether you wanted an
array interpolated or a literal @.  It did this when the string was first
used at runtime.  Now strings are parsed at compile time, and ambiguous
instances of @ must be disambiguated, either by prepending a backslash to
indicate a literal, or by declaring (or using) the array within the
program before the string (lexically).  (Someday it will simply assume
that an unbackslashed @ interpolates an array.)
--------------------


perl will complain unless you use @aray before attempting to
interpolate it.


( that '(lexically)' part is trying to say what you said in your other
  followup: "strictly following the sequence of the script"
)


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 22 Jul 1998 15:25:11 -0700
From: BJ Kim <benk@netscape.com>
Subject: Perl -pi
Message-Id: <35B666C7.D13B9224@netscape.com>

I'm trying to edit in place a certain file using this command

perl -p -i.bak -e "s/pear/plum/" fruit.txt

I get this error:
Can't do inplace edit: fruit.txt is not a regular file.



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

Date: Wed, 22 Jul 1998 17:26:18 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Perl with SSI
Message-Id: <linberg-2207981726180001@projdirc.literacy.upenn.edu>

In article <35B64FA1.B925A659@cse.unl.edu>, Ryan Morgan
<rmorgan@cse.unl.edu> wrote:

> hello
> 
> is there anyway to enbed ssi directives within perl scripts?   I know
> that you can set up which files are parsed for ssi using the SetHandler
> command (in the apache config.) , but when the html is generated from a
> perl script, (eg.. login.pl)  the web server wont parse it since its
> not coming from a file with a .shtml extension.  Anyone have a work
> around?

This is a web server problem.  Consult your web server documentation. 
Perl outputs whatever you tell it to output, it's the server's job from
there.  Alternatively, why not just output a .shtml file from your Perl
script?
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Wed, 22 Jul 1998 14:56:13 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Please HELP.  Print problem
Message-Id: <t4g5p6.68b.ln@localhost>

Glenn A. Cooper (cooperga@cig.mot.com) wrote:
: I need to cat a file to a printer using the enscript -r command.  My
: program sucessfully writes the information to a file and I want to
: automatically send it to the printer with the above command.  

: It keeps
: showing that there is no input.  


   What "It"? 

   I guess you mean a script you have written?


: Any help would be GREATLY appreciated.


   Can't fix code that we can't see...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 22 Jul 1998 15:46:06 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: printf syntax?
Message-Id: <e2j5p6.ggb.ln@localhost>

Aaron Fox (afox@u.washington.edu) wrote:

: going wrong in the syntax? It compiles fine....


   Those are mutually exclusive.

   If perl is not complaining, then you do NOT have a syntax error.

   You may, however, be using syntax that conveys undesireable
   meaning (instruction) to perl  ;-)



   Sorry, but this is a pet peeve of mine (folks saying "syntax" when
   they mean "semantics").

   Syntax is like the grammar of an English sentence:

      "Pigs can fly"

   No syntax error there. The sentence is constructed following the
   grammatical rules of English.

   There is a semantic (ie. meaning) error there though...



   I think this confusion arises when you need to change the syntax
   of a program in order to get different semantics. The syntax
   change is just a trivial "housekeeping" type of thing needed to
   get what is Really Important (a different meaning).


   Change the syntax, and you get a different meaning. Here are the
   same English symbols rearranged to get a completely different
   meaning:

      "Can pigs fly"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 22 Jul 1998 14:53:49 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: question about split
Message-Id: <d0g5p6.68b.ln@localhost>

gvacanti@my-dejanews.com wrote:
: From the Camel Book (function split) I understand that in the following
: example:

: $a = ' a b ';
: $_ = $a;
: @b = split /\s+/;
: @c = split;


: foreach(@b){
: print "-b-$_-\n";
: }
: foreach(@c){
: print "-c-$_-\n";
: }

: @b and @c should be the same ("if the PATTERN is also omitted, the function
: splits on white space, /\s+/, after skipping any leading whitespace"). But the
: output I get is:

: -b--       <-- Extra field ?
: -b-a-
: -b-b-
: -c-a-
: -c-b-


: Could somebody explain what's happening? Thanks.


  I think the description for split() in the 'perlfunc' man page
  explains it pretty well.

  What part don't you understand?  (surely you wouldn't have posted
  a question about split() without reading the docs for split()
  first, would you?)


-----------------------
As a special case, specifying a PATTERN of space (C<' '>) will split on
white space just as split with no arguments does.  Thus, split(' ') can
be used to emulate B<awk>'s default behavior, whereas C<split(/ /)>
will give you as many null initial fields as there are leading spaces.
A split on /\s+/ is like a split(' ') except that any leading
whitespace produces a null first field.  A split with no arguments
really does a C<split(' ', $_)> internally.
-----------------------


@b is an example following the form given in the second to last sentence.

@c is an example following the form given in the last sentence.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 22 Jul 1998 20:53:12 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: regexp vs. split
Message-Id: <6p5jfo$mkn$3@marina.cinenet.net>

mboedicker@my-dejanews.com wrote:
: Does anyone see any reason why these two pieces of code wouldn't do the same
: thing?

Let's assume the first line of input processed int the loop looks like
this:

  "A"|"B"|C|D|"E"\n

and trace how each version transforms this.

: while(<SEARCH>) {

"A"|"B"|C|D|"E"\n

:      s/\"//g;

A|B|C|D|E\n

:      s/.*?\|//;

B|C|D|E\n

:      @fields = split(/\|/);

("B", "C", "D", "E\n")

:      foreach $field (@fields) {
:            ... etc
: --------------
: while(<SEARCH>) {

"A"|"B"|C|D|"E"\n

:      s/\"//g;

A|B|C|D|E\n

:      @fields = split(/\|/);

("A", "B", "C", "D", "E\n");

:      $fields[0] = "";

("", "B", "C", "D", "E\n");

:      foreach $field (@fields) {
:            ... etc

See the difference (and why it happens)?  Version two has an empty string
in slot 0, and all the other values moved one position right with respect
to version one.

: I have a file of the format blah|blah|blah|blah and basically I want 
: @fields to be an array of all the fields except the first one.
: Right, now I am using example #2.  The first example seems to strip out
: the first two fields. 

No, the first example strips out the first field, while the second
replaces it with a null string.  I'm not sure how you concluded that two
fields were being stripped -- can you supply a small example that
illustrates this behavior?

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


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

Date: Wed, 22 Jul 1998 16:01:36 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: regexp vs. split
Message-Id: <gvj5p6.gjb.ln@localhost>

mboedicker@my-dejanews.com wrote:
: Does anyone see any reason why these two pieces of code wouldn't do the same
: thing?

: while(<SEARCH>) {
:      s/\"//g;

   tr/"//d;   # this executes _much_ faster.

   And you don't need to backwack the double quote in either case...


:      s/.*?\|//;
:      @fields = split(/\|/);
:      foreach $field (@fields) {
:            ... etc
: --------------
: while(<SEARCH>) {
:      s/\"//g;
:      @fields = split(/\|/);
:      $fields[0] = "";
:      foreach $field (@fields) {
:            ... etc
: --------------


   Yeah, I see why they don't do the same thing.

   The first one _deletes_ the first field.

   The second one sets the first field to the empty string.

   So, @fields has one less element in the first version than it
   does in the second version.

   (try printing $#fields for each and see for yourself)



: I have a file of the format blah|blah|blah|blah and basically I want @fields
: to be an array of all the fields except the first one. 


   (undef, @fields) = split(/\|/);  # first field goes in the trash


: Right, now I am using
: example #2.  


   But example #2 does not do what your word description says you
   want to do. @fields DOES have the first field. You have just
   set it to be the empty string.


: The first example seems to strip out the first two fields. 


   I see it stripping *one* field. Where's the other one?


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 22 Jul 1998 14:43:59 -0400
From: Paul Mattheis <mattheis@iatcmail.ed.ray.com>
Subject: Re: Restricting refering domains access to script?
Message-Id: <s87btqh7mkw.fsf@iatcmail.ed.ray.com>

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

> In comp.lang.perl.misc, some idiot who screws up his address writes:
> 
I have to say I really love this! ^


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

Date: Wed, 22 Jul 1998 16:17:02 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Save additional data
Message-Id: <esk5p6.elb.ln@localhost>

Andy (andy@switchboard.net) wrote:
: Hi,
: I4m writing a script where I have to read out an existing list such a form
: like this:

: data1,number1
: data2,number2
: ......

: In same cases I have to hitch some information.  like that:

: data1,number1
: data2,number2,further2
: ......

: When I open the file for read it will be read line by line. then I have to
: close it and to work with this information. How can I realise it, that only
: this one line will be overwrite with the new information, so that I can
: return to it, when I open the file again.

   if ($line =~ tr/,/,/ == 2)
      {print "has three fields\n"}
   else
      {print "does not have three fields\n"}

: In this content I have an other question. When I split this string at the
: first time, I have only two information, data and number. When my program
: have to check if there are more information (further) it can be, that there
: is nothing, because this information aren4t existing. In pascal I can use
: the term NIL. But what about it in Perl. Does it mean // e.g. $further =~
: //, means there are no information, empty?


   I'm not sure I understand your question.

   Perl uses 'undef' in a way similar to NIL in other languages.



   Does this help?

      ($first, $second, $third) = split /,/;

      if (defined $third)
         {print "has three fields\n"}
      else
         {print "does not have three fields\n"}


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 22 Jul 1998 18:35:31 -0300
From: "Fernando Nemec" <fnemec@sti.com.br>
Subject: Re: Save additional data
Message-Id: <6p5m83$iep$1@news.sti.com.br>

Andy,

>When I open the file for read it will be read line by line. then I have to
>close it and to work with this information. How can I realise it, that only
>this one line will be overwrite with the new information, so that I can
>return to it, when I open the file again.

I have encountered a problem very similar, but I don't find any solution
yet; if you find the solution, please tell me how I can do it!

Thanks!

Fernando Nemec
Sco Paulo - Brasil
fnemec@sti.com.br





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

Date: Wed, 22 Jul 1998 18:49:49 -0400
From: Ian <imoore-NOSPAM@erols.com>
To: "M.J.T. Guy" <mjtg@cus.cam.ac.uk>
Subject: Re: temp directory for both unix and windows platform
Message-Id: <35B66C8D.6C69@erols.com>

I beleive both Unix and Windoze have an enviornment variable called
"TEMP"

M.J.T. Guy wrote:
> 
> Anandan Balaji  <balaji@emicx.mentorg.com> wrote:
> >Hi,
> >
> >I am writing some perl scripts, which can run on both unix and
> >windows platform. Does any one have solution for how to take
> >care /tmp directory in the scripts?
> 
> See IO::File::new_tmpfile or POSIX::tmpnam.
> 
> Mike Guy


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

Date: Wed, 22 Jul 1998 17:24:58 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: The act of glueing one cat's nose to another's tail...
Message-Id: <linberg-2207981724580001@projdirc.literacy.upenn.edu>

In article <35B64F87.EFC9705D@onlinetech.net>, Shaun Gilroy
<shaung@onlinetech.net> wrote:

> ...and a similar operation performed on strings.
> 
> Does anyone have a suggestion on how to copy and concatenate entire
> files in PERL without resorting to:
> exec "cp ..."; [and]
> exec "cat ...";

Um... you don't want to just slurp the files into strings, concatenate
them in memory, and write them back out?  Are they too big?
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: 22 Jul 1998 21:20:09 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: The act of glueing one cat's nose to another's tail...
Message-Id: <6p5l29$mkn$6@marina.cinenet.net>

Shaun Gilroy (shaung@onlinetech.net) wrote:
: Does anyone have a suggestion on how to copy and concatenate entire
: files in PERL without resorting to:
: exec "cp ..."; [and]

perldoc File::Copy

: exec "cat ...";

That's trivial to write in Perl.  Basically, open your input files
sequentially, read each, write to standard output.  For input files
provided as command line arguments, you can use <> magic to write this as

  print while <>;

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


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

Date: Wed, 22 Jul 1998 15:32:06 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: the low road
Message-Id: <68i5p6.ifb.ln@localhost>

John (jkramer@primenet.com) wrote:
: Hello,

   Hi.

: First of all I would like to say that I am new to the Newsgroup and still in
: the learning stages with perl too but I will do my best not to sound
: completely ignorant.  


   Refreshing attitude in these here parts.


   But you seem to have the same misconception that many newbies have.

   Folks *don't* (or shouldn't, anyway) mind when a newbie sounds
   completely ignorant.

   Ignorance is expected in newbies. We were all there at one time.

   What *is* objected to is asking a question that can be easily
   answered by a cursory word search of the docs that come with perl.


   Your question is not (obviously) of that type...


: As to my topic I was creating a database program using
: perl cgi when I encountered a problem.  It became necessary for form via an
: HTML page to pass information from a <textarea>.  The problem was I needed
: to remove the \n's and replace them with <BR>'s.  

  I assume that _adding_ a <BR> before the newlines will also
  be satisfactory. 

  Hundreds of chars on a single line offends my delicate sensibilities 
  (even when only machines read the file)   

  ;-)


: I opted to use the Split
: command to split at the \n's and then run a foreach loop to paste the <BR>'s
: in place.  True to TIMTOWTDI form after I finished I got to thinking that
: there might have been a better way.  Is it possible to set the Output Record
: Separator ($\) to <BR> 


   Yes.


: and if so how do you get it in before the data is
: passed from the form?


   You don't need it before the data is passed from the form.

   That is *in*put.


   The aptly named Output Record Separator only applies to *out*put  ;-)

   You need to set it before print()ing, not before getting the data.


: I have searched my stack of manuals and browsed till my eyes are falling out
: but I can't seem to find the answer.  It could be that I am looking in the
: wrong area's but I differ to the wisdom of the board.
                   ^^^^^^^^^^^^^^^^^^^^^^

   Don't do that. 

   There are lots of truly wise folks here, present company excepted.

   (BTW: it is a newsgroup, not a "board")

   Differing with them is most often foolish  ;-)


   I expect you meant to   s/differ/defer/;  ???


: Thank you,

   You're welcome.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 22 Jul 1998 16:27:32 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: the low road
Message-Id: <4gl5p6.kob.ln@localhost>

Tad McClellan (tadmc@flash.net) wrote:
: John (jkramer@primenet.com) wrote:

: : Thank you,

:    You're welcome.


Doh!

Forgot to include my code examples, with three ways to do it:


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

$textarea =<<ENDTEXT;
line one
line two
line three
ENDTEXT


### your current way, I assume
foreach (split /\n/, $textarea) {print "$_<BR>\n"}
print "\n\n";


### using the output record separator
{  # put it in a block so we don't have to set $\ back to normal

   local $\ = "<BR>\n";
   foreach (split /\n/, $textarea) {print}
}
print "\n\n";


### using a substitution
$textarea =~ s/\n/<BR>\n/g;
print $textarea;
-------------------



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 23 Jul 1998 00:04:54 +0200
From: "file" <file@job.to>
Subject: Re: the low road
Message-Id: <6p5ngu$lu2$1@usenet47.supernews.com>

A suggestion use the substitution command:

so...
$_ = $html_text;
$html_text =~ s/\\n/<br>/g;

good luck


John schrieb in Nachricht <6p57kc$mds$1@nnrp02.primenet.com>...
>Hello,
>
>First of all I would like to say that I am new to the Newsgroup and still
in
>the learning stages with perl too but I will do my best not to sound
>completely ignorant.  As to my topic I was creating a database program
using
>perl cgi when I encountered a problem.  It became necessary for form via an
>HTML page to pass information from a <textarea>.  The problem was I needed
>to remove the \n's and replace them with <BR>'s.  I opted to use the Split
>command to split at the \n's and then run a foreach loop to paste the
<BR>'s
>in place.  True to TIMTOWTDI form after I finished I got to thinking that
>there might have been a better way.  Is it possible to set the Output
Record
>Separator ($\) to <BR> and if so how do you get it in before the data is
>passed from the form?
>
>I have searched my stack of manuals and browsed till my eyes are falling
out
>but I can't seem to find the answer.  It could be that I am looking in the
>wrong area's but I differ to the wisdom of the board.
>
>Thank you,
>John
>
>
>
>




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

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

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