[11931] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5531 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 30 19:07:19 1999

Date: Fri, 30 Apr 99 16:00:18 -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, 30 Apr 1999     Volume: 8 Number: 5531

Today's topics:
    Re: "learning perl" does not seem to be written well (I R A Aggie)
    Re: "learning perl" does not seem to be written well (Ben Coleman)
    Re: "learning perl" does not seem to be written well (Ben Coleman)
        Can perl download html files? <"ashi mg"@qualcomm.com>
        Can perl download html files? <"ashi mg"@qualcomm.com>
        Can perl download html files? <"ashi mg"@qualcomm.com>
    Re: Concatenating files with PERL <tchrist@mox.perl.com>
    Re: Concatenating files with PERL <ebohlman@netcom.com>
    Re: copy file  <tchrist@mox.perl.com>
    Re: copy file (Bob Trieger)
    Re: copy file <tchrist@mox.perl.com>
    Re: create directory with perl script? <tchrist@mox.perl.com>
    Re: create directory with perl script? <tchrist@mox.perl.com>
    Re: Executing Perl code within print structure... <tchrist@mox.perl.com>
    Re: Executing Perl code within print structure... <design@raincloud-studios.com>
    Re: Executing Perl code within print structure... <ebohlman@netcom.com>
    Re: Global Filehandle ? <tchrist@mox.perl.com>
    Re: Instance Data / Instance Variables <tchrist@mox.perl.com>
        need help on archiving files using perl and tar <ilinlee@fox.CS.Berkeley.EDU>
    Re: Newsfeed and Local Weather <tchrist@mox.perl.com>
    Re: Newsfeed and Local Weather (I R A Aggie)
    Re: NT Perl vs UNIX Perl <cassell@mail.cor.epa.gov>
        Problems with sockets <rconner@mail.intrix.com>
    Re: search string syntax <ebohlman@netcom.com>
    Re: single quotation " erases REST OF TEXT <ebohlman@netcom.com>
        Using perl to set permissions when chown is blocked <design@raincloud-studios.com>
    Re: Using perl to set permissions when chown is blocked <tchrist@mox.perl.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 30 Apr 1999 22:18:50 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <slrn7ikb77.ov3.fl_aggie@stat.fsu.edu>

On 30 Apr 1999 17:49:13 -0400, David H. Adler
<dha@panix.com>, in <slrn7ik9ao.6fg.dha@panix.com> wrote:
+ On Thu, 29 Apr 1999 19:47:29 GMT, birgitt@my-dejanews.com
+ <birgitt@my-dejanews.com> wrote:

+ >All nice and good, but the basic problem is that even Larry Wall pointed
+ >out that Perl should not be used as the first programming language to learn.

+ comment.  I'd be interested to see your source.

Probably Randal. I made a statement very similar to Birgitt, once, and
Randal objected, and that made me think about it. After consideration,
I realized he's right. Perl is powerful, and perl doesn't enforce good
programming practice. Both those things allow good programmers to do
miraculous things.

But they can be extraordinarily deadly to a novice who hasn't learned
the discipline necessary to self-impose good programming practices.

My take on it is: Perl will cheerfully hand you every inch of rope
necessary to hang yourself and your system.

James - it's just up to you not to wrap that rope around your neck...


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

Date: Fri, 30 Apr 1999 22:29:34 GMT
From: tnguru@termnetinc.com (Ben Coleman)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <372a2e8e.91572774@news.mindspring.com>

On Wed, 28 Apr 1999 09:48:19 -0700, David Cassell
<cassell@mail.cor.epa.gov> wrote:

>Ah yes.  For fun, try to say "I am full" after eating with a European.
>The literal translation is (in several languages) a euphemism for
>"I am pregnant."  Oops!  

Or saying "I am hot" in French.  The literal translation means something
more like "I'm in heat".

Ben
-- 
Ben Coleman
Senior Systems Analyst
TermNet Merchant Services, Inc.
Atlanta, GA


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

Date: Fri, 30 Apr 1999 22:39:46 GMT
From: tnguru@termnetinc.com (Ben Coleman)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <372a30b2.92120261@news.mindspring.com>

On Mon, 26 Apr 1999 19:22:46 GMT, ralawrence@my-dejanews.com wrote:

>I've now made a total tit out of myself infront of 16 million odd people.

IME, that's a normal part of the online experience, and has been from the
days of BBSs and the old online services.  Don't worry about it.

