[15778] in Perl-Users-Digest
Perl-Users Digest, Issue: 3191 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 28 18:15:36 2000
Date: Sun, 28 May 2000 15:15:25 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <959552125-v9-i3191@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 28 May 2000 Volume: 9 Number: 3191
Today's topics:
reading line number <wes_hutton@hotmail.com>
Re: reading line number (Tad McClellan)
Re: reading line number <dave@dave.org.uk>
Re: reading line number (Steven Smolinski)
Re: reading line number <dave@dave.org.uk>
Re: reading line number (Philip 'Yes, that's my address' Newton)
Re: ref-to-glob error (*in) <sean77@dds.nl>
RegEx newbie@db-networks.com
Re: remove leading space with regex <rick.delaney@home.com>
Re: Replace a string with another <joeb@jagas.demon.co.uk>
setting main:: variables from a library file <sean77@dds.nl>
Re: Should be in FAQ: "I can't find Net::SMTP" <gellyfish@gellyfish.com>
Re: simple regexp question (Philip 'Yes, that's my address' Newton)
Re: simple regexp question (Bart Lateur)
some questions about perl format <huxh@990.net>
Re: some questions about perl format (Philip 'Yes, that's my address' Newton)
Re: Tanspose rows to columns <iltzu@sci.invalid>
Weird script behaviour called from a web page. (Thaddeus L. Olczyk)
Re: Weird script behaviour called from a web page. <dave@dave.org.uk>
What do I need to write my first perl program?? <N.Hemp@wanadoo.fr>
Re: What do I need to write my first perl program?? <carvdawg@patriot.net>
Re: What do I need to write my first perl program?? <wellhaven@worldnet.att.net>
Re: What do I need to write my first perl program?? <y-o-y@home.com>
Re: What do I need to write my first perl program?? <kenny@kenny.co.uk>
Re: What package does "xsubpp" belong to and where are <dan@tuatha.sidhe.org>
writing SMTP daemon in perl amir@infoteen.com
Re: writing SMTP daemon in perl <tony_curtis32@yahoo.com>
Re: writing SMTP daemon in perl amir142@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 28 May 2000 22:56:47 +1000
From: "wes" <wes_hutton@hotmail.com>
Subject: reading line number
Message-Id: <vx8Y4.7149$c5.10613@newsfeeds.bigpond.com>
I am trying to store the current line number of the file that I have open,
the command printf ("%1d", $.) prints the correct line number - is there any
way to redirect this number to a variable, ie $cur_line = `printf ("%1d",
$.)`, or is there a different command I can use?
Thanks in advance
Wes
------------------------------
Date: Sun, 28 May 2000 09:05:53 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: reading line number
Message-Id: <slrn8j26dh.3cc.tadmc@magna.metronet.com>
On Sun, 28 May 2000 22:56:47 +1000, wes <wes_hutton@hotmail.com> wrote:
>I am trying to store the current line number of the file that I have open,
>the command printf ("%1d", $.) prints the correct line number - is there any
>way to redirect this number to a variable, ie $cur_line = `printf ("%1d",
>$.)`, or is there a different command I can use?
perldoc -f sprintf
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 28 May 2000 16:01:53 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: reading line number
Message-Id: <56d2jss1rr5i6sj5k9uskubl4b9jt9ma19@4ax.com>
On Sun, 28 May 2000 22:56:47 +1000, "wes" <wes_hutton@hotmail.com>
wrote:
>I am trying to store the current line number of the file that I have open,
>the command printf ("%1d", $.) prints the correct line number - is there any
>way to redirect this number to a variable, ie $cur_line = `printf ("%1d",
>$.)`, or is there a different command I can use?
Read about the 'sprintf' function.
perldoc -f sprintf
hth,
Dave...
--
<http://www.dave.org.uk> SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>
"There ain't half been some clever bastards" - Ian Dury [RIP]
------------------------------
Date: Sun, 28 May 2000 15:35:06 GMT
From: sjs@yorku.ca (Steven Smolinski)
Subject: Re: reading line number
Message-Id: <slrn8j2f12.old.sjs@john.sympatico.ca>
Dave Cross <dave@dave.org.uk> wrote:
>"wes" <wes_hutton@hotmail.com> wrote:
>>I am trying to store the current line number of the file that I have open,
>>the command printf ("%1d", $.) prints the correct line number - is there any
>>way to redirect this number to a variable, ie $cur_line = `printf ("%1d",
>>$.)`, or is there a different command I can use?
>Read about the 'sprintf' function.
>perldoc -f sprintf
Why is there a printf involved at all? print $. should have the same
results as printf( "%1d", $. ) in my tests.
If you don't need to use any more formatting than "%1d", then why not
just go with less expensive statements like print $. to print it and:
my $saved_line_no = $.;
to save it. There's no need to bother with the formatted functions if
you need no formatting.
Steve
------------------------------
Date: Sun, 28 May 2000 16:39:47 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: reading line number
Message-Id: <bbf2jsci1d6dcb898kf3qqp6r8tmduemv1@4ax.com>
On Sun, 28 May 2000 15:35:06 GMT, sjs@yorku.ca (Steven Smolinski)
wrote:
>Dave Cross <dave@dave.org.uk> wrote:
>>"wes" <wes_hutton@hotmail.com> wrote:
>
>>>I am trying to store the current line number of the file that I have open,
>>>the command printf ("%1d", $.) prints the correct line number - is there any
>>>way to redirect this number to a variable, ie $cur_line = `printf ("%1d",
>>>$.)`, or is there a different command I can use?
>
>>Read about the 'sprintf' function.
>>perldoc -f sprintf
>
>Why is there a printf involved at all? print $. should have the same
>results as printf( "%1d", $. ) in my tests.
>
>If you don't need to use any more formatting than "%1d", then why not
>just go with less expensive statements like print $. to print it and:
>
>my $saved_line_no = $.;
>
>to save it. There's no need to bother with the formatted functions if
>you need no formatting.
True enough. I should have looked a bit closer at the format string. I
assumed that the OP was using something like
printf("%03d". $.);
in which case it _is_ doing a useful job.
Cheers,
Dave...
--
<http://www.dave.org.uk> SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>
"There ain't half been some clever bastards" - Ian Dury [RIP]
------------------------------
Date: Sun, 28 May 2000 16:09:17 GMT
From: nospam.newton@gmx.li (Philip 'Yes, that's my address' Newton)
Subject: Re: reading line number
Message-Id: <393136de.380955985@news.nikoma.de>
On Sun, 28 May 2000 22:56:47 +1000, "wes" <wes_hutton@hotmail.com>
wrote:
> I am trying to store the current line number of the file that I have open,
> the command printf ("%1d", $.) prints the correct line number
You don't need to use printf; just print is fine: print $.;
> - is there any
> way to redirect this number to a variable, ie $cur_line = `printf ("%1d",
> $.)`, or is there a different command I can use?
You can use $curline = sprintf("%ld", $.); if you absolutely want,
but it's probably a lot easier to just say $curline = $.; . At its
heart, $. is just a variable like any other. Remember, in Perl, numbers
and strings are interchangeable (nearly) anywhere, so you don't need to
use sprintf to go from number to string (unless you want rounding or
leading zeroes or similar), nor is there an atof to from from string to
number.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sun, 28 May 2000 00:23:08 +0200
From: "Seansan" <sean77@dds.nl>
Subject: Re: ref-to-glob error (*in)
Message-Id: <39315772$0$13229@reader4.casema.net>
Seansan <sean77@dds.nl> schreef in berichtnieuws
392e5b16$0$6810@reader4.casema.net...
> I dont understand this next line.
> I mean the star next to in (*in)
> I use it in a library file, but saw it somewhere and
> wondered why they use it.
> what does it mean ??
>
> my (*in) = shift if @_; # CGI input
>
>
for you who found this too.
It's an old way of referencing a variable outside the subroutine. If you
dont use my / local you would actually get the same effect, but no name can
be passed.
cgi-lib.pl use(d)s this style and makes it possible to read in POST/GET
characters and put it in a (Self made up) Hash.
What you do is make a hole that when the $in, @in or %in is used in the
module/sub the actual passed variable name in main:: is used.A
Globbing as it is called has one problem. When you want to use only a hash,
the globbing makes the string, array and hash.
Perl 5. now has referencinc, so this problem can ideed better be solved by
using the refernce structure.
Sean
------------------------------
Date: Sun, 28 May 2000 21:42:23 GMT
From: newbie@db-networks.com
Subject: RegEx
Message-Id: <td33jskocaa080slol0i43kpveg7e33lpc@4ax.com>
I have a file: noise.txt with
A
B
C...
I have a data file:
my ($infile, $outfile, $line, $counter, $unique, $item, $element,
$keywords);
my (@noisewords, @data, @tosave, @words, @request);
$infile = "Pass02.txt";
$outfile = "Pass03.txt";
open (NOISE, "< noise.txt") or die "Could not open NOISE WORDS for
read";
open (INPUT, "< $infile") or die "Could not open $infile for read";
open (OUTPUT, "> $outfile") or die "Could not open $outfile for
write";
@noisewords = (); ## make sure array is empty
while (<NOISE>) {
chomp;
push(@noisewords, $_);
}
while(<INPUT>) {
chomp;
undef @data;
undef @words;
undef @tosave;
%seen = 0;
push(@data, defined($1) ? $1:$3)
while m/([^,]+)/g; ## extract fields comma from CSV
@words = split(/ /, uc($data[0]));
foreach $element(@words) {
$element =~ s/(2A)/ /g; ## remove *
$element =~ s/(2B)/ /g; ## remove +
$element =~ s/(3C)/ /g; ## remove <
$element =~ s/(3F)/ /g; ## remove ?
$element =~ s/\W/ /g; ## remove non words
$element =~ s/\d/ /g; ## remove all digits
}
foreach $item (@noisewords) { ## build lookup table
$seen{$item} = 1
}
foreach $item (@words) { ## only elements in @words but not
noise
unless ($seen{$item}) { ## it's not in %seen==>save
push(@tosave, $item)
}
}
$keywords = join(" ",@tosave);
$keywords =~ s/\s+/ /g;
$keywords =~ s/^\s+//;
$keywords =~ s/\s+$//;
if (length($keywords) > 0){
$counter ++;
$unique = sprintf("%010d",($counter));
print OUTPUT $unique . "," . $data[0] . "," . $keywords . "\n";
}
}
close(INPUT);
close(CLEANED);
The input is:
%u05D6%u05D9%u05D9%u05DF
P7#NPP@CHS=.QP:A6,
P@CHS=.QP:A6
P@CHS=.QP:A6
PA2049U
The outpout should be:
0000000567,%u05D6%u05D9%u05D9%u05DF,DF,
0002037551,P7#NPP@CHS=.QP:A6,NPP CHS
0002037601,P@CHS=.QP:A6,CHS QP
0002037651,P@CHS=.QP:A6,CHS QP
0002037801,PA2049U,PA
The output is:
0000000567,%u05D6%u05D9%u05D9%u05DF,U D U D U D U DF
0002037551,P7#NPP@CHS=.QP:A6,P NPP CHS QP A
0002037601,P@CHS=.QP:A6,P CHS QP A
0002037651,P@CHS=.QP:A6,P CHS QP A
0002037801,PA2049U,PA U
The single letters should have been filtered out by the noise file.
What am I missing?
------------------------------
Date: Sun, 28 May 2000 05:23:43 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: remove leading space with regex
Message-Id: <3930AEC0.A6EAA977@home.com>
[posted & mailed & cc perlbug]
Cure wrote:
>
> s/(?!\A)^ //mg;
> $_ contains the string "a\n b\n c\n d\n";
>
> the regex is supposed to remove the LEADING space at the beginning of
> each "line" except the first "line"
>
> but its not working
> help!
It would help to say what doesn't work. Printing $_ after substitution
gives:
a
b
c
d
which is obviously wrong. One work-around is
s/(?<=\n) //g;
Now, some more data points for p5p. This may be related to ticket
20000405.017.
$ perl -Mre=debug -e 'qq{a\n b\n}=~/(?!\A) /' 2>noqr
$ perl -Mre=debug -e 'qq{a\n b\n}=~/(?!\A) /m' 2>noqrm
$ perl -Mre=debug -e '$re=qr/(?!\A) /m;qq{a\n b\n}=~$re' 2>qrm
$ perl -Mre=debug -e '$re=qr/(?!\A) / ;qq{a\n b\n}=~$re' 2>qr
Files noqr, qr and qrm are identical and correct. Here's the difference
between them and the wrong noqrm.
*** qrm Sun May 28 01:21:36 2000
--- noqrm Sun May 28 01:16:12 2000
***************
*** 14,32 ****
Guessed: match at offset 2
Matching REx `(?!\A) ' against ` b
'
! Setting an EVAL scope, savestack=3
2 <a
> < b
> | 1: UNLESSM[-0]
2 <a
> < b
> | 3: SBOL
- failed...
2 <a
> < b
! > | 6: EXACT < >
! 3 <a
! > <b
! > | 8: END
! Match successful!
Freeing REx: `(?!\A) '
--- 14,29 ----
Guessed: match at offset 2
Matching REx `(?!\A) ' against ` b
'
! Setting an EVAL scope, savestack=6
2 <a
> < b
> | 1: UNLESSM[-0]
2 <a
> < b
> | 3: SBOL
2 <a
> < b
! > | 4: SUCCEED
! could match...
! failed...
Freeing REx: `(?!\A) '
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sun, 28 May 2000 15:28:31 +0100
From: JoeB <joeb@jagas.demon.co.uk>
Subject: Re: Replace a string with another
Message-Id: <39312D0F.98079471@jagas.demon.co.uk>
Many Thanks to you all.
JoeB wrote:
> Hello All,
>
> I need a function that will take a word and replace it with another as
> in:
> "Mango and Fruit" I want this string to be "Mango +Fruit"
> I have tried:
> my $vale = "Mango and Fruit";
> $vale =~ tr/ and /+;
> It doesn't work.
>
> On the other hand, if the value of $vale is:
> my $vale = "Mango and Fruit";
>
> I still want it to be clever and convert it to:
> "Mango +Fruit"
>
> Any help will be appreicated.
>
> Many Thanks
>
> Joe B.
------------------------------
Date: Sun, 28 May 2000 23:33:35 +0200
From: "Seansan" <sean77@dds.nl>
Subject: setting main:: variables from a library file
Message-Id: <3931908e$0$12967@reader3>
I created a library file for POST and GET requests that sets a hash variable
for the main (calling) program. I now use refernces to pass a handle.
Now I want to set a variable that is local for the main:: environment.
How do I do this from a module / library file ??
And. Is this variable accesible for another library file ??
Thanks in advance, Seansan
------------------------------
Date: 28 May 2000 00:54:19 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Should be in FAQ: "I can't find Net::SMTP"
Message-Id: <8gpn7b$pvu$1@orpheus.gellyfish.com>
On Fri, 26 May 2000 11:56:38 +0800 John Lin wrote:
> Dear all,
>
> I have been asked this question for many times.
>
> "I can't find Net::SMTP module in CPAN."
>
> Actually, we should redirect them to look for "libnet" instead, right?
> Can we put this answer in the FAQ?
>
You might want to look at :
<http://www.perl.com/CPAN/modules/02packages.details.txt>
Wherein is listed the files that each module is in.
/J\
--
Remember that postcard Grandpa sent us from Florida of that alligator
biting that woman's bottom? That's right, we all thought it was
hilarious. But it turns out we were wrong. That alligator was sexually
harrassing that woman.
--
fortune oscar homer
------------------------------
Date: Sun, 28 May 2000 07:34:43 GMT
From: nospam.newton@gmx.li (Philip 'Yes, that's my address' Newton)
Subject: Re: simple regexp question
Message-Id: <3930c5ec.352037963@news.nikoma.de>
On Sun, 28 May 2000 02:34:35 GMT, "Pat!"
<news**NO_SPAM**@psychogenic.com> wrote:
> Barry Grupe wrote:
> > s/\/\\/\\\//g; #turn those frowns upside down!
>
> s|/\|\/|g; -- Using an alternate delimiter makes it so much clearer ;)
ITYM s|/\\|\\/|g;
Which is still better than the original. And its difference to yours is
that (a) it's valid Perl, and (b) it works :-) (tested).
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sun, 28 May 2000 12:45:52 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: simple regexp question
Message-Id: <3935140f.5686000@news.skynet.be>
Barry Grupe wrote:
>I'd like to test for a valid domain name, where domain may equal the
>following:
>domain.xxx
>subdomain.domain.xxx
>subdomains.ad.nauseum.at.domain.xxx
Instead of using regexes, I think I'd go for something like:
@parts = split /\./, $domain, -1;
and check each part. BTW the '-1' part makes sure split() doesn't throw
away empty trailing fields.
None of them should have a length of zero (in regex terms: no two dots
in a row, no dot at beginning or end)
Furthermore, no part should contain two consecutive hyphens, or a hyphen
at the end. Here's the regex every domain name part should match:
/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/i
In summary: something like this could work.
my @parts = split /\./, $domain, -1;
my $invalid = @parts < 2 || $parts[-1] !~ /^[a-z]{2,3}$/i ||
grep { !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/i } @parts;
Well, maybe we *could* throw this into one single regex. It won't be a
"simple regex", though.
$valid = /^([a-z][a-z0-9]*(?:-[a-z0-9]+)*\.)+[a-z]{2,3}$/i;
--
Bart.
------------------------------
Date: Sun, 28 May 2000 21:27:05 +0800
From: "´ô´ô¹Ï" <huxh@990.net>
Subject: some questions about perl format
Message-Id: <8gr7cj$13jc$1@news.cz.js.cn>
Source code:
.......
format STDOUT=
@<<<<<<<<<<<<<@<<<<<<<<<<<@<<<<<<<<<<
$filename,$name,$word
.
when I run it ,there are some error massage:
format not terminated at scriptname line 21 ,at the end of line
format not terminated at scriptname line 21 ,at the end of line
syntax error at scriptname abort due to compliation errors
Please help me
dodo
------------------------------
Date: Sun, 28 May 2000 16:09:18 GMT
From: nospam.newton@gmx.li (Philip 'Yes, that's my address' Newton)
Subject: Re: some questions about perl format
Message-Id: <39313765.381091627@news.nikoma.de>
On Sun, 28 May 2000 21:27:05 +0800, "´ô´ô¹Ï" <huxh@990.net> wrote:
> Source code:
> .......
> format STDOUT=
> @<<<<<<<<<<<<<@<<<<<<<<<<<@<<<<<<<<<<
> $filename,$name,$word
> .
> when I run it ,there are some error massage:
> format not terminated at scriptname line 21 ,at the end of line
Is that format maybe the last thing in the file? This seems to be a
common problem on DOS/Windows systems if there is no line ending after
the '.' that terminates the format. Put a blank line after the final '.'
and it should work.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 28 May 2000 13:31:33 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Tanspose rows to columns
Message-Id: <959520311.20321@itz.pp.sci.fi>
In article <B55510F1.A685%xah@xahlee.org>, Xah wrote:
>Ilmari Karonen <iltzu@sci.invalid>,
>would you care to post an explanation of your implementation?
>
>* an overview of the algorithm/method.
It's really rather simple. It recursively descends the first N levels
of the tree, keeping track of the branch taken at each level. When it
gets to the specified depth, it permutates the collected list of
branches and descends the new tree according to the permutated list.
>* what does constructs like '\my $new' mean? Also, lines like
That declares a lexical scalar and returns a reference to it.
>$new = \$$new->[$_] for map $pos[$_ - 1] => @$perm;
The single-statement for(each) loops were introduced in perl 5.005.
For older perls, the above line could equivalently be written as:
for (map $pos[$_ - 1] => @$perm) { $new = \$$new->[$_] }
On the left of the "for" is a typical Perl idiom for walking a linked
list, with the twist that we choose a branch after each step. The
\$$new->[$_] evaluates as \(${${$new}}[$_]) - that is, it dereferences
$new twice to get an array, selects element number $_, and returns a
reference to it.
The right hand side of the "for" permutates the @pos array. I don't
think there's anything unusual there, except the stylistic use of the
"fat comma" after the first parameter to map(). That's just a habit.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Sun, 28 May 2000 11:51:38 GMT
From: olczyk@interaccess.com (Thaddeus L. Olczyk)
Subject: Weird script behaviour called from a web page.
Message-Id: <3930fc42.193253765@nntp.interaccess.com>
System: Linux (Mandrake 7.0)
Server:Apache
Problem: I've got two scripts in a directory running similar programs
which are called from a web page.
The first one works perfectly.
The second one doesn't.
The error messages I get all indicate that for some reason the second
one can't be found and opened.
They have the same owner and permissions.
When I try to execute both from command-line they run ( with limited
functionality ). But when I type ./script1.pl or fullpath/script1.pl
it runs. When I type ./script2.pl or fullpath/script2.pl the system
says it can't find the file. So I create a wrap script.
#!/usr/bin/perl
system 'perl fullscript2name',@args
I call this wrap script and script2 runs.
I the system call to: system 'fullscript2name',@args
and it does not run.
Change it to: system 'perl ./script2.pl',@args and it runs
change it to: system './script2.pl',@args and it does not run.
I've cut and paste the first line from script1 to script2.
I've changed the name of script2. Those don't help.
At this point I give up.
Can anyone help?
PS: Remember, an explanation must explain why script2 doesn't run
and why script1 does. An explanation that is something like
'the permissions on the directory are wrong' fails to take into
account that script1 runs from the same directory. Sorry to be pushy
but frankly I'm getting tired of the large number of people who answer
without thinking.
------------------------------
Date: Sun, 28 May 2000 16:31:06 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Weird script behaviour called from a web page.
Message-Id: <qje2js094gi59kuigudrjda2r55app4285@4ax.com>
On Sun, 28 May 2000 11:51:38 GMT, olczyk@interaccess.com (Thaddeus L.
Olczyk) wrote:
>System: Linux (Mandrake 7.0)
>Server:Apache
>Problem: I've got two scripts in a directory running similar programs
>which are called from a web page.
>The first one works perfectly.
>The second one doesn't.
>The error messages I get all indicate that for some reason the second
>one can't be found and opened.
>They have the same owner and permissions.
>When I try to execute both from command-line they run ( with limited
>functionality ). But when I type ./script1.pl or fullpath/script1.pl
>it runs. When I type ./script2.pl or fullpath/script2.pl the system
>says it can't find the file. So I create a wrap script.
>
>#!/usr/bin/perl
>system 'perl fullscript2name',@args
>
>
>I call this wrap script and script2 runs.
>I the system call to: system 'fullscript2name',@args
>and it does not run.
>Change it to: system 'perl ./script2.pl',@args and it runs
>change it to: system './script2.pl',@args and it does not run.
>
>I've cut and paste the first line from script1 to script2.
>I've changed the name of script2. Those don't help.
>At this point I give up.
>Can anyone help?
>
>PS: Remember, an explanation must explain why script2 doesn't run
>and why script1 does. An explanation that is something like
>'the permissions on the directory are wrong' fails to take into
>account that script1 runs from the same directory. Sorry to be pushy
>but frankly I'm getting tired of the large number of people who answer
>without thinking.
This is a Linux question rather than a Perl one and would be more
appropriate in a Linux or Unix newsgroup, but here goes anyway!
An error like that doesn't always mean that the shell can't find the
script file. You'll also get that message if the shell can't find the
interpreter given by the #! line at the top of the script.
You should check the first lines of both of these scripts and ensure
that they both point to a Perl interpreter.
This theroy is backed up by the evidence that script2 works when
invoked as 'perl script2.pl' but not as simply 'script2.pl' as in the
first case the shell doesn't need the #! line to find the sripts
interpreter.
Hope you don't think that I answered without thinking.
Dave...
--
<http://www.dave.org.uk> SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>
"There ain't half been some clever bastards" - Ian Dury [RIP]
------------------------------
Date: Sun, 28 May 2000 09:26:37 +0200
From: "Nelly Hemp" <N.Hemp@wanadoo.fr>
Subject: What do I need to write my first perl program??
Message-Id: <8gqhj1$lj5$2@wanadoo.fr>
Hi, I am trying to find out what I need to install onj my PC computer to
write and test perl programs.
Thanks in advance,
N.H.
------------------------------
Date: Sun, 28 May 2000 08:54:17 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: What do I need to write my first perl program??
Message-Id: <393116F9.5C11B050@patriot.net>
> 1. If you are using Windows 95, 98 or NT and have a web browser, go to
> www.perl.com
It's quicker to just go to http://www.activestate.com. They have a warning that
if you're
using Win95, you need to get the DCOM update.
> 2. Look for Win32 binaries which will take you to the latest ActivePerl
> site.
But don't get the latest build. Perl 5.6 is in build 613 (or better) at AS.
Some modules,
particularly the powerful, NT-based ones (Dave Roth's modules, Win32::Lanman,
etc)
haven't been recompiled for that build. If you want to use those modules, stick
with
build 522.
> 3. Download the latest safe version and install it accepting defaults.
Read above.
> 4. You can try it with Notepad or DOS command line, but A good editor like
> www.UltraEdit.com (shareware)
> will be a great boost. Get familiar with it, and don't forget the
> Advanced->Dos Commands menu to make rerunning lightening fast.
A good freeware editor is SynEdit from MKIDesign....
> 5. Now the real fun: Go to www.perl.com, scroll down to "Learning Perl....
> "tutorials". Choose "Robert's perl Tutorial". Print it out, and do it. It is
> hilarious and amazing.
Roger that!
------------------------------
Date: Sun, 28 May 2000 11:11:15 GMT
From: "William Cardwell" <wellhaven@worldnet.att.net>
Subject: Re: What do I need to write my first perl program??
Message-Id: <n97Y4.2603$Zm5.206501@bgtnsc06-news.ops.worldnet.att.net>
Nelly Hemp <N.Hemp@wanadoo.fr> wrote in message
news:8gqhj1$lj5$2@wanadoo.fr...
> Hi, I am trying to find out what I need to install onj my PC computer to
> write and test perl programs.
>
> Thanks in advance,
>
> N.H.
>
Here's my recipe:
1. If you are using Windows 95, 98 or NT and have a web browser, go to
www.perl.com
2. Look for Win32 binaries which will take you to the latest ActivePerl
site.
3. Download the latest safe version and install it accepting defaults.
4. You can try it with Notepad or DOS command line, but A good editor like
www.UltraEdit.com (shareware)
will be a great boost. Get familiar with it, and don't forget the
Advanced->Dos Commands menu to make rerunning lightening fast.
5. Now the real fun: Go to www.perl.com, scroll down to "Learning Perl....
"tutorials". Choose "Robert's perl Tutorial". Print it out, and do it. It is
hilarious and amazing.
------------------------------
Date: Sun, 28 May 2000 19:19:11 GMT
From: Andy <y-o-y@home.com>
Subject: Re: What do I need to write my first perl program??
Message-Id: <PieY4.213496$Tn4.1921003@news1.rdc2.pa.home.com>
In article <n97Y4.2603$Zm5.206501@bgtnsc06-news.ops.worldnet.att.net>,
"William Cardwell" <wellhaven@worldnet.att.net> wrote:
> Nelly Hemp <N.Hemp@wanadoo.fr> wrote in message
> Here's my recipe:
>
> 1. If you are using Windows 95, 98 or NT and have a web browser, go to
> www.perl.com
>
> 2. Look for Win32 binaries which will take you to the latest ActivePerl
> site.
>
> 3. Download the latest safe version and install it accepting defaults.
>
> 4. You can try it with Notepad or DOS command line, but A good editor
> like
> www.UltraEdit.com (shareware)
> will be a great boost. Get familiar with it, and don't forget the
> Advanced->Dos Commands menu to make rerunning lightening fast.
>
> 5. Now the real fun: Go to www.perl.com, scroll down to "Learning
> Perl....
> "tutorials". Choose "Robert's perl Tutorial". Print it out, and do it. It
> is
> hilarious and amazing.
>
>
Thanks, William!!!
Just what I needed!
Andy
------------------------------
Date: Sun, 28 May 2000 13:58:23 +0100
From: "Kenny" <kenny@kenny.co.uk>
Subject: Re: What do I need to write my first perl program??
Message-Id: <8gr58s$5en$2@plutonium.btinternet.com>
I suggest you go to http://www.activestate.com/Products/ActivePerl/ and
download ActivePerl. And if you have not been before, www.perl.com is also
a good place to start.
If you need a program to actually write the coding, WordPad sufficed for the
first 2 years of my Perl programming life.
Nelly Hemp <N.Hemp@wanadoo.fr> wrote in message
news:8gqhj1$lj5$2@wanadoo.fr...
> Hi, I am trying to find out what I need to install onj my PC computer to
> write and test perl programs.
>
> Thanks in advance,
>
> N.H.
>
>
>
>
------------------------------
Date: Sat, 27 May 2000 04:08:02 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: What package does "xsubpp" belong to and where are updates?
Message-Id: <CSHX4.94434$hT2.391570@news1.rdc1.ct.home.com>
In comp.lang.perl.misc Yitzchak Scott-Thoennes <sthoenna@efn.org> wrote:
> In article <XYjX4.93847$hT2.388039@news1.rdc1.ct.home.com>,
> Dan Sugalski <dan@tuatha.sidhe.org> wrote:
> [refering to upgrading xsubpp]
>> It's part and parcel of the main perl distribution. You'll need to upgrade
>> to a more recent version of perl to get it. (It's got far too much
>> dependence on perl's guts to be a drop-in replacement)
> I believe you, but can you explain:
> [D:\perl\lib\5.6.0\ExtUtils]fgrep "require 5." xsubpp
> require 5.002;
Sure--someone forgot to update that. I can guarantee it's wrong. The
xsubpp in the 5.6.0 distribution requires the re extension to function,
and you definitely won't find that in 5.002, as it requires perl 5.005 at
a minimum. The xsubpp in the 5.6.0 distribution might generate code
compatible with 5.005, but I wouldn't count on even that.
Dan
------------------------------
Date: Sun, 28 May 2000 06:30:31 GMT
From: amir@infoteen.com
Subject: writing SMTP daemon in perl
Message-Id: <8gqee8$5km$1@nnrp1.deja.com>
Hello,
Has anyone out there written (or tried to write) an SMTP daemon
entirely in perl? If yes, please send me a copy to me or send me a URL
location.
I am writing one because I want it to add messages to a queue directory
where another daemon will process it. This smtp daemon must be able to
support ESMTP to be fully compatible with Internet mailers, right??
My daemon will be multi-threaded (meaning: no threads, just concurrent
connections). For a simple server with or without ESMTP, how would I
implement the NetServer::SMTP module (or any other module that does
SMTP command processing) with the following code? I want to use a
module for the SMTP command set.
#!/usr/bin/perl
use strict;
require Net::Daemon;
package SMTPd;
use vars qw($VERSION @ISA);
$VERSION = '0.01';
@ISA = qw(Net::Daemon); # to inherit from Net::Daemon
sub Version ($) { 'SMTPd in perl 0.1'; }
sub Options ($) {
my($self) = @_;
my($options) = $self->SUPER::Options();
$options->{'base'} = { 'template' => 'base=s',
'description' => '--base '
. 'dec (default), hex or oct' };
$options;
}
sub new ($$;$) {
my($class, $attr, $args) = @_;
my($self) = $class->SUPER::new($attr, $args);
if ($self->{'parent'}) {
# Called via Clone()
$self->{'base'} = $self->{'parent'}->{'base'};
} else {
# Initial call
if ($self->{'options'} && $self->{'options'}->{'base'}) {
$self->{'base'} = $self->{'options'}->{'base'}
}
}
if (!$self->{'base'}) {
$self->{'base'} = 'dec';
}
$self;
}
sub Run ($) {
my($self) = @_;
my($line, $sock, $buf,$rtype,$uri,$host,$ver);
$sock = $self->{'socket'};
while (1) {
if (!defined($line = $sock->getline())) {
if ($sock->error()) {
$self->Error("Client connection error %s", $sock->error
());
}
$sock->close();
return;
}
$line =~ s/\s+$//; # Remove CRLF
my($result,$close);
# $line is the SMTP command
if ($line =~ /HELO/i) {
# do whatever
} elsif ($line =~ /QUIT/i) {
print $sock "221 Have a nice day!\r\n";
$close = 1;
} else {
print $sock "502 unimplemented (#5.5.1)\r\n";
}
if ($close) {
$self->Error("Client connection error %s", $sock->error());
$sock->close();
return;
}
}
}
package main;
my $server = SMTPd->new({'pidfile' => 'none',
'localport' => 2000}, \@ARGV);
$server->Bind();
Any help would be appreciated.
Thanks,
Amir
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 28 May 2000 10:59:32 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: writing SMTP daemon in perl
Message-Id: <87vgzy8y3f.fsf@limey.hpcc.uh.edu>
>> On Sun, 28 May 2000 06:30:31 GMT,
>> amir@infoteen.com said:
> Hello, Has anyone out there written (or tried to write)
> an SMTP daemon entirely in perl? If yes, please send me
> a copy to me or send me a URL location.
http://search.cpan.org/search?mode=module&query=SMTP
(http://search.cpan.org/ is your friend :-)
> I am writing one because I want it to add messages to a
> queue directory where another daemon will process
> it. This smtp daemon must be able to support ESMTP to be
> fully compatible with Internet mailers, right??
An ESMTP request falls back to SMTP if not supported, so
no, your server doesn't have to support it.
> My daemon will be multi-threaded (meaning: no threads,
> just concurrent connections). For a simple server with
multi-threaded means no threads???
hth
t
--
"Trying is the first step towards failure"
Homer Simpson
------------------------------
Date: Sun, 28 May 2000 19:11:33 GMT
From: amir142@my-deja.com
Subject: Re: writing SMTP daemon in perl
Message-Id: <8grr0s$2j0$1@nnrp1.deja.com>
In article <87vgzy8y3f.fsf@limey.hpcc.uh.edu>, Tony Curtis
<tony_curtis32@yahoo.com> wrote:
> >> On Sun, 28 May 2000 06:30:31 GMT,
> >> amir@infoteen.com said:
>
> > Hello, Has anyone out there written (or tried to write)
> > an SMTP daemon entirely in perl? If yes, please send me
> > a copy to me or send me a URL location.
>
> http://search.cpan.org/search?mode=module&query=SMTP
>
> (http://search.cpan.org/ is your friend :-)
Yes, I already searched on cpan, but didn't find any modules that would
be suitable. I have written a minimum SMTP-compatible bare-bones SMTP
server that accepts these commands: HELO,RSET,MAIL,RCPT,DATA,QUIT. (I
_glanced_ at a couple of RFCs.)
It currently delivers to a file... but it's just a minimum server that
can obviously be improved.
See the source at: http://amir.net.eu.org/qsmtpd.txt
Am I correct in using my own checks for valid SMTP commands?? (The if
statements on HELO,RSET,MAIL,RCPT,DATA and QUIT ??)
> An ESMTP request falls back to SMTP if not supported, so
> no, your server doesn't have to support it.
OK thanks, I took that into consideration when writing the sample
server above.
>
> > My daemon will be multi-threaded (meaning: no threads,
> > just concurrent connections). For a simple server with
>
> multi-threaded means no threads???
I meant to say multi-tasking (meaning: it can handle _many_ concurrect
connections, and process them concurrently) without delay.
>
> hth
> t
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3191
**************************************