[7448] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1073 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 24 17:17:50 1997

Date: Wed, 24 Sep 97 14: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           Wed, 24 Sep 1997     Volume: 8 Number: 1073

Today's topics:
     Re: '0': string or number? you make the call! bholzman@bender.com
     Re: abs() function (Jason Gloudon)
     Re: Array or Hash? (Jason Gloudon)
     Re: cgi data <fearless@io.com>
     Re: Compiling perl 5.004_01 and failed sockets (Mark Doyle)
     Re: Ctrl-D can not works in Perl5 for Win95 <fearless@io.com>
     Re: Ctrl-D can not works in Perl5 for Win95 (Andrew M. Langmead)
     Re: dates and other oddities of time <russ@mail.org.uk>
     dir symlinks don't work? <michel.bartolone@med.ge.com>
     Ellipses in formats <achoy@us.oracle.com>
     Re: file flush <russ@mail.org.uk>
     Re: File name changing under NT <russ@mail.org.uk>
     Re: HELP How do I use perl <fearless@io.com>
     Re: help request <russ@mail.org.uk>
     Help! <cmpiep@maila.wm.edu>
     Re: How do I change a line in a file? <pshellum@awod.com>
     Re: Learning Perl (chap 2 q 4); I'm confused <jdavie2@umbc.edu>
     Re: Learning Perl (chap 2 q 4); I'm confused (Adam Rogoyski)
     Re: MIME Header "Location:" (Gerben Vos)
     Re: Need bulk Unix <-> PC file conversion <russ@mail.org.uk>
     Perl 5.003, DBI, DBD and Oracle question <acgator@erols.com>
     Re: perl mail on solaris (Neil Briscoe)
     Re: Perl to Java Compiler? (Jeff R. Stone)
     Re: perl under win95 problem <fearless@io.com>
     Re: Q: Getting user input without pausing <joshua@mongoose.demon.co.uk>
     Re: Regular Expressions <russ@mail.org.uk>
     Re: require 'sys/socket.ph' (Andrew M. Langmead)
     Re: Send mail with cgi on NT (Neil Briscoe)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 24 Sep 1997 13:34:45 -0600
From: bholzman@bender.com
Subject: Re: '0': string or number? you make the call!
Message-Id: <875124657.25383@dejanews.com>

In article <34283EEC.CD1@team-konzept.de>,
  andi@team-konzept.de wrote:
>
> In perl there are no datatypes like integer or string, they all are
just
> scalars. So there is no difference between assigning 0 or '0'. A
scalar

Actually, that's not technically correct-- Perl does know the
difference between a number and a string.  A scalar has three
"slots"-- one for an integer, one for a float, and one for a string.
(there's also a slot for references, although I think that reference
values and the other values cannot exist simultaneously--if someone
knows for sure, please correct me...)  Which one gets used in a given
context depends on just that--the context.  That's how $! can either
be used as an error number or as an error string.  Here's some
examples, using Devel::Peek--

(1)
bash$ perl -e 'use Devel::Peek; $a=0; Dump($a)'
SV = IV(0xb5914)
  REFCNT = 1
  FLAGS = (IOK,pIOK)
  IV = 0

(2)
bash$ perl -e 'use Devel::Peek; $a="0"; Dump($a)'
SV = PV(0xab414)
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0xaa930 "0"
  CUR = 1
  LEN = 2

(3)
bash$ perl -e 'use Devel::Peek; $a="0";0+$a; Dump($a)'
SV = PVNV(0xb54e0)
  REFCNT = 1
  FLAGS = (NOK,POK,pNOK,pPOK)
  IV = 0
  NV = 0
  PV = 0xaa930 "0"
  CUR = 1
  LEN = 2

(4)
bash$ perl -e 'use Devel::Peek; $a="foo";$a+=.1; Dump($a)'
SV = PVNV(0xb54e0)
  REFCNT = 1
  FLAGS = (NOK,pNOK)
  IV = 0
  NV = 0.1
  PV = 0xaa930 "foo"
  CUR = 3
  LEN = 4

So, in (1), $a contains _only_ an integer (IV).  In (2), $a contains
_only_ a string (PV). In (3), $a contains an integer, a float (NV) and
a string. (4) is the most interesting.  There are three 'distinct'
values in the three different slots-- the integer 0, the float 0.1,
and the string 'foo'.  What fascinating things you can learn using
Devel::Peek!