Ben
-- 
Ben Coleman
Senior Systems Analyst
TermNet Merchant Services, Inc.
Atlanta, GA


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

Date: Fri, 30 Apr 1999 15:52:39 -0700
From: Ashim <"ashi mg"@qualcomm.com>
Subject: Can perl download html files?
Message-Id: <372A3437.4403E212@qualcomm.com>

Hi
   Is there any way to write a perl script which can take a URL as input
and download it into a file? Just something that can surpass Netscape.

Thanks
Ashim



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

Date: Fri, 30 Apr 1999 15:53:58 -0700
From: Ashim <"ashi mg"@qualcomm.com>
Subject: Can perl download html files?
Message-Id: <372A3486.C2032EB5@qualcomm.com>

Hi
   Is there any way to write a perl script which can take a URL as input
and download it into a file? Just something that can surpass Netscape.

Thanks
Ashim



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

Date: Fri, 30 Apr 1999 15:56:14 -0700
From: Ashim <"ashi mg"@qualcomm.com>
Subject: Can perl download html files?
Message-Id: <372A350E.B85390EC@qualcomm.com>

Hi
   Is there any way to write a perl script which can take a URL as input
and download it into a file? Just something that can surpass Netscape.

Thanks
Ashim



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

Date: 30 Apr 1999 16:11:14 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Concatenating files with PERL
Message-Id: <372a2a82@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, ratpfink@akamail.com (Rat Pfink) writes:
:It's just that nobody that uses NT/95/98 these days knows
:their way around a command prompt...

Those who ignore Unix are doomed to repeat it -- badly.

--tom
-- 
    I think I'm likely to be certified before Perl is...  :-) 
	--Larry Wall in <1995Feb12.061604.6008@netlabs.com>


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

Date: Fri, 30 Apr 1999 22:46:06 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Concatenating files with PERL
Message-Id: <ebohlmanFB0xwu.L4n@netcom.com>

Tom Christiansen <tchrist@mox.perl.com> wrote:
:  [courtesy cc of this posting sent to cited author via email]

: In comp.lang.perl.misc, 
:     "psychout" <psychout@pacbell.net> writes:
: :I'm new to PERL and trying to figure out how to use PERL to concatenate 3
: :files together into one file on an NT system. Can anyone help me?

: Man, it sure sucks to be screwed out of proper tools, doesn't it?

:     % cat f1 f2 f3 > f4

: Go to http://language.perl.com/ppt/ to get a set of Perlian replacement tools
: for those poor unfortunates such as yourself. :-)

Or just use 'copy /b f1+f2+f3 f4'.



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

Date: 30 Apr 1999 16:34:21 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: copy file 
Message-Id: <372a2fed@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    cpl11@netcom.ca writes:
:I also look for a command which enable perl script to copyone file to
:another directory

You haven't read the documentation lately, have you?  Can't you roll
your own?  Shell out to the system?  Read perlfunc?  Think a little?
Try a module?

Sigh.

Here is a list of places to find examples of Perl code:

    ftp://ftp.oreilly.com/published/oreilly/perl/cookbook/
    http://language.perl.com/ppt/
    http://www.perl.com/CPAN-local/authors/id/TOMC/scripts/

There's a lot more, too.  Look around on CPAN and the various 
perl.com sites.

You should also read the documentation that comes with Perl 
on your very own system.   The manpages and faqs are where you
should start.  You have them.  Please tell us what you don't 
understand in them.

--tom
-- 
    :  I've heard that there is a shell (bourne or csh)  to perl filter, does
    :  anyone know of this or where I can get it?
    Yeah, you filter it through Tom Christiansen.  :-)  --Larry Wall


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

Date: Fri, 30 Apr 1999 22:36:49 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: copy file
Message-Id: <7gdakv$8q8$1@ash.prod.itd.earthlink.net>

[ courtesy cc sent by mail if address not munged ]
     
cpl11@netcom.ca wrote:
>Dear Friends
>I also look for a command which enable perl script to copyone file to
>another directory


If you have written such a script, the command which will enable it is:

chmod 500 script.pl


Good luck,



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

Date: 30 Apr 1999 16:48:44 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: copy file
Message-Id: <372a334c@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, sowmaster@juicepigs.com (Bob Trieger) writes:
:If you have written such a script, the command which will enable it is:
:
:chmod 500 script.pl

