[9446] in Perl-Users-Digest
Perl-Users Digest, Issue: 3041 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 1 19:17:15 1998
Date: Wed, 1 Jul 98 16:00:30 -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, 1 Jul 1998 Volume: 8 Number: 3041
Today's topics:
\d versus [0-9] howard@wdsec.com
Re: \d versus [0-9] <danboo@negia.net>
Re: \d versus [0-9] (Matt Knecht)
Re: \d versus [0-9] (Craig Berry)
Re: case-insensitivity <jason.holland@dial.pipex.com>
Re: case-insensitivity <jason.holland@dial.pipex.com>
Re: Couple of quick ?'s from perl newbie Grehom@my-dejanews.com
Re: Dejanews/closed lists/moderated groups/lists [Was: birgitt@my-dejanews.com
Re: detecting time of day (Chris Russo)
Re: How do you pre-append using "open" abraham@mpi.com
I NEED SOME HELP <dcunningham@detnet.com>
Re: Invalid regexp in grep (Michael J Gebis)
Re: Invalid regexp in grep <danboo@negia.net>
Re: Invalid regexp in grep (Greg Bacon)
Low level Windows event execution via Perl (Tom Werner)
Re: passing a ref to a subroutine, problem with use str (Greg Bacon)
Re: passing a ref to a subroutine, problem with use str <rick.delaney@shaw.wave.ca>
Re: Passing arguments to perl CGI (brian d foy)
Re: perl and secured payment online? (Abigail)
Perl At Work <jason.holland@dial.pipex.com>
Re: perl newbie Q: Any ideas why this doesn't work? (Jeffrey Kaplan)
problem with system and ftp (Larry Martell)
problem with system and ftp (Larry Martell)
Re: problems with script (Abigail)
Re: problems with script (Matt Knecht)
problems: compiling module with nmake (Michael Haertfelder)
Sorting Database Entries sdreyer@writeme.com
Re: Sorting Database Entries (Matt Knecht)
time out for IO::Socket::accept() <mitchell@ilog.com>
Using goto & with SUPER:: (Peter Scott)
Re: Vertical Perl <zenin@bawdycaste.org>
Re: Virtual functions. <igor.k@usa.net>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 01 Jul 98 17:30:57
From: howard@wdsec.com
Subject: \d versus [0-9]
Message-Id: <NEWTNews.899328673.11610.howard@howardnt2>
In pattern matching checking against a variable
$SOURCE =~ /$CHECK/
works for $CHECK="[0-9]"
but fails for $CHECK="\d"
but works for
$SOURCE =~ /\d/
Does anyone have an explanation?
------------------------------
Date: Wed, 01 Jul 1998 18:00:14 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: \d versus [0-9]
Message-Id: <359AB16E.91BB5F8@negia.net>
howard@wdsec.com wrote:
>
> In pattern matching checking against a variable
>
> $SOURCE =~ /$CHECK/
>
> works for $CHECK="[0-9]"
> but fails for $CHECK="\d"
> but works for
>
> $SOURCE =~ /\d/
>
> Does anyone have an explanation?
$CHECK="\d";
print $CHECK;
cheers,
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Wed, 01 Jul 1998 22:00:04 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: \d versus [0-9]
Message-Id: <Ejym1.26$rf1.302765@news3.voicenet.com>
howard@wdsec.com <howard@wdsec.com> wrote:
>$SOURCE =~ /$CHECK/
>
>works for $CHECK="[0-9]"
>but fails for $CHECK="\d"
>but works for
>
>$SOURCE =~ /\d/
>
>Does anyone have an explanation?
Interpolation! Check out 'perldoc perlop' specifically 'Quote and
Quote-like Operators'. And also try these two lines:
print "\d";
print '\d';
--
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"
------------------------------
Date: 1 Jul 1998 22:08:38 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: \d versus [0-9]
Message-Id: <6nec16$nt9$1@marina.cinenet.net>
howard@wdsec.com wrote:
: In pattern matching checking against a variable
:
: $SOURCE =~ /$CHECK/
:
: works for $CHECK="[0-9]"
perl -e 'print "[0-9]"' => [0-9]
: but fails for $CHECK="\d"
perl -e 'print "\d"' => d
: but works for
:
: $SOURCE =~ /\d/
Different escaped-char processing going on here.
: Does anyone have an explanation?
Make sense, now?
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Wed, 01 Jul 1998 22:14:23 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
To: Jonas Kihlsten <"qtxjoki"@vg.ao,.ericsson.se>
Subject: Re: case-insensitivity
Message-Id: <359AB4BF.10C21606@dial.pipex.com>
Jonas Kihlsten wrote:
>
> Does anyone know how to ignore case-sensivity when scaning through a
> textfile?
>
> Jonas Kihlsten
> qtxjoki@vg.aom.ericsson.se
> http://holistic.home.ml.org
If you are using the m pattern matching command/operator then add the i
parameter to the end of the pattern, liek this:
$string =~ m/hello/i;
This will match things like Hello, HELLO and HeLlO.
Bye!
--
sub jasonHolland {
my %hash = ( website =>
"http://dspace.dial.pipex.com/jason.holland/",
email => "jason.holland@dial.pipex.com" );
}
------------------------------
Date: Wed, 01 Jul 1998 22:14:49 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
Subject: Re: case-insensitivity
Message-Id: <359AB4D9.1357C385@dial.pipex.com>
Jonas Kihlsten wrote:
>
> Does anyone know how to ignore case-sensivity when scaning through a
> textfile?
>
> Jonas Kihlsten
> qtxjoki@vg.aom.ericsson.se
> http://holistic.home.ml.org
If you are using the m pattern matching command/operator then add the i
parameter to the end of the pattern, liek this:
$string =~ m/hello/i;
This will match things like Hello, HELLO and HeLlO.
Bye!
--
sub jasonHolland {
my %hash = ( website =>
"http://dspace.dial.pipex.com/jason.holland/",
email => "jason.holland@dial.pipex.com" );
}
------------------------------
Date: Wed, 01 Jul 1998 22:27:22 GMT
From: Grehom@my-dejanews.com
Subject: Re: Couple of quick ?'s from perl newbie
Message-Id: <6ned4a$eg9$1@nnrp1.dejanews.com>
In article <6nb8at$ev0$1@nnrp1.dejanews.com>,
cia1@ix.netcom.com wrote:
>
> Thanks in advance to any who can help!
>
> The following is a piece of code from my first ever script that appends to a
> file some form info:
>
try the following ($1, $2 etc. are already defined!! )
#!/usr/bin/perl -w
open MYDB, 'text.dat' or die "couldn't open MYDB: $!";
while (<MYDB>) {
chomp;
($f1, $f2, $f3, $f4, $f5, $f6, $f7, $f8, $f9, $f10, $f11) = split /\|/;
print $f1, " ", $f2, " ", $f3, " ", $f4, " ", $f5, " ", $f6, " ", $f7,
" ", $f8, " ", $f9, " ", $f10, " ", $f11, "\n";
}
close MYDB;
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 01 Jul 1998 20:12:06 GMT
From: birgitt@my-dejanews.com
Subject: Re: Dejanews/closed lists/moderated groups/lists [Was: Re: Is perl5-porters closed to subscription?
Message-Id: <6ne56l$4n6$1@nnrp1.dejanews.com>
In article <6ndn1p$f2m$1@nnrp1.dejanews.com>,
birgitt@my-dejanews.com wrote:
>
> First, I apologize that my questions end up being posted here in
> c.l.p.m, but I couldn't find (besides may be news.groups) a place
Now again I apologize. I found three sources which answer 95 percent
of my questions. Sorry, unforgivable, too much readin', too little
time, darn homework, (fake excuses, uhm). :-(
Birgitt Funk
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 01 Jul 1998 15:06:40 -0700
From: news@russo.org (Chris Russo)
Subject: Re: detecting time of day
Message-Id: <news-0107981506400001@buzz.hq.alink.net>
In article <6ndsnm$a0l$10@engnews2.Eng.Sun.COM>,
bday@mtv03install2.eng.sun.com wrote:
>I have another newbie question. Is there some way of detecting the time
with Perl.
>I thought I remember hearing something about that.
I noticed that you have a couple of very basic questions posted to
comp.lang.perl.misc today. Not that there's anything wrong with being new
and all, but could you please take some time to read the documentation
that comes with perl before posting a bunch of questions that you could
just as easily solve yourself?
You might also take a look at the FAQ and other resources available from
www.perl.com & www.perl.org:
<http://language.perl.com/faq/>
After you've taken a look at those resources, you'll find that there are
plenty of people here who would be happy to help you past any major
hurdles.
Regards,
Chris Russo
--
Chris Russo
news@russo.org
http://www.russo.org
------------------------------
Date: Wed, 01 Jul 1998 21:26:02 GMT
From: abraham@mpi.com
Subject: Re: How do you pre-append using "open"
Message-Id: <6ne9h9$9u9$1@nnrp1.dejanews.com>
In article <6ndnhg$467$3@news.iastate.edu>,
kortbein@iastate.edu (Josh Kortbein) wrote:
>
> Earl Hood (ehood@geneva.acs.uci.edu) wrote:
> : In article <Pine.GSO.3.96.980618195259.17544J-100000@user2.teleport.com>,
> : Tom Phoenix <rootbeer@teleport.com> wrote:
> : >On Fri, 19 Jun 1998, Nick Forte wrote:
> : >
> : >> I'm trying to pre-append a record to a flat file. I want the record to
> : >> be inserted on the first line everytime instead of appending it to the
> : >> end. Can someone help me?
> : >
> : >Section five of the FAQ has an entry on this oxymoronic notion of
> : >"appending to the beginning" of a file. Hope this helps!
>
> : Actually, it is not oxymoronic. "append" means to attach or affix.
> : There is no notion of location. So making the statement, "append to
> : the beginning" is okay since it explicitly states where the data
> : should be attached.
>
> That may be the "actual" denotation, but "append" is commonly
> understood to refer to attaching at the end.
>
Append is from Latin ad + pendare, meaning literally "attach to" or "hang
onto". The word prepend results from the linguistic phenomenon called
analogy. In this case, because "append," which as you say carries no
connotation of location, becomes commonly used to refer only to the
attachment of something to the end of something else, a converse expression
"prepend" is created, probably on analogy with suffix (sub + facio), prefix
(pre + facio).
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 1 Jul 1998 17:24:14 -0500
From: "David" <dcunningham@detnet.com>
Subject: I NEED SOME HELP
Message-Id: <6ned7n$b6e$1@supernews.com>
Hi all! I know this may sound pretty clueless, but I'm running IIS 3.0 and
NT 4, and have perl5 installed properly ( I think), but I don't understand
how to run the perl scripts from the web. I am basically trying to create
forms for different Web uses. I understand that the script is going to
process the form info., but I don't understand how to integrate the html
with the perl. If someone can help me, I realize it may take awhile, but I
would appreciate it. My ICQ # is 2356968 and my email address is
wbj1@cornell.edu.
Thanks alot.
Will Jacobs
------------------------------
Date: 1 Jul 1998 20:43:26 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Invalid regexp in grep
Message-Id: <6ne71e$qd@mozo.cc.purdue.edu>
s_emery@my-dejanews.com writes:
}I can't seem to grep a certain array because I get an error of invalid
}regexp.
This is true. You're using a character class incorrectly. Re-read
the regexp stuff, on using [7-176] again.
}This is the idea of the programming:
}@a = (1 ,2, 5, 22, 84, 129, 205);
}@b = grep (/[7-176]/, @a);
#This is pretty stratightforward--a quick look through perfunc should
#clear up any questions.
@b = grep { $_ >= 7 && $_ <= 176 } @a;
}Greping is a whole lot faster than attempting to make a for loop.
}If there is a way around this please tell me.
I'm not getting "whole lot faster" on this end. A bit faster, maybe.
Benchmark: timing 100000 iterations of foreach, grep...
foreach: 9 secs ( 8.40 usr 0.00 sys = 8.40 cpu)
grep: 7 secs ( 6.27 usr 0.00 sys = 6.27 cpu)
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Wed, 01 Jul 1998 16:55:32 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Invalid regexp in grep
Message-Id: <359AA244.3BE1E1D4@negia.net>
s_emery@my-dejanews.com wrote:
>
> I can't seem to grep a certain array because I get an error of invalid
> regexp.
>
> This is the idea of the programming:
>
> @a = (1 ,2, 5, 22, 84, 129, 205);
>
> @b = grep (/[7-176]/, @a);
i think you are a bit confused. what the above tells me is that you
want a number between 7 and 1, incrementing by one (huh?), or 7, or 6.
note that the regex compiles as long as the first digit of your upper
limit is greater than or equal to the lower limit. that is why 99
worked and so will 999999999.
i question why you are using regexes if you are trying to determine
if numbers are within a certain range. how about:
@b = grep $_ >= 7 && $_ <= 176, @a;
cheers,
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: 1 Jul 1998 21:17:49 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Invalid regexp in grep
Message-Id: <6ne91t$o4n$2@info.uah.edu>
In article <6ne52q$4it$1@nnrp1.dejanews.com>,
s_emery@my-dejanews.com writes:
: I can't seem to grep a certain array because I get an error of invalid
: regexp.
:
: This is the idea of the programming:
:
: @a = (1 ,2, 5, 22, 84, 129, 205);
:
: @b = grep (/[7-176]/, @a);
You almost certainly don't want to do that.
@b = grep($_ >= 7 && $_ <= 176, @a);
Greg, who still thinks grep BLOCK looks a whole lot nicer
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Wed, 1 Jul 1998 15:41:16 -0700
From: twerner@hmc.edu (Tom Werner)
Subject: Low level Windows event execution via Perl
Message-Id: <MPG.10045ae41348fcf1989682@news.hmc.edu>
I'm writing some Perl scripts that I need to be able to execute a low
level "open" event on a file. That is, I need some way to tell a given
program to open a given file on a Windows platform. I've looked into
Window's DDE scripting language, but from what I've read, Perl doesn't
support DDE. I've also read about Perl's IPC, but don't see how that
could lead to a solution. If you have any insight on this problem, I
would appreciate hearing from you. Thanks.
Tom Werner
------------------------------
Date: 1 Jul 1998 21:34:25 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: passing a ref to a subroutine, problem with use strict
Message-Id: <6nea11$o4n$3@info.uah.edu>
In article <6ne5rl$9qd$0@206.165.146.67>,
due@murray.fordham.edu (Allan M. Due) writes:
: You can change the
: search_on and search_for variables and it works fine. But if you
: include use strict you have to include a my in front of the
: ($animal,$color,$name) = split(/\,/,$I);
: line and when you do that you receive the error message:
: Can't use string ("color") as a SCALAR ref while "strict refs" in use
That's because you have three dollar signs. It works without use strict
(as long as $animail, $color, and $name aren't lexicals). use strict
turns off the ability to use soft references like this.
If you want to search on different fields, why not do something like
#! /usr/local/bin/perl -w
use strict;
use constant ANIMAL => 0;
use constant COLOR => 1;
use constant NAME => 2;
my @data = (
'dog,black,sparky',
'cat,black,socks',
'dog,white,fido'
);
my $search_on = COLOR;
my $search_for = "bl";
## no need to pass references to these scalars that we're not
## going to change
&search ($search_on, $search_for,\@data);
foreach (@data) {
print "$_\n";
}
sub search {
my $record;
my @keep_array;
my @tmp;
my($field,$find,$recs_ref) = @_;
foreach $record (@$recs_ref) {
@tmp = split /,/, $record;
if ($tmp[$field] =~ /$find/i) {
push @keep_array, $record;
}
}
@$recs_ref = @keep_array;
}
Hope this helps,
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Wed, 01 Jul 1998 23:55:28 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
To: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: passing a ref to a subroutine, problem with use strict
Message-Id: <359AC008.6651E121@shaw.wave.ca>
Allan M. Due wrote:
>
> But if you
> include use strict you have to include a my in front of the
> ($animal,$color,$name) = split(/\,/,$I);
> line and when you do that you receive the error message:
> Can't use string ("color") as a SCALAR ref while "strict refs" in use
Because strict refs doesn't like soft refs, which you are using. If
you're going to be using keys, then you should try a hash.
> ($animal,$color,$name) = split(/\,/,$i);
> if ($$$key_ref =~ /$$search_ref/i) {
my %value;
@value{qw(animal color name)) = split(/\,/,$i);# hash slice
if ($value{$key} =~ /$search/i) {
No need to pass references to $key or $search. You might want to
quotemeta($search) if it might have pattern-match meta-characters.
HTH.
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Wed, 01 Jul 1998 18:47:03 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Passing arguments to perl CGI
Message-Id: <comdog-ya02408000R0107981847030001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6nbpti$mvj$1@news.rt66.com>, mikep@rt66.com (mikep) posted:
>I'm using a perl script as a CGI script. I'd like to pass arguments to
>it. What is the appropriate syntax to interact with the HTTP server
>(e.g. is there one general way in which parameters are passed to a CGI
>script?)? Once I pass the arguments, how do they appear to the script
>itself (e.g. in the $ARGV built-in variable?)?
the CGI Meta FAQ has references to everything you need to know,
the Perl specific information.
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers T-shirts! <URL:http://www.pm.org/tshirts.html>
------------------------------
Date: 1 Jul 1998 21:32:03 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: perl and secured payment online?
Message-Id: <6ne9sj$lsi$2@client3.news.psi.net>
DUTOIT (abcdm@wanadoo.fr) wrote on MDCCLXV September MCMXCIII in
<URL: news:01bda509$0184a1c0$a894fcc1@SIT.wanadoo.fr>:
++ Hello,
++
++ I'ld want to use an https protocol in a form.
++
++ I know it's necessary to put , after the Content-type of this HTML page a
++ command wich permits to secure the payment (not broken blue left key of
++ the screen).
++
++ What is the command to do that in Perl?
print
But you have to figure out what to print outside this newsgroup.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Wed, 01 Jul 1998 21:58:14 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
Subject: Perl At Work
Message-Id: <359AB0F6.1FC8B2AF@dial.pipex.com>
Hello All,
Is this a sensitive subject, but how many people here actually use Perl
as part of their daily work? If this is the wrong place to ask, then
could someone point me (and probably others too!) in the right
direction.
For a while now I've been getting itchy feet, mainly because I've been
learning a lot of Perl at work, and getting paid for it I suppose. I
maintain our company's web site and write all of the CGI scripts along
with a couple of sizable online applications (is a 9000+ line Perl
script large?).
Unfortunately my company does not have much of an Internet 'culture',
the various managers love to discuss Java but are not prepared to pay
those kind of wages, to be honest their not actually sure what it's used
for (actually neither am I, but I do remember seeing a pretty cool
Missile Command game somewhere!). The mere mention of Perl at work
causes stares of incomprehension, but I reckon that Perl's market
penetration is far greater than Java's will ever be, at least for the
time being.
The bottom line is, what is the going rate for Perl programmers,
including satellite functions such as webmastering, maintenance etc? In
the UK!
Is there some way of gauging one's skills in Perl against others, to
determine one's level of expertise? I've been using Perl seriously for
over a year now, for both web projects and one off utilities.
Is there some kind of Perl 'exam' on the Internet at all?
Just some thoughts,Sorry if I ramble a bit...
Bye!
--
sub jasonHolland {
my %hash = ( website =>
"http://dspace.dial.pipex.com/jason.holland/",
email => "jason.holland@dial.pipex.com" );
}
------------------------------
Date: Wed, 1 Jul 1998 22:30:04 GMT
From: jkaplan@world.std.com (Jeffrey Kaplan)
Subject: Re: perl newbie Q: Any ideas why this doesn't work?
Message-Id: <359bb7b6.4743765@news.std.com>
Drifting in hyperspace, I had plenty of time to read this memoir from
F.Quednau:
; That is, you have a shell open, and you type perl -v and then it comes out with
; a similar message as above? But if you try to execute a script, nothing comes?
Right.
; How are you trying to execute those programs?
By entering the name of the script on the command line and hitting
<enter>.
; 1. Your shell doesn't support the shebang line (#!)
It does. tcsh is a standard, full function shell.
; 2. Your script isn't set to be excutable, but you are assuming it (OUCH!)
; => set your file to be executable (man chmod)
-rwxrwx--- 1 jkaplan jkaplan 127 Jul 1 02:59 test*
------------------------------
Date: Wed, 01 Jul 1998 22:48:34 GMT
From: larrym@imsi.com (Larry Martell)
Subject: problem with system and ftp
Message-Id: <6neebj$l2h@titan.imsi.com>
I have a file, call it ftp.in, with some ftp commands:
open remote_host
user user passwd
ascii
cd /some/dir
put testFile
get testFile /tmp/GetItBack
bye
And from perl I want to: system("/usr/ucb/ftp -in < ftp.in")
Should work, right? If I invoke that same command from the shell it works.
Well, from perl it hangs - ftp is prompting for a passwd.
I've found that perl invokes "sh -c /usr/ucb/ftp -in < ftp.in", and if I run
that it indeed hangs:
# sh -c /usr/ucb/ftp -in < ftp.in
Password:
I found that if I quote it thusly: sh -c "/usr/ucb/ftp -in < ftp.in" it does
work from the shell, but if I change the system command to:
system("'/usr/ucb/ftp -in < ftp.in'")
It complains:
sh: /usr/ucb/ftp -in < ftp.ftp: not found
How can I system this from perl?
TIA,
larry
--
Larry Martell "When I do good, I feel good. When I do bad,
larrym@imsi.com I feel bad. And that is my religion."
------------------------------
Date: Wed, 01 Jul 1998 22:50:15 GMT
From: larrym@imsi.com (Larry Martell)
Subject: problem with system and ftp
Message-Id: <6neeep$l33@titan.imsi.com>
I have a file, call it ftp.in, with some ftp commands:
open remote_host
user user passwd
ascii
cd /some/dir
put testFile
get testFile /tmp/GetItBack
bye
And from perl I want to: system("/usr/ucb/ftp -in < ftp.in")
Should work, right? If I invoke that same command from the shell it works.
Well, from perl it hangs - ftp is prompting for a passwd.
I've found that perl invokes "sh -c /usr/ucb/ftp -in < ftp.in", and if I run
that it indeed hangs:
# sh -c /usr/ucb/ftp -in < ftp.in
Password:
I found that if I quote it thusly: sh -c "/usr/ucb/ftp -in < ftp.in" it does
work from the shell, but if I change the system command to:
system("'/usr/ucb/ftp -in < ftp.in'")
It complains:
sh: /usr/ucb/ftp -in < ftp.ftp: not found
How can I system this from perl?
TIA,
larry
--
Larry Martell "When I do good, I feel good. When I do bad,
larrym@imsi.com I feel bad. And that is my religion."
------------------------------
Date: 1 Jul 1998 21:28:55 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: problems with script
Message-Id: <6ne9mn$lsi$1@client3.news.psi.net>
Matt Knecht (hex@voicenet.com) wrote on MDCCLXV September MCMXCIII in
<URL: news:pctm1.16$Du.105291@news2.voicenet.com>:
++ Abigail <abigail@fnx.com> wrote:
++ >Good for obfuscating?????? I use that construct all the time, in any
++ >language that has arrays, and I never use parens for that. Are you
++ >really suggesting that it should be written as:
++ >
++ > $foo = ($bar [3]) + 3; ????
++
++ No, I don't find the lack of parentheses distressing. I find the extra
++ space objectionable. I would write that as:
++
++ $foo = $bar[3] + 3;
++
++ >Oh, ok. Let me give some C examples then:
++ >
++ > foo = bar [3] + 3; /* Parens? */
++ > foo = *bar + 3; /* Parens? */
++ > foo (3) || bar (3); /* Parens? */
++
++ No in all three cases. I see your point when you use simple
++ expressions. In fact, excepting the spaces, I write the exact same way.
++
++ I wasn't trying to advocate the use of parentheses in _every_ expression
++ where precedence comes up. However, I do think their use in anything
++ other than basic expressions does help, even if they are redundant.
Uhm, you were quoting a rule that basically said parens could only be
omitted when dealing with multiplication/division vs addition/subtraction.
++ This holds especially true if you're trying to write maintainable code.
++ While I don't have a hard fast rule, I think when you get to more than 3
++ or so conditionals, it's a good idea to start bracing things the way you
++ want them.
Why? Even if I have 358 conditionals, if they are in subjective normal
form, there is no need for parens. I would usually format it such
that it is clear though.
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
------------------------------
Date: Wed, 01 Jul 1998 21:53:34 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: problems with script
Message-Id: <ydym1.25$rf1.302765@news3.voicenet.com>
Abigail <abigail@fnx.com> wrote:
>++ I wasn't trying to advocate the use of parentheses in _every_ expression
>++ where precedence comes up. However, I do think their use in anything
>++ other than basic expressions does help, even if they are redundant.
>
>Uhm, you were quoting a rule that basically said parens could only be
>omitted when dealing with multiplication/division vs addition/subtraction.
I see your confusion. Maybe I should've been more explicit in my last
reply.
You've convinced me that this probably isn't the best rule. I can't say
it clearer than that!
>++ This holds especially true if you're trying to write maintainable code.
>++ While I don't have a hard fast rule, I think when you get to more than 3
>++ or so conditionals, it's a good idea to start bracing things the way you
>++ want them.
>
>Why? Even if I have 358 conditionals, if they are in subjective normal
>form, there is no need for parens. I would usually format it such
>that it is clear though.
Well, that about does it then. You prefer to use whitespace, while I
prefer parentheses in these situations.
I humbly vow to try and stay out of the next five religious wars that
rage across clpm. Which means I should be posting in one some time next
week. :)
--
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"
------------------------------
Date: 01 Jul 1998 22:15:00 +0200
From: haert@wharp.rhein-main.de (Michael Haertfelder)
Subject: problems: compiling module with nmake
Message-Id: <6x2o5xXVZZB@wharp.rhein-main.de>
Hi,
I tried to compile a module (Readkey) with perl V500402 under WInNt40 with
VisualCpp50 and got an error (see end of this message). DOn't bother the
Carrigae Returns I used for better reading.
When I entered
perl Makefile.Pl
first, I got the "usage xsubpp" message, but an Makefile is generated
successfully (?). However a Readkey.c file is referenced in this Makefile
despite the fact that no Readkey.c file is provided by the author (I got
all the stuff from CPAN) only Readkey.xs.
SO what's the problem ?
Thanx in advance
Michael
D:\tmp>nmake
Microsoft (R) Program Maintenance Utility Version 1.62.7022
D:\PERL\V500402\BIN\perl -Id:\perl\V500402\lib -Id:\perl\V500402\lib
D:\perl\V500402\lib\ExtUtils/xsubpp
-typemap D:\perl\V500402\lib\ExtUtils\typemap ReadKey.xs
>ReadKey.tc && D:\PERL\V500402\BIN\perl -Id:\perl\V500402\lib
-Id:\perl\V500402\lib -MExtUtils::Command -e mv ReadKey.tc ReadKey.c
Usage: xsubpp [-v] [-C++] [-except] [-prototypes] [-noversioncheck]
[-nolinenumbers] [-s pattern] [-typemap typemap]... file.xs
NMAKE : fatal error U1077: D:\PERL\V500402\BIN\perl.exe' : return code '0x2'
Stop.
------------------------------
Date: Wed, 01 Jul 1998 22:27:14 GMT
From: sdreyer@writeme.com
Subject: Sorting Database Entries
Message-Id: <6ned41$eg5$1@nnrp1.dejanews.com>
Hi.
I4m running a flat-file ASCII-Database with a "|"-Delimiter.
Here4s an example from the file:
---
04|July|98|Bndname|ID|Location|21|City
---
Now, I4d like to sort the results by date, which will be put out of the
Perl-Script after a keyword-search.
(First by year, then by month, then by day.)
I4m messing up with the "Sort"-function, but I get no further.
Does anybody have an idea, how or where to get such a script-snippet ?
Thanks,
Stephan
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 01 Jul 1998 22:59:55 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Sorting Database Entries
Message-Id: <Lbzm1.35$rf1.332576@news3.voicenet.com>
sdreyer@writeme.com <sdreyer@writeme.com> wrote:
>04|July|98|Bndname|ID|Location|21|City
>
>Now, I4d like to sort the results by date, which will be put out of the
>Perl-Script after a keyword-search.
>(First by year, then by month, then by day.)
>
>Does anybody have an idea, how or where to get such a script-snippet ?
I just answered an extremly similar question here only a few hours ago.
The message should still be in your news spool. Look for message id
<2jwm1.21$Du.237526@news2.voicenet.com> with the subject "Re: HELP....!
Very simple array sort question!".
It's almost exactly the same question, except that you have the
additional need to sort on multiple fields, which 'perldoc -f sort'
should show you how to do.
--
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"
------------------------------
Date: Wed, 01 Jul 1998 14:02:21 -0700
From: Blake Mitchell <mitchell@ilog.com>
To: mitchell@ilog.com
Subject: time out for IO::Socket::accept()
Message-Id: <359AA3DD.8AE0BFAD@ilog.com>
Hello,
Is it possible to set a time out for a $socketref->accept call. Perhaps
someone knows some sort of hack to set a timer or something that I could
use to break ot of the function after a specified time. Or even better,
if there were some way to poll the listener to see if there were any
pending connections to be accepted.
Thank you,
Blake
--
Blake Mitchell Hotline: 650/944-7195
Technical Support Voice: 650/390-9000
ILOG, Inc. Fax: 650/390-0946
1901 Landings Drive http://www.ilog.com
Mountain View, CA 94043 mitchell@ilog.com
------------------------------
Date: 1 Jul 1998 22:47:00 GMT
From: psh@euclid.jpl.nasa.gov (Peter Scott)
Subject: Using goto & with SUPER::
Message-Id: <6nee94$hb3@netline.jpl.nasa.gov>
I have a tied hash whose object I want to create from an inherited
constructor, viz and e.g.:
----------------
package Bar;
sub new {
print "new, args = @_\n";
return bless { @_[1..$#_] }, shift;
}
package Foo;
@ISA = qw(Bar);
sub TIEHASH {
my $class = $_[0];
print "Tie, args = @_\n";
goto &$class->SUPER::new; # ***
}
package main;
tie %h, Foo, dog => 'bark', cat => 'meow';
$obj = tied %h;
----------------
Using the "highly magical" goto & on the *** line seemed logical,
but I can't get it to work; the output is:
Tie, args = dog bark cat meow
Undefined subroutine &Foo::Foo called at /tmp/foo line 17.
I can get what I want (absent the magical stack frame effect of the goto &,
no big deal) by changing that line to
$class->SUPER::new(@_);
provided I also shift the class out of @_ two lines earlier since the
method call puts it back.
But I'm just curious why I got the result I did and whether there's a way
to use goto & in that situation.
ObRTFM: I read perlobj, perlbot (inheritable constructors), perltoot,
and perlfunc (goto &) first.
This was Perl 5.004_04 on Solaris 2.5.1.
--
This is news. This is your | Peter Scott, NASA/JPL/Caltech
brain on news. Any questions? | (psh@euclid.jpl.nasa.gov)
Disclaimer: These comments are the personal opinions of the author, and
have not been adopted, authorized, ratified, or approved by JPL.
------------------------------
Date: 1 Jul 1998 21:23:26 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Vertical Perl
Message-Id: <899328761.951713@thrush.omix.com>
RICHARD PROULX <richard.proulx@sun.com> wrote:
: I am trying to print text out vertically from it's horizontal
: input:
: e.g.
: Input = 'string'
: Output = 's
: t
: r
: i
: n
: g'
$string = 'string';
@charArray = split //, $string;
$output = join "\n", @charArray;
print $output;
Or, in one line:
print join ("\n", split (//, "string"));
: Questions:
: Is there a way to access string elements like
: $string[2] = "t" for aboce example
Split the string on null, the things that don't exist between
chars.
@string = split //, "string";
print $string[2]; # prints 'r'
: Is there a such thing as character arrays like:
: $character_array = (80,24) where $character_array[0,0] gives you the top
: row, left column character of the array.
# build it
while (<>) {
my @chars = split //, $_;
push @character_array, \@chars; # Note the \
}
## X Y
print $character_array[80][24]; # single value
print @{ $character_array[80] }; # array of all Y's of X80
See man pages perllol, perldsc, and perlref for details.
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: Wed, 1 Jul 1998 13:49:13 -0700
From: "Igor Krivokon" <igor.k@usa.net>
Subject: Re: Virtual functions.
Message-Id: <6ne7ed$3vs$1@news.ncal.verio.com>
John Porter wrote in message <359A7FB6.7072@min.net>...
>Oleg Beregovich wrote:
>>
>> Can I have pure virtual functions implemented in package.
>> I want to overload it in derived packages (I will have this function
>> overloaded in more than one package). If its possible could somebody
>> write few lines as an example.
>
>Well, you can't have "pure virtual" methods in the C++ sense, where
>they *must* be overridden by the derived class or else kablooi.
>But you can get the same effect by writing it that way:
>
>class Parent;
>
>sub good_looks {
> my $self = shift;
> die "Error: called $self->good_look( @_ ), not overridden!";
>}
...
Probably, it helps; but that's not the same effect.
Using C++ pure virtual functions, you get an error message
1) when you try to instantiate your class (not when you call the function)
2) in compile time
Igor Krivokon
<igor.k@usa.net>
---
"Instead of referring to pi as 3.141592653589793 at every appearance, the
variable PI can be given that value with a DATA statement and used instead
of the longer form of the constant. This also simplifies modifying the
program, should the value of pi change" (Fortran manual for Xerox Computers)
------------------------------
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 3041
**************************************