Hope this helps!

Benjamin Holzman

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


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

Date: 24 Sep 1997 18:05:40 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: abs() function
Message-Id: <60bkpk$3p8$1@daily.bbnplanet.com>

Helen Shen (helen@panix.com) wrote:
: In <yeon2l3zfmq.fsf@kudu.ind.tansu.com.au> Stuart Cooper <stuartc@ind.tansu.com.au> writes:

: >> $sNetExcep = ($NetLimit - abs($entityNet)) > 0 ? 
: >> 0 : ($NetLimit - abs($entityNet));
: >> 

: >$sNetExcep = (abs($entityNet) > $NetLimit);

: does this return the actual value of (abs($entityNet) > $NetLimit)?
: is there a better way to do that (return the actual value or return zero)
: than the way i did it originally?

: ps - my mistake was two statement later when i did this:

: $sNetExcep = "-$sNetExcep"  if (($dStratNet > 0) && ($sNetExcep < 0));
More general comment :

The quotes "" around -$sNetExcep are unncessary.
You shouldn't make a number look like a string unless you want a string,
cause you're forcing Perl to do unnecessary conversions and string operations.
Besides, it looks neater(not a real reason).

: i shouldn't have put -$sNetExcep in quotes.

Jason Gloudon


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

Date: 24 Sep 1997 18:14:46 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: Array or Hash?
Message-Id: <60blam$3p8$2@daily.bbnplanet.com>

Andy Smith (asmith@hsonline.net) wrote:
: Why is perl trying to make a hash out of @services? Is there something i
: need to do to make it see the variable as an array instead?

: --------------------

: @services={"witha","smile","anda","one","two",};
            -                                   -
The underlined { } are your problem. They are creating a reference to the
array. You want ().


: ----Andy Smith ------  reply to:  ----------------
:      -KB9KQD-       (asmith@hsonline.net)

Jason Gloudon


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

Date: Wed, 24 Sep 1997 11:35:49 -0700
From: "Creede Lambard" <fearless@io.com>
Subject: Re: cgi data
Message-Id: <60bmsv$ifc@news.microsoft.com>

Try this ($id is the ID number you're checking for):

open (DATA,"data.txt");
read (DATA,$s,(-s DATA));
close DATA;

if ($id =~ /$s/) { . . . code to execute if ID matches . . . }

$s contains your entire data file, newlines and all, so if your ID is
1234567890, you won't get a match on the off chance you have ID numbers like
this:

5842012345
6789053256

There might be better ways to do it. There might be faster ways to do it.
But as you'll see if you work with Perl for any length of time, There's
Always More Than One Way To Do It (TM).

-- Creede

>asmr wrote:
>
> Under normal circumstances I would take the time to learn how to do this
> myself, but unfortunately time constraints have forced me to get a
> project done as quickly as possible.
>
> I'm creating a perl script that will allow users to access information,
> as long as the identification number entered is valid.  I have a list of
> the valid id numbers in a file, and the data is structured as follows:
>
> 123456789
> 234567891
> 098765432
>
> and so on for a list of aprox. 200 numbers.  I need to check the user
> input of their ID and see if it appears in the data file.  If anyone
> could crank out the few lines of code I need it would save me a
> considerable amount of time.  (to make things easier to explain, i've
> called the user entered id number "input{'id'}"  and the data text file
> "data.txt")
>
> Thanks in advance! :)
> Allison Conover
> conov@hotmail.com





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

Date: 24 Sep 1997 17:33:54 GMT
From: doyle@aps.org (Mark Doyle)
Subject: Re: Compiling perl 5.004_01 and failed sockets
Message-Id: <60biu2$pu2$1@sun20.ccd.bnl.gov>

doyle@aps.org (Mark Doyle) wrote:

>We are trying to compile perl 5.004_01 on a Sequent machine running
>Dynix/ptx  4.2.1  -- everything seems to go fine but during make test, the
>following  three errors occur:

[errors about failed socket calls deleted]

The solution turned out to be to define the following environment variable:

_SEQUENT_CC_=-Wc,+abi-socket 

before compiling. Thanks to Phil Hoggins from Sequent for the hint.

Cheers,
Mark



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