What is this 500 stuff?  You'll probably find 0755 much more useful
in most cases.

--tom
-- 
If you are not part of the solution, you are part of the precipitate.


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

Date: 30 Apr 1999 16:28:48 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: create directory with perl script?
Message-Id: <372a2ea0@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    cpl11@netcom.ca writes:
:How to use perl script to creat a directory

You read the perlfunc documentation which comes with your
system and enumerates the list of standard functions, including
the obvious one you're looking for.

And go chase down Ken and have him put the "e" into creat(). :-)

--tom

-- 
    It's documented in The Book, somewhere...
            --Larry Wall in <10502@jpl-devvax.JPL.NASA.GOV>


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

Date: 30 Apr 1999 16:29:57 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: create directory with perl script?
Message-Id: <372a2ee5@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Charles R. Thompson" <design@raincloud-studios.com> writes:
:mkdir("/mydir/", 0550);

Not very useful.  Better use 0777 unless you are doing mail or 
some such.

--tom
-- 
"... and I realized, we did not live in a scientific society."
	--R. P. Feynman, "Cargo cult science"


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

Date: 30 Apr 1999 16:26:21 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Executing Perl code within print structure...
Message-Id: <372a2e0d@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via mail]

In comp.lang.perl.misc, 
    "Charles R. Thompson" <design@raincloud-studios.com> writes:
:END_OF_HTML
:
:terrifying system code here...
:
:print <<END_OF_HTML;
:
:into the textfield... which I can check for and it eliminates
:the problem.

No, I don't think you could.

:Is there anything I'm unaware of that could really be fatal
:here? I'm sure there are some really clever tricks coming my
:way. Should I just ban the use of anything but <> </> and
:standard A-Z 0-9 ?

Perhaps you could look into some of the 21 different
template-interpolating examples that Mark-Jason Dominus has collected.
It's also in the "name in a name" FAQ.

--tom
-- 
    "Even egotists are allowed to have opinions." --Larry Wall


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

Date: Fri, 30 Apr 1999 22:34:42 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Executing Perl code within print structure...
Message-Id: <6eqW2.75$iu1.197@news.rdc1.tn.home.com>

>:END_OF_HTML
>:terrifying system code here...
>:print <<END_OF_HTML;
>:into the textfield... which I can check for and it eliminates
>:the problem.

>No, I don't think you could.


I didn't mean every kind of whacko thing somebody could stick in
there. I was just thinking of bombing out if they try to 'close'
the print.

>Perhaps you could look into some of the 21 different
>template-interpolating examples that Mark-Jason Dominus has
collected.
>It's also in the "name in a name" FAQ.


Will do.. thanks.

CT




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

Date: Fri, 30 Apr 1999 22:52:55 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Executing Perl code within print structure...
Message-Id: <ebohlmanFB0y87.LL4@netcom.com>

Charles R. Thompson <design@raincloud-studios.com> wrote:
: Okay.. I forget what they call this type of print structure...

: print <<END_OF_HTML;
: La la la
: END_OF_HTML

It's not a special "print structure."  It's an ordinary print statement 
with its argument supplied by a here-doc, the latter being semantically 
equivalent to a double-quoted string.

: Anyway... I'm experimenting with a script that accepts HTML
: markup in a Textfield, then builds a small Perl-type library on
: the system. The HTML then becomes part of a larger script.

: I'm trying to wrap my brain around all the things that could go
: wrong as far as security is concerned... I realize it's probably
: wide open.

: I can't seem to call any subroutines or system commands from
: within the print statement, which leads me to believe it's
: pretty safe. The only thing I could come up with was if someone
: typed...

I think you'd better take a look at "How do I expand function calls in a 
string" in perlfaq4.

print <<END_OF_HTML
Bye Bye files
${\(system "rm -rf *")}
END_OF_HTML



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

Date: 30 Apr 1999 16:02:51 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Global Filehandle ?
Message-Id: <372a288b@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    William Blasius #42722 <Wm.Blasius@ks.sel.alcatel.de> writes:
:That sounds almost like the choice between grotty one and grotty two. In
:my particular case, I can get away with the second - and did - but where
:can I get the straight dope on user-defined variables with global scope?
:This is the first time I've needed one in quite a while but at least one
:inquiring mind wants to know. Okay, maybe not enough to reverse-engineer
:the perl interpreter, but curiosity is the work the devil finds for idle
:minds.

