[21790] in Perl-Users-Digest
Perl-Users Digest, Issue: 3994 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 18 18:06:04 2002
Date: Fri, 18 Oct 2002 15:05:14 -0700 (PDT)
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, 18 Oct 2002 Volume: 10 Number: 3994
Today's topics:
About to tear my hair out here ... (Newbie Question) (Simon)
Re: About to tear my hair out here ... (Newbie Question <nobull@mail.com>
Re: About to tear my hair out here ... (Newbie Question <mbudash@sonic.net>
Re: can't terminate the script? <nobull@mail.com>
Re: Controlling recursion depth with File::Find <goldbb2@earthlink.net>
Re: expanding variables in text strings <nobull@mail.com>
File::Find directory conundrum <rubberducky703@hotmail.com>
Re: File::Find directory conundrum (Tad McClellan)
Re: File::Find directory conundrum (Randal L. Schwartz)
got socks? <asmith2@rational.com>
Handling Arguments passed to script <hari_yarlagadda@adc.com>
Re: Handling Arguments passed to script <ddunham@redwood.taos.com>
Re: Handling Arguments passed to script <usenet@tinita.de>
Re: Handling Arguments passed to script (Tad McClellan)
Re: how to change compiler in Perl config? <tony_curtis32@yahoo.com>
icmp/udp question <smackdab1@hotmail.com>
intelligent parsing of contact info <dugan@smi.stanford.edu>
Re: intelligent parsing of contact info <nobody@dev.null>
Re: Passing array in the middle of the parrameter list (Cal Contractor)
Re: Pattern Matching help nobull@mail.com
Re: Problem with file Sorting with Perl <danb@mail.dnttm.ro>
processing lines in pairs (hymie!)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Oct 2002 09:14:46 -0700
From: simontheak@hotmail.com (Simon)
Subject: About to tear my hair out here ... (Newbie Question)
Message-Id: <495e297c.0210180814.441844@posting.google.com>
Ok - what I'm trying to do in the long run is to create a guestbook
for my site.
I know I could probably find complete examples on the internet (and
believe me I've been tempted!), but I want to code it myself so that
I'll learn more Perl.
Anyway, I'm stuck at the first hurdle. All I'm trying to do is write a
script that accepts the input from an HTML form and writes it up to
the screen.
Here's what I've got:
#!/usr/bin/perl
$formdata = $ENV{'CONTENT_LENGTH'}
print "Content-type:text/html\n\n";
print "<html><head><title>Test Page</title></head>\n";
print "<body>\n";
print "<h2>Hello, world!</h2>\n";
print $formdata;
print "</body></html>\n";
As you can probably imagine, it's not working. Anyone got any idea
why? I can't tell you HOW greatful I would be!
Thanks,
Simon
------------------------------
Date: 18 Oct 2002 20:19:38 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: About to tear my hair out here ... (Newbie Question)
Message-Id: <u9smz3wo51.fsf@wcl-l.bham.ac.uk>
simontheak@hotmail.com (Simon) writes:
> Subject: About to tear my hair out here ... (Newbie Question)
Y'know this is one of the classic "Bad" subject lines.
Please put the subject of your post in the Subject of your post. If
in doubt try this simple test. Imagine you could have been bothered
to have done a search before you posted. Next imagine you found a
thread with your subject line. Would you have been able to recognise
it as the same subject?
> Ok - what I'm trying to do in the long run is to create a guestbook
> for my site.
>
> I know I could probably find complete examples on the internet (and
> believe me I've been tempted!), but I want to code it myself so that
> I'll learn more Perl.
>
> Anyway, I'm stuck at the first hurdle. All I'm trying to do is write a
> script that accepts the input from an HTML form and writes it up to
> the screen.
use CGI
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 18 Oct 2002 19:39:50 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: About to tear my hair out here ... (Newbie Question)
Message-Id: <mbudash-2DB1A7.12394918102002@typhoon.sonic.net>
In article <495e297c.0210180814.441844@posting.google.com>,
simontheak@hotmail.com (Simon) wrote:
> Ok - what I'm trying to do in the long run is to create a guestbook
> for my site.
>
> I know I could probably find complete examples on the internet (and
> believe me I've been tempted!), but I want to code it myself so that
> I'll learn more Perl.
>
> Anyway, I'm stuck at the first hurdle. All I'm trying to do is write a
> script that accepts the input from an HTML form and writes it up to
> the screen.
>
> Here's what I've got:
>
this code yields the following when called via perl -c:
syntax error at -e line 2, near "print"
> #!/usr/bin/perl
here's your main problem:
> $formdata = $ENV{'CONTENT_LENGTH'}
you're missing a semicolon at the end of the line.
if your code actually contains the semicolon, then i must say: DON'T
retype your code into a newgroup post. copy and paste it.
anyway... what makes you think $ENV{'CONTENT_LENGTH'} contains your form
data??
> print "Content-type:text/html\n\n";
>
> print "<html><head><title>Test Page</title></head>\n";
> print "<body>\n";
> print "<h2>Hello, world!</h2>\n";
> print $formdata;
> print "</body></html>\n";
>
> As you can probably imagine, it's not working. Anyone got any idea
> why? I can't tell you HOW greatful I would be!
do yourself a favor and learn how to use the CGI perl module (among
other techniques):
#-----------------------------------------
#!/usr/bin/perl -wT
use strict;
use CGI;
my $cgi = CGI->new();
print $cgi->header();
print q|<html>
<head><title>Test Page</title></head>
<body>
<h2>Hello, world!</h2>
|;
foreach ($cgi->param()) {
print "$_ : ", $cgi->param($_), "<br>\n";
}
print q|</body>
</html>
|;
exit;
#-----------------------------------------
see: http://stein.cshl.org/WWW/software/CGI/
the CGI module is included with the perl distribution, so you don't even
have to install it...
good luck!
------------------------------
Date: 18 Oct 2002 20:27:36 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: can't terminate the script?
Message-Id: <u9ptu7wnrr.fsf@wcl-l.bham.ac.uk>
"jackkon" <jackkon@ms29.url.com.tw> writes:
> "Brian McCauley" <nobull@mail.com> ¼¶¼g©ó¶l¥ó
> news:u9y98xmd4e.fsf@wcl-l.bham.ac.uk...
> >
> > You've not told us what you are observing only how you interpreted it.
>
> My OS is linux Mandrake 8.2
> but I use the ActivePerl, not the native perl while install
>
> When the script named rpm-qlp.pl prints "Execute Over",
> I use the "top" command to watch the process,
> and I find the data below.
>
> PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
> 1867 root 15 0 6220 1108 368 R 3.9 1.7 24:04 X
> 2379 jck1 12 0 2200 732 568 S 1.9 1.1 13:15 kdeinit
> 7136 jck1 19 19 2724 1416 1008 S N 1.9 2.2 17:33 krozat.kss
> 7425 jck1 17 0 668 512 340 R 1.7 0.8 0:01 top
> 5 root 10 0 0 0 0 SW 1.5 0.0 0:11 kswapd
> 7397 root 10 0 63508 46M 42768 R 0.5 77.2 0:31 rpm-qlp.pl
>
> It seems a little strange.
> But I don't know why.
Are you sure that the instance of rpm-qlp.pl that is still running is
the same instance as the one that printed "Execute Over"? Are you
sure you didn't start multiple copies.
Of course, I suppose, such a big process could take a noticable time in the global
destruction phase.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 18 Oct 2002 17:03:03 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Controlling recursion depth with File::Find
Message-Id: <3DB07707.69AE6816@earthlink.net>
Michele Dondi wrote:
>
> On Fri, 18 Oct 2002 00:20:43 -0400, Benjamin Goldberg
> <goldbb2@earthlink.net> wrote:
>
> >Michele Dondi wrote:
> >>
> >> Is there any easy/preferred way to impose limits to recursion depth
> >> for File::Find::find, as for the -mindepth, -maxdepth parameteres
> >> of the find command?
> >>
> >> Have I to count the number of directory separators?
> >
> >my $path = "/some/directory/path/";
> >my $len;
> >find sub {
> > my $depth = substr( $_, $len ) =~ tr!/!!;
> > return $File::Find::prune = 1 if $depth > $n;
> > # do rest of processing here.
> >}, $path;
>
> Wow! I can even understand the way it works, and surprisingly that's
> more or less what I had thought of.
>
> Of course the above code would need some enhancements to take into
> account the numer of slashes in $path
That's what the substr() does -- it skips the leading part of $_, for
however long $path is. That way, $depth only counts slashes in the part
we've recursed into.
> and further complications arise
> if multiple paths are supplied.
There's two ways that I can see of doing that:
find( sub {
my $depth = substr( $_, length $File::Find::topdir ) =~ tr!/!!;
return if $depth < $mindepth;
return $File::Find::prune = 1 if $depth > $maxdepth;
# stuff .
}, @multiple_paths );
Or:
foreach my $path (@multiple_paths) {
my $len = length $path;
find( sub {
my $depth = substr( $_, $len ) =~ tr!/!!;
return if $depth < $mindepth;
return $File::Find::prune = 1 if $depth > $maxdepth;
# stuff .
}, $path );
}
> For ease of use File::Find could just include a $File::Find::depth var
> with the obvious meaning. It should be set to 0 at root dirs and
> incremented when recursing into a subdirectory and decremented when
> getting back to the parent directory.
This sounds like a good idea. Since File::Find is part of core perl,
the people who maintain and upgrade it are the same folks as maintain
and upgrade perl -- the people on the perl5porters mailing list -- so
use the 'perlbug' program to send in your idea.
> Also (my humble suggestion) the value of such an hypothetical var
> could be assigned locally to the $. var so to be able to use a
> statement like
>
> print if 1 .. 3;
I don't know about this... think about what happens if the directories
are 4 levels deep... it stops printing when $depth is 3, then (silently)
goes deeper, and backs up, but on it's way up, it won't print any of the
filenames that are at a depth of 2 or 3, until it's gone all the way up
to a directory of depth 1.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 18 Oct 2002 17:33:39 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: expanding variables in text strings
Message-Id: <u9of9r9064.fsf@wcl-l.bham.ac.uk>
jason@generationterrorists.com (Jason Quek) writes:
> $string = '$one$two is my $three';
> $string =~ s/(\$\w+)/$1/eeg;
> However, if I have this:
> $string = '$FORM{\'one\'}$FORM{\'two\'} is my $FORM{\'three\'}';
> # -----------------------------------------------------------------
>
> What is the regular expression I should use to match $FORM{'xxx'}?
Others have given good answers to this sepecific question but you may
also like to take a look at the various Template::* modules on CPAN or
even String::Interpolate.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 18 Oct 2002 16:53:02 +0100
From: "Rubber Duck" <rubberducky703@hotmail.com>
Subject: File::Find directory conundrum
Message-Id: <aopaml$osmft$1@ID-116287.news.dfncis.de>
Thanks Helgi for your answer (below) I'm about to try what you suggested.
I have a similar problem.
I'm counting directories in a directory and each directory below that.
A simple question.
How do I know if the current $_ is a directory or a file??
I've been using if ($_ !~ /\./) # if no dots in the filename
This is fine until I come across a filename such as README or similar.
Is their a sure fire way I can know if the current $_ is definitely a
directory?
RD
------------------------------
Date: Fri, 18 Oct 2002 12:32:39 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: File::Find directory conundrum
Message-Id: <slrnar0hdn.1nb.tadmc@magna.augustmail.com>
Rubber Duck <rubberducky703@hotmail.com> wrote:
> How do I know if the current $_ is a directory or a file??
print "$_ is a directory if -d;
For more info:
perldoc -f -d
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 18 Oct 2002 10:50:10 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: "Rubber Duck" <rubberducky703@hotmail.com>
Subject: Re: File::Find directory conundrum
Message-Id: <8665vz7i25.fsf@red.stonehenge.com>
>>>>> "Rubber" == Rubber Duck <rubberducky703@hotmail.com> writes:
Rubber> Is their a sure fire way I can know if the current $_ is definitely a
Rubber> directory?
if (-d $_) { "it's a directory!" }
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 18 Oct 2002 13:15:32 -0400
From: "Smith, Aaron" <asmith2@rational.com>
Subject: got socks?
Message-Id: <657B3BF8C9B17249A8E3BF98622AE88D0B093B97@sus-ma1it06.rational.com>
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C276C9.F6F1E228
Content-Type: text/plain;
charset="iso-8859-1"
There's a socks module. Other than that, I vaguely remember trying to
work that out once but I don't recall that I had much success. I could
be wrong though. Would be relatively easy if you had a socks server.
-----Original Message-----
From: NigelC [mailto:Nigel@mutualnet.co.uk]
Posted At: Friday, October 18, 2002 12:35 PM
Posted To: comp.lang.perl.misc
Conversation: Sockets through a proxy/firewall
Subject: Re: Sockets through a proxy/firewall
My own fault, the serv.pl script should read as follows - Still doesn't
solve my problem if someone could help?
use IO::Socket;
use Socket;
use Sys::Hostname;
my $host = hostname();
my $addr = inet_ntoa(scalar gethostbyname($host || 'localhost'));
my $server = IO::Socket::INET->new(
Listen => 5,
LocalAddr => $addr,
LocalPort => 5050,
Proto => 'tcp'
) or die "Can't create server socket: $!";
my $client = $server->accept;
$fl="c:/Perl/out1.pdf";
open FILE, ">$fl" or die "Can't open: $!";
binmode (FILE);
while (<$client>) {
print FILE $_;
}
close FILE;
"Nigel" <nhcannings@hotmail.com> wrote in message
news:361d2a80.0210180537.218396e3@posting.google.com...
> I have two simple scripts for passing pdf documents from one machine
> to another using sockets. These work perfectly well for most
> machines, but from time to time I'm going to want to get them through
> to a machine behind a corporate firewall. Assuming I know the IP
> address of the firewall, and the local Ip address of the machine
> itself, is there a simple way of modifying cli.pl (below) to pass the
> documents through
>
> thanks
>
> Nigel
>
> ===========
> (cli.pl)
>
> use IO::Socket;
> $remserv = 'xx.xx.xx.xx';
> my $server = IO::Socket::INET->new(
> PeerAddr => $remserv,
> PeerPort => 5050,
> Proto => 'tcp'
> ) or die "Can't create client socket: $!";
>
> open FILE, "c:/perl/ReadMe.pdf";
> binmode (FILE);
> while (<FILE>) {
> print $server $_;
> }
> close FILE;
>
>
> (serv.pl)
>
> use IO::Socket;
>
> my $server = IO::Socket::INET->new(
> Listen => 5,
> LocalAddr => 'localhost',
> LocalPort => 5050,
> Proto => 'tcp'
> ) or die "Can't create server socket: $!";
>
> my $client = $server->accept;
> $fl="c:/perl/out1.pdf";
>
> open FILE, ">$fl" or die "Can't open: $!";
> binmode (FILE);
>
> while (<$client>) {
> print FILE $_;
> }
> close FILE;
------_=_NextPart_001_01C276C9.F6F1E228
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2654.19">
<TITLE>got socks?</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=3D2>There's a socks module. Other than that, I vaguely =
remember trying to work that out once but I don't recall that I had =
much success. I could be wrong though. Would be relatively easy if you =
had a socks server.</FONT></P>
<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: NigelC [<A =
HREF=3D"mailto:Nigel@mutualnet.co.uk">mailto:Nigel@mutualnet.co.uk</A>]<=
/FONT>
<BR><FONT SIZE=3D2>Posted At: Friday, October 18, 2002 12:35 PM</FONT>
<BR><FONT SIZE=3D2>Posted To: comp.lang.perl.misc</FONT>
<BR><FONT SIZE=3D2>Conversation: Sockets through a =
proxy/firewall</FONT>
<BR><FONT SIZE=3D2>Subject: Re: Sockets through a proxy/firewall</FONT>
</P>
<BR>
<P><FONT SIZE=3D2>My own fault, the serv.pl script should read as =
follows - Still doesn't</FONT>
<BR><FONT SIZE=3D2>solve my problem if someone could help?</FONT>
</P>
<P><FONT SIZE=3D2>use IO::Socket;</FONT>
<BR><FONT SIZE=3D2> use Socket;</FONT>
<BR><FONT SIZE=3D2> use Sys::Hostname;</FONT>
<BR><FONT SIZE=3D2> my $host =3D hostname();</FONT>
<BR><FONT SIZE=3D2> my $addr =3D inet_ntoa(scalar =
gethostbyname($host || 'localhost'));</FONT>
</P>
<P><FONT SIZE=3D2>my $server =3D IO::Socket::INET->new(</FONT>
<BR><FONT SIZE=3D2> Listen =3D> 5,</FONT>
<BR><FONT SIZE=3D2> LocalAddr =3D> $addr,</FONT>
<BR><FONT SIZE=3D2> LocalPort =3D> 5050,</FONT>
<BR><FONT SIZE=3D2> Proto =
=3D> 'tcp'</FONT>
<BR><FONT SIZE=3D2>) or die "Can't create server socket: =
$!";</FONT>
</P>
<P><FONT SIZE=3D2>my $client =3D $server->accept;</FONT>
<BR><FONT SIZE=3D2>$fl=3D"c:/Perl/out1.pdf";</FONT>
</P>
<P><FONT SIZE=3D2>open FILE, ">$fl" or die "Can't =
open: $!";</FONT>
<BR><FONT SIZE=3D2>binmode (FILE);</FONT>
</P>
<P><FONT SIZE=3D2>while (<$client>) {</FONT>
<BR><FONT SIZE=3D2> print FILE $_;</FONT>
<BR><FONT SIZE=3D2>}</FONT>
<BR><FONT SIZE=3D2>close FILE;</FONT>
</P>
<BR>
<P><FONT SIZE=3D2>"Nigel" <nhcannings@hotmail.com> =
wrote in message</FONT>
<BR><FONT SIZE=3D2><A =
HREF=3D"news:361d2a80.0210180537.218396e3@posting.google.com" =
TARGET=3D"_blank">news:361d2a80.0210180537.218396e3@posting.google.com</=
A>...</FONT>
<BR><FONT SIZE=3D2>> I have two simple scripts for passing pdf =
documents from one machine</FONT>
<BR><FONT SIZE=3D2>> to another using sockets. These work =
perfectly well for most</FONT>
<BR><FONT SIZE=3D2>> machines, but from time to time I'm going to =
want to get them through</FONT>
<BR><FONT SIZE=3D2>> to a machine behind a corporate firewall. =
Assuming I know the IP</FONT>
<BR><FONT SIZE=3D2>> address of the firewall, and the local Ip =
address of the machine</FONT>
<BR><FONT SIZE=3D2>> itself, is there a simple way of modifying =
cli.pl (below) to pass the</FONT>
<BR><FONT SIZE=3D2>> documents through</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> thanks</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> Nigel</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT>
<BR><FONT SIZE=3D2>> (cli.pl)</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> use IO::Socket;</FONT>
<BR><FONT SIZE=3D2>> $remserv =3D 'xx.xx.xx.xx';</FONT>
<BR><FONT SIZE=3D2>> my $server =3D IO::Socket::INET->new(</FONT>
<BR><FONT SIZE=3D2>> PeerAddr =3D> =
$remserv,</FONT>
<BR><FONT SIZE=3D2>> PeerPort =3D> =
5050,</FONT>
<BR><FONT SIZE=3D2>> Proto =
=3D> 'tcp'</FONT>
<BR><FONT SIZE=3D2>> ) or die "Can't create client socket: =
$!";</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> open FILE, =
"c:/perl/ReadMe.pdf";</FONT>
<BR><FONT SIZE=3D2>> binmode (FILE);</FONT>
<BR><FONT SIZE=3D2>> while (<FILE>) {</FONT>
<BR><FONT SIZE=3D2>> print $server =
$_;</FONT>
<BR><FONT SIZE=3D2>> }</FONT>
<BR><FONT SIZE=3D2>> close FILE;</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> (serv.pl)</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> use IO::Socket;</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> my $server =3D IO::Socket::INET->new(</FONT>
<BR><FONT SIZE=3D2>> Listen =3D> =
5,</FONT>
<BR><FONT SIZE=3D2>> LocalAddr =3D> =
'localhost',</FONT>
<BR><FONT SIZE=3D2>> LocalPort =3D> =
5050,</FONT>
<BR><FONT SIZE=3D2>> =
Proto =3D> 'tcp'</FONT>
<BR><FONT SIZE=3D2>> ) or die "Can't create server socket: =
$!";</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> my $client =3D $server->accept;</FONT>
<BR><FONT SIZE=3D2>> $fl=3D"c:/perl/out1.pdf";</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> open FILE, ">$fl" or die =
"Can't open: $!";</FONT>
<BR><FONT SIZE=3D2>> binmode (FILE);</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> while (<$client>) {</FONT>
<BR><FONT SIZE=3D2>> print FILE $_;</FONT>
<BR><FONT SIZE=3D2>> }</FONT>
<BR><FONT SIZE=3D2>> close FILE;</FONT>
</P>
</BODY>
</HTML>
------_=_NextPart_001_01C276C9.F6F1E228--
------------------------------
Date: Fri, 18 Oct 2002 13:43:33 -0500
From: Hari Yarlagadda <hari_yarlagadda@adc.com>
Subject: Handling Arguments passed to script
Message-Id: <3DB05655.B14F5E8A@adc.com>
Hello Folks,
I am trying to pass a string as an argument to a Perl script. This
string has some metacharacters that I don't want suppressed. For
example:
\( Project 'isequal' "DVT" \)
is interpreted as
( Project isequal DVT )
in the ARGV array.
Is there any way to suppress this behavior? Unfortunately I don't have
control over the input string so I can't use backslashes to escape each
of the metacharacters I want to keep.
Thanks a lot for the help!
-chad
------------------------------
Date: Fri, 18 Oct 2002 18:56:17 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Handling Arguments passed to script
Message-Id: <lPYr9.5948$Ec7.373847309@newssvr21.news.prodigy.com>
Hari Yarlagadda <hari_yarlagadda@adc.com> wrote:
> Hello Folks,
> I am trying to pass a string as an argument to a Perl script. This
> string has some metacharacters that I don't want suppressed. For
> example:
> \( Project 'isequal' "DVT" \)
> is interpreted as
> ( Project isequal DVT )
> in the ARGV array.
Then it's whatever is handing the arguments to perl. What is it?
> Is there any way to suppress this behavior? Unfortunately I don't have
> control over the input string so I can't use backslashes to escape each
> of the metacharacters I want to keep.
How is perl being invoked? Is it from a shell or batch script (what
OS?) or is it from a c program calling an exec() function?
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: 18 Oct 2002 19:08:03 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Handling Arguments passed to script
Message-Id: <aopm6j$ogl98$2@fu-berlin.de>
Hari Yarlagadda <hari_yarlagadda@adc.com> wrote:
> I am trying to pass a string as an argument to a Perl script. This
> string has some metacharacters that I don't want suppressed. For
> example:
> \( Project 'isequal' "DVT" \)
> is interpreted as
> ( Project isequal DVT )
> in the ARGV array.
no it isn't.
if you pass the string
\( Project 'isequal' "DVT" \)
perl will get it like it is.
> Is there any way to suppress this behavior? Unfortunately I don't have
> control over the input string so I can't use backslashes to escape each
> of the metacharacters I want to keep.
well, *how* do you get the input?
in a shell, i assume.
if you do
$ perl script.pl \( Project 'isequal' "DVT" \)
then @ARGV will contain this:
print join ",",@ARGV";
(,Project,isequal,DVT,)
this is because the shell converts \( to (, 'arg' to arg,
"arg" to arg and \) to ).
to get one element in @ARGV you have to do
$perl script.pl "\( Project 'isequal' \"DVT\" \)"
hth, tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/ \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Fri, 18 Oct 2002 14:54:30 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Handling Arguments passed to script
Message-Id: <slrnar0pnm.1rm.tadmc@magna.augustmail.com>
Hari Yarlagadda <hari_yarlagadda@adc.com> wrote:
> I am trying to pass a string as an argument to a Perl script. This
> string has some metacharacters that I don't want suppressed.
You have a shell question, not a Perl question.
You should ask shell questions in a newsgroup about shells, such as:
comp.unix.shell
> For
> example:
>
> \( Project 'isequal' "DVT" \)
>
> is interpreted as
>
> ( Project isequal DVT )
Not by Perl it isn't.
> in the ARGV array.
>
> Is there any way to suppress this behavior?
There is no Perl behavior to suppress.
You haven't told us what shell you must use, so we can't offer
much direct help, other than to tell you that Perl isn't the
one messing with your data.
This works fine for be with the bash shell:
perl -e 'print @ARGV' "\( Project 'isequal' \"DVT\" \)"
> Unfortunately I don't have
> control over the input string so I can't use backslashes to escape each
> of the metacharacters I want to keep.
Then you must figure out some way of otherwise avoiding the shell.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 18 Oct 2002 10:17:24 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: how to change compiler in Perl config?
Message-Id: <87wuoflqt7.fsf@limey.hpcc.uh.edu>
>> On 18 Oct 2002 08:01:17 -0700,
>> shambo_p@yahoo.com (Shambo) said:
> Perl is already installed on the Solaris 7 box here. I
> downloaded the gcc compiler and need to tell Perl to use
> this compiler for makes. I manually edited the Config.pm
> file and changed "cc" to "gcc", and gcc is in my PATH,
> but certain modules are still tryting to call cc. Any
> ideas?
Build your own perl from source with the compiler you want
to use. Trying to hack a new compiler in post facto is
going to cause headaches (esp. if there are
compiler-specific CFLAGS).
hth
t
------------------------------
Date: Fri, 18 Oct 2002 21:04:24 GMT
From: "smackdab" <smackdab1@hotmail.com>
Subject: icmp/udp question
Message-Id: <sH_r9.171222$S32.11960901@news2.west.cox.net>
For ICMP, I know I can use select() to see if there is any
pending data on my socket. Since I can use IO::Socket I am assuming
that I can also use IO::Select instead of the select() call, right ?
For UDP, I can't tell from my book if I can use select() or IO::Select...
It just mentiones that you can set an alarm in an eval {} block
to timeout a recv(). Since I am on windows, I don't use alarm..
Assuming that select will work for UDP, can I set the sequence
number with IO::Socket or do I need to manually create the packet ?
thanks!
------------------------------
Date: Fri, 18 Oct 2002 10:20:18 -0700
From: Jonathan Dugan <dugan@smi.stanford.edu>
Subject: intelligent parsing of contact info
Message-Id: <n2g0ruo4l0g4ae9k4v95t31h72jddmjkfr@4ax.com>
hi all
quick question...
I am about to write a script that will notice and pull out contact
information from text, and then parse it into relevant fields for
entry into pim/contact lists.
I'd like to be able to pass emails with signatures / scanned business
cards / .vcf attachments / etc. and have the name/ address/ phone all
parsed and classified appropriately.
I'm imagining having several keywords to search for, including many
common position titles -- making some simplifying assumptions that
information is separated onto different lines... etc.
The question: has anyone else done this? I don't want to
startworking on it and reproduce existing work. Does anyone else want
to work on it with me?
Cheers,
Jon
------------------------------
Date: Fri, 18 Oct 2002 17:59:27 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: intelligent parsing of contact info
Message-Id: <3DB04C36.6020908@dev.null>
Jonathan Dugan wrote:
> hi all
>
> quick question...
>
> I am about to write a script that will notice and pull out contact
> information from text, and then parse it into relevant fields for
> entry into pim/contact lists.
>
>
> I'd like to be able to pass emails with signatures / scanned business
> cards / .vcf attachments / etc. and have the name/ address/ phone all
> parsed and classified appropriately.
>
>
> I'm imagining having several keywords to search for, including many
> common position titles -- making some simplifying assumptions that
> information is separated onto different lines... etc.
>
>
>
> The question: has anyone else done this? I don't want to
> startworking on it and reproduce existing work. Does anyone else want
> to work on it with me?
>
>
> Cheers,
> Jon
Check out the Lingua::EN::* modules on CPAN before you reinvent the wheel...
------------------------------
Date: 18 Oct 2002 13:08:40 -0700
From: cal_contractor@hotmail.com (Cal Contractor)
Subject: Re: Passing array in the middle of the parrameter list
Message-Id: <905a9e5d.0210181208.52d2e261@posting.google.com>
Mike Mayer <vm.mayer@comcast.net> wrote in message news:<vm.mayer-762AD9.01530818102002@news-east.giganews.com>...
...snip...
> You are correct that you cannot pass an arbitrarily sized array in the
> middle of a list. But, it is perfectly acceptable to pass it at the end
> of the list.
>
...snip...
Another possibility would be to have a parameter which indicates the
length of the array:
@A = (1, 2, 3);
some_sub("Hello, world", $#A + 1, @A, "more parameters", "and
another");
This method seems quite cumbersome - I mention it only for
completeness.
------------------------------
Date: 18 Oct 2002 10:07:42 -0700
From: nobull@mail.com
Subject: Re: Pattern Matching help
Message-Id: <4dafc536.0210180907.36feda8e@posting.google.com>
Giuseppe <lcdn@inwind.it> wrote in message news:<aomat5$o1i6s$1@ID-154800.news.dfncis.de>...
> > The $1, $2 etc represent the bits captured by the () in the regex.
> >
> > There is no () in your regex.
> >
> > You appear to be totally confused. I suggest going back and reading
> > about what s/// does and what $1 and so on mean in the manuals.
> >
> > If your problem is that you find the manuals hard to understand in
> > English then perhaps you should get the Italian translation of The
> > Camel Book. Unfortunatly the quality Italian translation is apparently
> > not as good as the French and German.
>
> I have no problem to understand english,
In that case I must conclude that you decided to post to Usenet with
your question about s/// rather than reading the explaintion of s///
and regular expressions in the reference manual. Why did you do that?
> where can I download this book ?
The Camel Book (aka. "Programming Perl" by Wall, Christiansen &
Schwartz published by O'Reilly ) is not freely distributable. You can
buy it from any good bookshop or bookshop-website.
It is available on paper or on CD (as part of the "Perl Bookshelf").
I actually have both (my own personal copy on paper and my office copy
on CD).
Reading this book you'll find it's a lot like an extended version of
the standard (GPL/Artistic license) manuals. This is, I assume,
because they share a common ancestor.
You can also read O'Reilly books on their website but this too is not
free (after the fist 14 days).
Although I know it can be done, I strongly discourage you from
dowloading the Perl Bookshelf from a Warez site as this would deny the
authors (and publishers) their legitimate rewards for all they have
done for the Perl community.
------------------------------
Date: Fri, 18 Oct 2002 19:07:30 +0200
From: "Dan Borlovan" <danb@mail.dnttm.ro>
Subject: Re: Problem with file Sorting with Perl
Message-Id: <aopbjp$qm8$1@nebula.dnttm.ro>
> When it tries to sort the file, it throws out "Out of Memory" error.
> The file I am trying to sort is 500 MB. I tried it on Windows NT and
No wonder. Perl is not optimized to handle large data structures (arrays /
hashes) - it allocates a lot more memory than the size of the data.
If you need to do the sorting in memory, use a language that let you control
the memory allocation, like C. If not, there are "on disk" sorting
techniques (I think I learned a long time ago about some "band-sorting"
algoritm, using N "bands" - files that are accessed sequentially)
Dan
------------------------------
Date: Fri, 18 Oct 2002 19:16:03 -0000
From: hymie@lactose.smart.net (hymie!)
Subject: processing lines in pairs
Message-Id: <ur0nfjg9ksnt79@corp.supernews.com>
Greetings.
Can somebody help me improve my logic?
I'm reading from a text file that looks like this:
filename <tab> description
filename <tab> description
filename <tab> description
filename <tab> description
The nature of my output (a web table, but that's not important) requires that
I read the lines in pairs like this:
while (<INDEX>)
{
chomp;
if ($line==0)
{
($picture1file, $picture1text) = ("","");
if (s/\\$//) { $_ .= <INDEX> ; redo; }
($picture1file, $picture1text) = &pictureline($_);
$line++;
}
elsif ($line==1)
{
($picture2file, $picture2text) = ("","");
if (s/\\$//) { $_ .= <INDEX> ; redo; }
$line++;
($picture2file, $picture2text) = &pictureline($_);
}
# and then I process the lines into my web table like this
if ($line==2)
{ # we're finished. process and print the line
print qq(<tr>);
&printpicture($picture1file);
&printtext($picture1text,"left",$picture1file);
&printpicture($picture2file,$picture2thumb);
print qq(</tr>\n<tr>);
&printtext($picture2text,"right",$picture2file,$picture2thumb);
print qq(</tr>\n);
$line=0;
}
}
In short, having read
filename1 <tab> description1
filename2 <tab> description2
I output something like this:
<tr><td>filename1</td><td>description1</td><td>filename2</td></tr>
<tr><td> </td><td>description2</td><td> </td></tr>
Which works fine as long as I guarantee that my lines are in pairs.
I have I have odd line at the end, then EOF ends my while() loop, and
my printing portion is never activated.
The best alternative I've come up with (I haven't tried it yet) is to
slurp the file into an array and process each line that way, so that
I have a little more control over what to do at the end. (That is, I
know in advance which is my last line.) But I wonder if there's a better
way...
Thanks in advance.
hymie! http://www.smart.net/~hymowitz hymie@lactose.smart.net
===============================================================================
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.
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 V10 Issue 3994
***************************************