Date: Wed, 24 Sep 1997 09:17:42 -0700
From: "Creede Lambard" <fearless@io.com>
Subject: Re: Ctrl-D can not works in Perl5 for Win95
Message-Id: <60beq5$s8@news.microsoft.com>

I tried this just now under US Windows NT 4.0 (probably close enough to 95
for our purposes) and got something similar, a diamond character in the
console. If you use ^Z, however, it terminates the input. This is probably
because DOS, and therefore PC-compatible Perl, regards ^Z as an end-of-file
character (and I think ^D is the Unix equivalent).

Herman wrote in message <01bcc8ea$d0cb0600$56fc3cca@default>...
>I am running Perl5 under Chinese Windows 95. When I assign a array like
>that :
>
>@string = <STDIN>
>
>Normally, the input from keyboard can be terminated by Ctrl-D.
>However, it (I mean ^D) doesn't work in Chinese Windows 95 but displays the
>character of Ctrl-D (look like a small square) on screen and treats the
>Ctrl-D as a input key.
>
>Can anybody tell me why and how can I terminated the input besides pressing
>Ctrl-D in Chinese Win95/English Win95?
>
>Herman
>




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

Date: Wed, 24 Sep 1997 20:01:40 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Ctrl-D can not works in Perl5 for Win95
Message-Id: <EH13Ms.Lx0@world.std.com>

"Herman" <herman-law@usa.net> writes:

>Can anybody tell me why and how can I terminated the input besides pressing
>Ctrl-D in Chinese Win95/English Win95?

MS-DOS and Windows '95 use Control-Z to mean End Of File. It usually
needs the enter key hit after the control-z.

C:\TMP>copy con control-z.txt
I'm copying from standard input to a file called
control-z.txt. When I'm done, I'll hold
down the Control key and hit the letter Z
followed by the enter key
^Z
        1 file(s) copied


-- 
Andrew Langmead


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

Date: Wed, 24 Sep 1997 14:27:17 +0100
From: Russell Odom <russ@mail.org.uk>
Subject: Re: dates and other oddities of time
Message-Id: <34291535.6F552C18@mail.org.uk>

Nate Riggs wrote:
> 
> Sorry, I'm a newbie at perl.  Is there a function to retrieve the date?

RTFM.

In this case, TFM to R is 'perldoc -f time', and carry on from there.

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Wed, 24 Sep 1997 15:21:32 -0500
From: Michel Bartolone <michel.bartolone@med.ge.com>
Subject: dir symlinks don't work?
Message-Id: <3429764C.6F59@med.ge.com>

Using perl 5.003 with EMBED on an origin 200 (sgi IRIX64)
server, using the command:

symlink("$dir","$link");

with the $dir and $link variables set properly doesn't seem to
work! (I could still be misunderstanding something here.)

This call does create a symlink, or at least a directory
entry that LOOKS like a symlink, but if you attempt to cd to
the symlink, it fails. At first I thought I was doing something
wrong, but when I changed my script to use:

system('ln','-s',"$dir","$link");

I was able to cd into the symlink and I was in the proper directory.

Has anyone else seen this? Is it a known bug?

To test it use this code:

#! /usr/local/bin/perl # <or whatever your perl path is>

mkdir("test.dir",0777);
symlink('test.dir','symlink,dir');
system('ln','-s','test.dir','systemln.dir');


after running it verify that you have test.dir with two different
symlinks to it. Then try to cd into each.


-- 
Michel Bartolone
michel.bartolone@med.ge.com or bartolon@execpc.com
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Lead me not into temptation, I can find it myself.


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

Date: Wed, 24 Sep 1997 11:55:18 -0700
From: Allen Choy <achoy@us.oracle.com>
Subject: Ellipses in formats
Message-Id: <34296216.748B@us.oracle.com>

Hi.

The Camel book mentioned that the $: variable is used to do
ellipses in formats but it doesn't say how.  I didn't find any doc 
about this in the FAQs either.

Can some give me a brief tutorial about using this?  I just want
to enable this feature on specific fields.

Thanks in advance,

Allen


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

Date: Tue, 23 Sep 1997 19:40:37 +0100
From: Russell Odom <russ@mail.org.uk>
Subject: Re: file flush
Message-Id: <34280D25.51B0AD20@mail.org.uk>