Ok, here's what's going on.  Perl has only two kinds of variables.

    Type I, known variously as global, package, dynamic, dynamically
    scoped, local (OUCH!), and symbol table (stab) variables.  These are
    exportable.  These can be qualified with a package.  They are the
    kind of variable that gets created when you just make an assignment
    or open a handle.  Or when you use local() on another Type-I variable.

    Type II, known variously as lexical, private, and statically scoped
    variables.  You cannot find these in the symbol table.  They aren't
    there.  These may NOT be qualified with a package.  These are NOT
    importable.  These are the kind of variable you get when you use my().

Filehandles, directory handles, subroutines, and formats are all
(essentially) of the first variety (Type-I).  They are stored in the
symbol table.  There are ways to get such that aren't in the symbol
table, or to store them in a Type-II variable, but in general, they're
all Type-I, and not Type-II.  You can't (currently) say my *FH, or
my sub foo {}, or my format Foo.  Type-II variables, while key to 
the creation of scalable, modularized code, are not particularly 
related to your question, so won't be talked about much here.

Now, a Type-I identifier might not be package-qualified.  If it is not,
you have to figure out what package it is.  You have two choices here.

  Type-I(n):
    Most Type-I identifiers are "normal" globals, in that they default to the
    currently selected package, or raise a compile-time error if the rare case
    that there isn't one.  Type-I(n) variables are not all there is, although
    they are the ones that you use all the time.

  Type-I(u):
    The other kind are "ubiquitous" global; these if not package qualified
    are instead qualified into the main package, not the current one.
    (They also don't care if there isn't a current package.)  Type-I(u)
    identifiers are all those with punctuation names -- such as $_,
    the _ filehandle, or $$ -- or those that are named STDIN, STDOUT,
    STDERR, ARGV, ARGVOUT, ENV, INC, and SIG.  That also means %ENV, $ENV,
    $STDIN, STDIN, &ARGV, or &STDOUT are of Type-I(u), strange those
    this may all appear.

Now, all Type-I variables and identifiers are globals.  It makes no
difference whether they're of subtype "n" or subtype "u".  They're still
global.  All that changes is the default qualification.  You *can*
have a variable called $Frobniz::_ if you want, but you'll always have
to fully qualify it.  And it will likely get you talked about.

Now, the list of Type-I(u) variables is fixed.  You can't just decide
that your STDLOG filehandle should be Type-I(u) rather than Type-I(n).
It doesn't have the right name.  So if you are only considering Type-I(u)
variables "global" (which is the wrong way to think about it), you're
out of luck, and you can't do what you want.

Does that make more sense now?

I don't see why you don't have a &Trace::Log function or some such, which
would have the handle open.  Why would you want it to be accessible from
all points far and wide?  Notice the syslog model.

--tom
-- 
"Americans are broad-minded people. They'll accept the fact that a person
 can be an alcoholic, a dope fiend, a wife beater, and even a newspaperman,
 but if a man doesn't drive, there is something wrong with him."
				- Art Buchwald


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

Date: 30 Apr 1999 16:19:54 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Instance Data / Instance Variables
Message-Id: <372a2c8a@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via mail]

In comp.lang.perl.misc, 
    David Cassell <cassell@mail.cor.epa.gov> writes:
:Let me just add that you might want to *buy* the Perl Cookbook,
:because the discussions in that chapter might help you more than the 
:code examples.  The O'Reilly site has only the code.

I don't like suggesting that people pay me money.  It makes me feel
slimey and profiteering.  Shame can be a powerful force for good. :-)
If there's one thing I hate, it's when people push there own wares on
folks alleging that they are trying to help them when it just feathers
there pocket.  In a recent example, a certain university professor had
his students all buy the prof's book for a particular course.  Ok fine,
so the prof knows that book better, but it really was about the worst
possible book for the course.

I'd rather err on the side of disgression.  Never trust a man who 
tells you to pay him money for your own good.

--tom
-- 
    X-Windows: Flawed beyond belief.
	--Jamie Zawinski


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

Date: Fri, 30 Apr 1999 15:20:23 -0700
From: I-lin Lee <ilinlee@fox.CS.Berkeley.EDU>
Subject: need help on archiving files using perl and tar
Message-Id: <Pine.HPP.3.96.990430151600.7492A-100000@fox.CS.Berkeley.EDU>

Dear Friends,
	
i've been learning how to write a little shell and perl script since i
started college... and now i'm running into problems of running out of
space in my acct. People told me that tar is a good idea of archiving
files, and i was thinking maybe i could write an automated perl script
tarring my directories periodically. Could anyone help me/gimme tips on
how to do that?

Thanks!!

Alan



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

Date: 30 Apr 1999 16:05:53 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Newsfeed and Local Weather
Message-Id: <372a2941@cs.colorado.edu>

	[courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, Uri Guttman <uri@sysarch.com> writes:
:nroff!! nroff embedded in the perl source!!! puleaasee!! use pod and
:pod2man

I think not.  In fact, I plan to post more and more troff.  Everytime I
catch someone posting HTML to this newsgroup, I will post troff.
This is going to be fun. :-)

See below.  Note the author.  And do have a nice day.  

--tom

#!/usr/bin/perl
'di';
'ig00';
#
# $RCSfile: rename,v $$Revision: 4.1 $$Date: 92/08/07 17:20:30 $
#
# $Log:	rename,v $

($op = shift) || die "Usage: rename perlexpr [filenames]\n";
if (!@ARGV) {
    @ARGV = <STDIN>;
    chop(@ARGV);
}
for (@ARGV) {
    $was = $_;
    eval $op;
    die $@ if $@;
    rename($was,$_) unless $was eq $_;
}
##############################################################################

	# These next few lines are legal in both Perl and nroff.

 .00;			# finish .ig
 
'di			\" finish diversion--previous line must be blank
 .nr nl 0-1		\" fake up transition to first page again
 .nr % 0			\" start at page 1
';<<'.ex'; #__END__ ############# From here on it's a standard manual page ############
 .TH RENAME 1 "July 30, 1990"
 .AT 3
 .SH NAME
rename \- renames multiple files
 .SH SYNOPSIS
 .B rename perlexpr [files]
 .SH DESCRIPTION
 .I Rename
renames the filenames supplied according to the rule specified as the
first argument.
The argument is a Perl expression which is expected to modify the $_
string in Perl for at least some of the filenames specified.
If a given filename is not modified by the expression, it will not be
renamed.
If no filenames are given on the command line, filenames will be read
via standard input.
 .PP
For example, to rename all files matching *.bak to strip the extension,
you might say
 .nf

	rename 's/\e.bak$//' *.bak

 .fi
To translate uppercase names to lower, you'd use
 .nf

	rename 'y/A-Z/a-z/' *

 .fi
 .SH ENVIRONMENT
No environment variables are used.
 .SH FILES
 .SH AUTHOR
Larry Wall
 .SH "SEE ALSO"
mv(1)
 .br
perl(1)
 .SH DIAGNOSTICS
If you give an invalid Perl expression you'll get a syntax error.
 .SH BUGS
 .I Rename
does not check for the existence of target filenames, so use with care.
 .ex
-- 
The hardware engineer says: "Isn't it shipping yet?"
The software engineer says: "Is it shipping already?"
The systems engineer says: "I think I'll paint it beige."


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

Date: 30 Apr 1999 22:21:48 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Newsfeed and Local Weather
Message-Id: <slrn7ikbcq.ov3.fl_aggie@stat.fsu.edu>

On 30 Apr 1999 16:05:53 -0700, Tom Christiansen
<tchrist@mox.perl.com>, in <372a2941@cs.colorado.edu> wrote:
+ 	[courtesy cc of this posting mailed to cited author]
+ 
+ In comp.lang.perl.misc, Uri Guttman <uri@sysarch.com> writes:
+ :nroff!! nroff embedded in the perl source!!! puleaasee!! use pod and
+ :pod2man

+ I think not.  In fact, I plan to post more and more troff.  Everytime I
+ catch someone posting HTML to this newsgroup, I will post troff.
+ This is going to be fun. :-)

Please don't. Its every inch as rude as posting html.

James


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

Date: Fri, 30 Apr 1999 15:22:13 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: NT Perl vs UNIX Perl
Message-Id: <372A2D15.7A6CD4F3@mail.cor.epa.gov>

news.boeing.com wrote:
> 
> I am getting better with converting my UNIX perl to NT, but still some
> problems exist.  It's not as easy some would say.
> 
> Is there some documentations that describe what calls different from NY and
> UNIX?
> 
> Such commands like CHDIR in UNIX does not work with NT.  Well at least it
> does not work with my code.