Lefteris Xanthoudakis wrote:
> 
>  Hi all,
> 
>     I'm new to Perl and writting a little script which creates a log. I
> opened a filehandle to a log file like ">>script.log" and everything works
> fine. The script though doesn't update the file line by line before it
> finishes or the buffer runs out so "tail -f script.log" doesn't work well.
> Is there a file-flush function in Perl.

Try...

$oldhandle = select(FILEHANDLE);
$| = 1;
select($oldhandle);

See 'perldoc perlvar' for more info on $|

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Wed, 24 Sep 1997 14:28:52 +0100
From: Russell Odom <russ@mail.org.uk>
Subject: Re: File name changing under NT
Message-Id: <34291594.F8E6119A@mail.org.uk>

Andrew wrote:
> 
> I am writing a program to convert from one file format to another.  The
> perl program is invoked by another program, which just passes it the input
> filename on the command line.
> 
> I want to take the input filename, strip off the extension, and then put a
> new one on.  I've included my solution below.  It works, but I want to know
> how I could have done it better.
>
> #! /usr/bin/perl
   ^^^
No space here, not that it matters on an NT system.

> $input = $ARGV[0];
> $output = $input;               # Get input filename from command line
> while ($strip ne ".")           # Keep removing characters from the end of the
>                                 # filename until
>     {                           # the file extension is gone
>     $strip = chop($output);
>     }
> $output = ">" . $output . ".txt";

Rather than adding the '>' here, do it when you do the open().

Try...

#!perl -w
$output = $input = $ARGV[0];          # Get name from command line
($output !~ /\./) and $output .= '.'; # Special case for files with no extension
$output =~ s/(.*)\..*?$/$1.txt/;      # Do a substitution

open (FILE, ">$output") or die ("AAAaaaaaaargh!");

__END__

This does the following conversions...
'test'         -> 'test.txt'
'test.'        -> 'test.txt'
'test.abc'     -> 'test.txt'
'test.abc.'    -> 'test.abc.txt'
'test.abc.xyz' -> 'test.abc.txt'

Note that there's no checking that the command line argument exists and 
is valid, but I'm not doing it all for you ;-)

HTH,
 
Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------



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

Date: Wed, 24 Sep 1997 11:20:29 -0700
From: "Creede Lambard" <fearless@io.com>
Subject: Re: HELP How do I use perl
Message-Id: <60bm07$ktl@news.microsoft.com>

Here's how I got started. This explains how to put a counter into your web
page. It works for accounts on io.com; whether it works for your particular
provider depends. Some providers won't let you run a CGI script (even one as
simple as a counter) unless they review it first.

http://www.io.com/help/helpdesk/counter.html

Follow the instructions carefully, including making your home page
executable, making sure your script name ends in .cgi, etc.

IO's helpdesk also has pointers to some good tutorials on CGI. And finally,
check your local bookstore (or an online store like amazon.com) for books on
Web programming with Perl5. It really is about the best thing to come along
since sliced bread.

> I have absoluely no idea how to get started on perl. I made a pl file,
> made it executible by the chmod parameter, and then what the hell am I
> supposed to do. I have the 1st. edition of the Ilama book, and I
> couldn't find the answer to it. I thought I could write some CGI stuff
> with perl, but I have no idea how it works. I tried to open the file
> with Netscape and it treated the .pl file that I had written as a text
> file and showed the source. What the hell am I supposed to do now?





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

Date: Tue, 23 Sep 1997 16:43:48 +0100
From: Russell Odom <russ@mail.org.uk>
Subject: Re: help request
Message-Id: <3427E3B4.9459933@mail.org.uk>

Leo Kerner wrote:
> 
> Can anybody explain the first lines in page 95 of Randal Schwartz's
> "Learning Perl"? It says that asfer a successful pattern match
> $1, $2,... are set to \1, \2,... I don't see an explanation as to what
> \1, \2,... are.

Thery're backreferences to sets of parentheses in your regexp. For
example...

s/(x|y|z)abc\1/wibble/

 ...will replace the strings 'xabcx', 'yabcy' or 'zabcz' with the string
'wibble'. But it will not replace say 'xabcz'. The \1 means 'whatever the
value of the first set of parentheses was' - (x|y|z) in this case.
Similarly \2 refers to the second set of parentheses, etc.

If you want, you can use $1, $2, etc in the second half of a 's///'
regexp...

s/(x|y|z)abc\1/$1wibble$1/

 ... which replaces 'xabcx' with 'xwibblex', etc.