If you're using ActiveState's Perl, then the docs that come with it 
have an entire separate ActivePerl FAQ.  There are two sections
titled `Windows 95/NT' and `Quirks'.  Have you read through both of
them to make sure it's not already covered?  And the perlport and
perlwin32 pods?

Are you trying to use Perl's builtin, or the system() function?

Maybe you could show us a small, [non]working program that illustrates
your point.  That might help.

HTH,
David
-- 
David Cassell, OAO                            cassell@mail.cor.epa.gov
Senior Computing Specialist                      phone: (541) 754-4468
mathematical statistician                          fax: (541) 754-4716


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

Date: Fri, 30 Apr 1999 15:39:02 -0700
From: "Russ Conner" <rconner@mail.intrix.com>
Subject: Problems with sockets
Message-Id: <925511579.173.82@news.remarQ.com>

I am tryign to write an interface to a program my company produces, called
Supercharge.
Essentually it is a credit card authorization server that uses TCP/IP to
conenct with clients.
To make that process easier, it uses gateways, such as an OCX or DLL and a
drop file interface.
As you can guess it all runs under windows.
A number of clients have expressed an intrest in a UNIX based drop file
interface, and Perl seemed a natural choice. Problem is my Perl, she is not
too good...
I am having a devil of a time getting the response socket open and working

Here is the way it is supposed to work:
I open a socket on <hostname:2000> (this works)
I get a new socket to listen on for a response. (this does not work on my
end it apears that I am getting a null response.)
I send a transaction packet on port 2000 to the SuperCharge server.  (this
also works)
I  wait for a response on the listen socket. (I can't seem to receive this
part.)
I have tried the following:

#!/usr/bin/perl

print ("Attempting to contact a supercharge server...\n");

use IO::Socket;
$remote = IO::Socket::INET->new(
 Proto => "tcp",
 PeerAddr => "Scharge",
 PeerPort => "(2000)",

)
  or die "cannot connect to datime port at localhost" ;
 $local = $remote->accept;
 $remote->autoflush(1);
 print $remote
"[REQ|PERLCLIENT|1|P|549999253409xxxx|1199|1060|000|021848|]";
# while (<$remote>) {print}
$response = IO::Socket::INET->new(Proto=>"tcp", LocalPort=>$local,
Listen=>1) or die "Can't open socket\n";
$res = $response->accept;
while (<$res>) {print}


and also
#!/usr/bin/perl

print ("Attempting to contact a supercharge server...\n");

use IO::Socket;
$remote = IO::Socket::INET->new(
 Proto => "tcp",
 PeerAddr => "Scharge",
 PeerPort => "(2000)",

)
  or die "cannot connect to datime port at localhost" ;
 $remote->autoflush(1);

 print $remote
"[REQ|PERLCLIENT|1|P|549999253409xxxx|1199|1060|000|021848|]";

 $local = $remote->accept;
 while (<$remote>) {print}

I am more than happy to beat my head against the more mundane parts, but I
was hoping to get some help with the more exotic socket stuff




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

Date: Fri, 30 Apr 1999 22:31:11 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: search string syntax
Message-Id: <ebohlmanFB0x7z.K6F@netcom.com>

Eric The Read <emschwar@rmi.net> wrote:
: But in this case, he doesn't want to match patterns, but explicit
: strings.  In this case, index is a lot faster than using a regex.

: #!/usr/bin/perl -w

: use Benchmark;

: my $string = "match something in this short string";
: my $matchstring = "string";

: timethese( 100000, {
:     INDEX => sub { index $string, $matchstring;
:                  },
:     REGEX => sub { $string =~ m/$matchstring/;
:                  },
:     });

: $ /tmp/tmp.pl   
: Benchmark: timing 100000 iterations of INDEX, REGEX...
:      INDEX:  3 secs ( 3.30 usr  0.01 sys =  3.31 cpu)
:      REGEX:  6 secs ( 5.21 usr  0.02 sys =  5.23 cpu)

Unfair comparison, since REGEX includes the overhead of repeatedly
recompiling an interpolated but constant regex.  But INDEX is still
faster, not just as much: 

#!/usr/bin/perl -w

use Benchmark;

my $string = "match something in this short string";
my $matchstring = "string";