Actually, I've just looked in the Llama book (1st ed), there's an
explanation starting at the bottom of p88 - 'Parentheses as memory'.

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: 24 Sep 1997 18:58:51 GMT
From: "Christopher Pieper" <cmpiep@maila.wm.edu>
Subject: Help!
Message-Id: <01bcc91c$50e9d420$84cbef80@chris.resnet.wm.edu>

I am a beginner when it comes to the perl language and well I have already
been asked to write my first program to help out a professor. Anyway he
wants me to write a script that will convert a whole group of files located
within a large and complex directory tree from text files to html.
Basically he has a ton of files spread out over several directories and he
wants be to put the appropriate html tags in front and at the end of these
documents and then rename the final file to include the html extension. Now
I know how to change the file but it is the process of going through all
the files in a directory and then switching directories that has me
baffled. I know that I could find it in my newly acquired text "Programming
Perl" by Orielly, however I just can't seem to find it amongst the other
stuff.

Please help a blind man out! (That is just figurative by the way!)

Chris


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

Date: Wed, 24 Sep 1997 16:01:06 -0400
From: Paul Shellum <pshellum@awod.com>
Subject: Re: How do I change a line in a file?
Message-Id: <34297182.38C@awod.com>

Chocolate wrote:
> 
> How do I change a line in a file from a web page?  I have this database
> file and there is one entry per line.  If the password is correct then
> the entry appears and you can edit it.  The only thing is how do I
> replace the old entry with the new one.  I don't want to replace the
> whole file just the line that matches the password.  How do I do this
> using perl?

You could modify the script that is retrieving the data from the
database and add code to do an update to the database if data is
modified and the modify button is pressed.  The exact syntax varies from
database to database.


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

Date: Wed, 24 Sep 1997 14:09:24 -0400
From: Jim Davies <jdavie2@umbc.edu>
Subject: Re: Learning Perl (chap 2 q 4); I'm confused
Message-Id: <34295754.2EAB@umbc.edu>

Dana,

	The problem with the second is one of you confusing perl with the
context.  There is an x operator that can be used to make something
repeat.  This is what is happening in your second case.  The context of
the first case is clear such that perl will interpret it as the
multiplication operator.  At least that's my guess:>


			Jim
Dana Anthony wrote:
> 
> Why does this work:
> 
>   print "Type a number: ";
>   $number = <STDIN>;
>   print "Type a phrase: ";
>   $phrase = <STDIN>;
>   $C =  ($phrase x $number);
>   print $C;
> 
> and this doesn't:
> 
>   print "Type a number: ";
>   $number = <STDIN>;
>   print "Type a phrase: ";
>   $phrase = <STDIN>;
>   print  ($phrase x $number);
> 
> but returns this error:
> 
>   Can't call method "x" without a package or object
>   reference at   list1.perl line 6, <STDIN> chunk 2.
> --
> Dana Lynne Goldblatt Anthony
> Internet Publications Technology at SAS Institute
> World Headquarters Cary, NC, USA


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

Date: 24 Sep 1997 19:32:45 GMT
From: ifqa242@spice.cc.utexas.edu (Adam Rogoyski)
Subject: Re: Learning Perl (chap 2 q 4); I'm confused
Message-Id: <60bpst$b1b$2@geraldo.cc.utexas.edu>

Dana Anthony (daanth@unx.sas.com) wrote:
: Why does this work:


:   print "Type a number: ";
:   $number = <STDIN>;
:   print "Type a phrase: ";
:   $phrase = <STDIN>;
:   $C =  ($phrase x $number);
:   print $C;



: and this doesn't:

:   print "Type a number: ";
:   $number = <STDIN>;
:   print "Type a phrase: ";
:   $phrase = <STDIN>;
:   print  ($phrase x $number);

: but returns this error:

:   Can't call method "x" without a package or object 
:   reference at   list1.perl line 6, <STDIN> chunk 2.
: -- 
: Dana Lynne Goldblatt Anthony
: Internet Publications Technology at SAS Institute
: World Headquarters Cary, NC, USA
  For me perl -c says OK and both run the same, printing phrase Number
times.
--
           __/\__.           [-Temperance-]              .__)\__
      !    \ oO /         . :[Adam Rogoyski]: .           \ oO /    !
      .    /_\/_\       .  :[ apoc@laker.net ]:  .        /_\/_\    . 
             \/    .  :[ http://www.laker.net/apoc ]:  .    \/


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

Date: 24 Sep 1997 20:10:29 GMT
From: gerben@cs.vu.nl (Gerben Vos)
Subject: Re: MIME Header "Location:"
Message-Id: <60bs3l$htf$1@star.cs.vu.nl>

"S. Steven Maese" writes:

>I'm new to PERL, sorry if this is a more than obvious question, but....

This is more of a CGI question, so i've crossposted this to
comp.infosystems.www.authors.cgi . By the way, comp.lang.perl does
not exist anymore (in most computers' idea of Usenet). You should
be able to get by with posting to just comp.lang.perl.misc .

Anyway:

>sub redir {
>	print "Location: http://www.csolutions.net/index.html\n\n";
>}

>The above code is intended to redirect a browser to the above listed web
>page.  This works with IE 3.02, but with Navigator 4.01 I get "Document
>contains no data."  Any ideas?

I don't know, but maybe Navigator wants some data in your document,
not just headers?
Try

:	print "Location: http://www.csolutions.net/index.html\n\nYou should not see this page. Please go <a href=\"http://www.csolutions.net/index.html\">here</a>.\n";

Or, better formatted,

:	print <<END_OF_TEXT;
:Location: http://www.csolutions.net/index.html
:
:You should not see this page.
:Please go <a href="http://www.csolutions.net/index.html">here</a>.
:END_OF_TEXT

This is also nicer for the few people using (outdated) browsers that
don't support the Location: header.

g e r b e n @ c s . v u . n l . . . . . . . . . . . . G e r b e n   V o s   <><
Join the Coalition Against Unsolicited Commercial Email!  http://www.cauce.org/
Men... the second-most confused group in our culture... after teenagers.
  -- from John Mark Ministries' seminar on manhood


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

Date: Tue, 23 Sep 1997 16:28:26 +0100
From: Russell Odom <russ@mail.org.uk>
Subject: Re: Need bulk Unix <-> PC file conversion
Message-Id: <3427E01A.298CEDC8@mail.org.uk>

Dave Schenet wrote:
> 
> Ron Savage (rpsavage@ozemail.com.au) wrote:
> 
> [How do I convert DOS CR-LF to UNIX LF?]
> 
> This works for me, and I'm sure there's a more elegant way of
> doing it.
> 
> open (INPUT, "<dosfile");
> open (OUTPUT, ">unixfile");
> while (<INPUT>) {
>   $_ =~ s/^M//;
>   print (OUTPUT $_);
> }
> close (INPUT);
> close (OUTPUT);
> 
> The ^M needs to be literal, for example in vi, you would actually
> type ^V^M to get a literal ^M. I'm not sure how to accomplish this
> in a DOS editor, though. IOW, it's a literal control-m, not a
> shift-6 capital-M.

Rather than a literal control-M in the above regexp, use either \cM or \r
- it'll avoid possible problems like the char being removed or changed if
you ftp the source to another machine, it's (usually) easier to type, more
readable if your editor doesn't display control chars correctly, isn't
misinterpreted as an end of line on some systems, etc.

Oh, and don't forget to check the return value from open()...

open (INPUT "$dosfile") or die ("AAAAAAAAaaaaargh, can't open DOS file");

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Wed, 24 Sep 1997 15:52:06 -0400
From: ErnieCee <acgator@erols.com>
Subject: Perl 5.003, DBI, DBD and Oracle question
Message-Id: <34296F66.138F@erols.com>

I have a question about a problem I have been running into using Perl
5.003 on a DEC Alpha machine w/UNIX 3.2C, DBI version 0.79 abd
DBD::Oracle version 0.44 with Oracle 7.2.2.3.

My problem stems from trying to run perl scripts that read in large data
files, process several edit checks on each data record, insert the
record into a temporary oracle table with no constraints.  Then perform
validations of the primary and foreign key values in the temp table, and
finally copy over all valid rows to the permanent database schema table.

I dont seem to have any problems when testing with a small amount of
records, but when run with a large amount of records (25,000), the
script crashes and gives an error ORA-04031, which states the database
is unable to allocated enough memory to perform the indicated SQL
statement.

Do I have a major flaw in design?  Has anyone seen this problem before?
Has anyone ever experienced memory problems when trying to run large
sequential batch processes?  The Oracle DBA indicates that the
shared_memory_pool is set at more than enough to process large numbers
of records and the problem lies in my code, but I am unsure.  Any help
would be most appreciated.

Any replies may be posted here or sent direct to me at
aron_ceely@notes.pw.com

Thanks


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

Date: 24 Sep 1997 19:09:25 GMT
From: neilb@zetnet.co.uk (Neil Briscoe)
Subject: Re: perl mail on solaris
Message-Id: <memo.19970924200926.23605E@skep.compulink.co.uk.cix.co.uk>

In article <60b9vf$fv6$3@info.uah.edu>, gbacon@adtran.com (Greg Bacon)
wrote:

> [Posted and mailed]
>
> In article <memo.19970924062231.21497A@skep.compulink.co.uk.cix.co.uk>,
> 	neilb@zetnet.co.uk (Neil Briscoe) writes:
> : The quick solution to this is to use
> : open (DOMAIL, "| mail -s \"${MailSubject}\" $Mailto");
>
> That breaks when the shell peers through its beady little eyes, sees
> a shiny trinket like a $, and goes to grab it.  Better to use single
> quotes:
>
>     open DOMAIL, "| mail -s '${MailSubject}' $Mailto"
>         or die "$0: Failed fork: $!\n";
>
> because it works with single- or multi-word subjects.
>

Yes, you're quite right.  I wasn't quite awake when I wrote it, and
considered single quotes.  I remember quite clearly thinking "if its
single quotes, it won't expand the value of $MailSubject" when, of course,
being inside the outer quotes, it would have been fine.

Moral: Don't post "helpful" advice when you've only just got up. ;-))