timethese( 300000, {
    INDEX => sub { index $string, $matchstring;
                 },
    REGEX => sub { $string =~ m/$matchstring/;
                 },
    REGEXO => sub {$string =~ m/$matchstring/o;
                 },
    });

Benchmark: timing 300000 iterations of INDEX, REGEX, REGEXO...
     INDEX:  0 wallclock secs ( 0.66 usr +  0.00 sys =  0.66 CPU)
     REGEX:  2 wallclock secs ( 1.80 usr +  0.00 sys =  1.80 CPU)
    REGEXO:  2 wallclock secs ( 1.09 usr +  0.00 sys =  1.09 CPU)

Timed on a 350Mhz K6-2 under Win95.



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

Date: Fri, 30 Apr 1999 22:15:27 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: single quotation " erases REST OF TEXT
Message-Id: <ebohlmanFB0wHs.JGE@netcom.com>

NOSPAMcrstlblu@planet.eon.net wrote:
: 	* * ? * *  are there DIFFERENT syntax rules for:
: 		a: <input type=\"hidden">      or
: 		b: <input type=\"text\">

No, the syntax rules are the same.

: besides the obvious that textfield gets displayed and typed into before
: submission, and the hiddenfield just gets generated value=\"$thevalue\">
: before submission?  NOTHING in any of the scripts is otherwise different.

The "obvious" has to do with semantics, not syntax.  The syntax for the 
'value' attribute is identical.

: >One of those rules says that you can't embed a literal double-quote inside a
: >double-quoted attribute-value string; you have to escape it (though the SGML
: >term, which applies because HTML is an SGML application, is "entify" it).
: >Your code is trying to do what the HTML syntax rules say you can't do.  Tad and 
: >others have been telling you how to modify your code so that it produces 
: >HTML that follows the rules.

: 	then how do you explain the customer input script - a cgi generated page
: that had a VISIBLE text formfield in it?  the customer simply typed in
: 	I am 5'10" tall
: clicked the submit button, and WOILA!  the action launched another script which
: simply parsed the incoming values properly, opened a dBm file and entered the
: value PERFECTLY?  if you VIEW that dbm file you will see very literally:
: 	I am 5'10" tall
: if this same script also prints it, it will do so PERFECTLY - !

What the customer types into a text field doesn't have to obey the syntax 
rules of HTML.

Why?  Because it isn't HTML.

It's never turned into HTML by the browser.

What your program sends to the browser as the contents of the 'value' 
attribute for a form field *does* have to obey the syntax rules of HTML.

Why?  Because what you're sending to the browser *is* HTML.

To *display* a form, a browser needs to receive HTML from the server.

To *submit* a form, a browser needs to send not-HTML to the server.

HTML needs to follow such HTML syntax rules as escaping quotes.

not-HTML doesn't need to follow such rules.


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

Date: Fri, 30 Apr 1999 22:17:27 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Using perl to set permissions when chown is blocked
Message-Id: <XZpW2.74$iu1.181@news.rdc1.tn.home.com>

Whassup with chown? I'm using Perl to create textfiles on a web
server. Perl and the server seem to run as owner www and group
www. I'm trying to reset the created files to my owner id. Am I
missing something in the syntax?

chown (web96052, www, "../mydir/myfile.txt") or die "can't set
ownership";

I'm not getting any errors with this.

CT




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

Date: 30 Apr 1999 16:38:00 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Using perl to set permissions when chown is blocked
Message-Id: <372a30c8@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Charles R. Thompson" <design@raincloud-studios.com> writes:
:Whassup with chown? I'm using Perl to create textfiles on a web
:server. Perl and the server seem to run as owner www and group
:www. I'm trying to reset the created files to my owner id. Am I
:missing something in the syntax?
:
:chown (web96052, www, "../mydir/myfile.txt") or die "can't set
:ownership";
:
:I'm not getting any errors with this.

You almost certainly can't do that.  

1) One passes chown() integers, not strings.  Did you use 
   strict?  -w?  Why not?

2) Are you running as the superuser?  That's very dangerous.
   
3) Are you on a system with chown giveaway?  That's insecure, too.

4) What directory are you in?

5) Why didn't you print $! in the error message?  Are you 
   sure you got no errors?

--tom
-- 
    str->str_pok |= SP_FBM;                     /* deep magic */
    s = (unsigned char*)(str->str_ptr);         /* deeper magic */
        --Larry Wall in util.c from the perl source code


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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