Regards
Neil



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

Date: 24 Sep 1997 14:49:22 -0400
From: jstone@america.net (Jeff R. Stone)
Subject: Re: Perl to Java Compiler?
Message-Id: <l6raae1r9p.fsf@transquest1.delta-air.com>

Tom Phoenix <rootbeer@teleport.com> writes:

> 
> On 23 Sep 1997, Jonathan Thornburg wrote:
> 
> > We should realise, though, that p2j would have one significant
> > benefit -- allowing Perl programs to run on platforms which have
> > Java installed but don't have Perl installed.  To the extent that
> > Java takes off, this might be a lot of platforms.
> 
> Perl runs on more platforms than Java does. And always will. :-)
> 
> -- 
> Tom Phoenix           http://www.teleport.com/~rootbeer/
> rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
> Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
>               Ask me about Perl trainings!
> 


Tom,

It all depends on your definition of "platform".  Java is in the
process of working (seeping?) its way into all sorts of smart cards
and other embedded devices that are unlikely to support Perl in its
current incarnation.

Jeff

-- 
| Jeff Stone <jstone@america.net>                          |



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

Date: Wed, 24 Sep 1997 09:33:44 -0700
From: "Creede Lambard" <fearless@io.com>
Subject: Re: perl under win95 problem
Message-Id: <60bfo3$ip9@news.microsoft.com>

It's probably simpler than that. Go to your Start button and choose the
Documents option. You'll most likely find a reference to a document there
that was at one time read from A:

The solution? Do a Find / Files and Folders for that document. That should
give you a path to a folder called something like Recent. (This varies
depending on whether you're on your own machine or one that has several user
profiles on it. Try C:\Windows\Recent) This folder is full of shortcuts to
documents you would have opened recently (or maybe not so recently). Drag
and dump these shortcuts straight to the Recycle Bin.

Additionally, you might want to download a little utility called TweakUI
from Microsoft's web site. There's an option in there called "Paranoia" that
allows you to set an option to clear the Documents folder (and the IE cache,
and a couple other things). Look for a package called "Power Toys."

-- Creede

Tom Phoenix wrote in message ...
>On Wed, 24 Sep 1997, Felix Ng wrote:
>
>> Everytime i run (perl my.pl) the program will seek my floppy drive first
>> before giving me the result.... why and how to solve ?
>
>Almost certainly, there's something in the registry which references A:
>unnecessarily. Hope this helps!
>
>--
>Tom Phoenix           http://www.teleport.com/~rootbeer/
>rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
>Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
>              Ask me about Perl trainings!
>




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

Date: Wed, 24 Sep 1997 19:52:42 +0100
From: the joshman <joshua@mongoose.demon.co.uk>
Subject: Re: Q: Getting user input without pausing
Message-Id: <3429617A.1A8759B@mongoose.demon.co.uk>

Mike Stok wrote:
> 
> the joshman  <joshua@mongoose.demon.co.uk> wrote:
> >How do I get input such as $foo = <STDIN> without the
> >program pausing?  This problem may be even worse for me
> >as I am using Win95.  Hopefully any solution will also
> >apply to sockets.
> 
> section 5 of the new perl FAQ (Files and Formats) contains this which may
> be part of a solution, there are other suggestions in that section of the
> FAQ too.
> 
> How can I tell if there's a character waiting on a filehandle?
> 
>    You should check out the Frequently Asked Questions list in
>    comp.unix.* for things like this: the answer is essentially the same.
>    It's very system dependent. Here's one solution that works on BSD
>    systems:
>    You should look into getting the ReadKey extension on CPAN.

Thanks, that's a step in the right direction.  I guess I should
be asking, has anyone done this in Win95?


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

Date: Tue, 23 Sep 1997 20:21:02 +0100
From: Russell Odom <russ@mail.org.uk>
Subject: Re: Regular Expressions
Message-Id: <3428169E.7FE73EA1@mail.org.uk>

Scott Cullen wrote:
> 
> I have some lines of HTML that always begin with a <P> and a <B> tag.
> These tags are then followed by a couple of words, then the next line is
> always a single word. It look like this:
> 
> <P><B>Arts & Entertainment
> Clemson
> 
> I need to add a <BR> tag after Entertainment (which I have already
> done). My problem is I also need to add a <BR> tag after Clemson. I'm
> having trouble using Perl's Regex to, in layman's terms, "always put a
> <BR> after the last word on the next line after a line that begins with
> a <P><B> tag.

s/		# Substitute a string which...
    (<P><B>.*?)	# ...starts with <P><B> then some stuff
    \n		#    which ends with a newline...
    (.*?)	# ...followed by more stuff
    \n		#    which ends with a newline...
/		# ...with...
    $1		# ...the first lot of stuff we got...
    <BR>\n      # ...plus a <BR> and the newline which was there before...
    $2		# ...then the second lot of stuff...
    <BR>\n	# ...then a <BR> and the newline which was there before.
/x;		# Oh, and allow comments in the regexp (may need more 
		#  modifiers here).

Or written as one line...

s/(<P><B>.*?)\n(.*?)\n/$1<BR>\n$2<BR>\n/;

This does the whole lot for you, I hope. (I'm off to the pub so I haven't
got time to test it :-)

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Wed, 24 Sep 1997 19:56:25 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: require 'sys/socket.ph'
Message-Id: <EH13E1.I4u@world.std.com>

Benarson Behajaina <Benarson.Behajaina@swh.sk> writes:

>Running this script:
>prompt% cache-compare.pl
>Can't locate sys/socket.ph in @INC (did you run h2ph?)

>So my question is: where can I find this socket.ph ?

sys/socket.ph is created by running the h2ph command on
/usr/include/sys/socket.h and then having someone knowledgeable in C
fix up the resulting mess. (h2ph is a mechanical translation of the C
header file. There are many constructs it can't handle correctly.)
-- 
Andrew Langmead


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

Date: 24 Sep 1997 19:09:27 GMT
From: neilb@zetnet.co.uk (Neil Briscoe)
Subject: Re: Send mail with cgi on NT
Message-Id: <memo.19970924200927.23605F@skep.compulink.co.uk.cix.co.uk>

In article <342934D2.F50D5A08@voigtgmbh.de>, kosthoff@voigtgmbh.de (Kai
Osthoff) wrote:

> Hi!
>
> I just started programming in Perl, now i need help ... :)
>
> How can I send a filled form with CGI to a specify eMail-Adress ?
>
> I found a few script, but they doesn't work on my server?
>
> At Unix-Systems perl's use often SENDMAIL ... what must i use on
> WindowsNT ?
>

Well, you can either purchase Metainfo's NT Port of Sendmail and then most
scripts will work unchanged, or, you can have a free copy of my smtp.pl.

The latter was hacked from the work of Graham Barr's smtp.pm - which I
never could get to work under NT.

With that, all you need is access to some smtp server somewhere, and you
can send mail from your NT based CGI's to your hearts content.

If you want a copy, send me a mail.

Regards
Neil



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

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

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