[16755] in Perl-Users-Digest
Perl-Users Digest, Issue: 4167 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 29 18:10:46 2000
Date: Tue, 29 Aug 2000 15:10:28 -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: <967587028-v9-i4167@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 29 Aug 2000 Volume: 9 Number: 4167
Today's topics:
Re: method="get" <jevon@islandtelecom.com>
Re: method="get" (Tony L. Svanstrom)
Re: method="get" <bart.lateur@skynet.be>
Re: method="get" <flavell@mail.cern.ch>
Need help to delete a file <info_no_spam_@nephrogene.com>
Re: Need help to delete a file (brian d foy)
Re: output fun <tim@ipac.caltech.edu>
Re: output fun yanick1@sympatico.ca
Parse::RecDescent and the C grammar of doom. <ocschwar@mit.edu>
Re: Parse::RecDescent and the C grammar of doom. (Damian Conway)
perl prob. <desi@byu.edu>
Re: perl send/detect ICMP <peckert@epicrealm.com>
Perl Temperature Grabber <yodajeff@hotmail.com>
Re: PGP Redirecting Output sean31@my-deja.com
Re: PGP Redirecting Output sean31@my-deja.com
Re: PGP Redirecting Output sean31@my-deja.com
Re: Please help: How to check for $var is null or not? <lr@hpl.hp.com>
Re: Please help: How to check for $var is null or not? (Jon S.)
Re: Please help: How to check for $var is null or not? <lr@hpl.hp.com>
Re: Problem with threads in Windows <jevon@islandtelecom.com>
Problems editing text with Perl itgirl57@my-deja.com
Re: Problems editing text with Perl <dperham@dperham.eng.tvol.net>
Re: Problems editing text with Perl <lr@hpl.hp.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 29 Aug 2000 18:42:58 GMT
From: "Jevon MacDonald" <jevon@islandtelecom.com>
Subject: Re: method="get"
Message-Id: <SuTq5.164$uR1.23413@sapphire.mtt.net>
There are a few great CGI modules..
You want search.cpan.org
"Erik" <e.hofstra@student.utwente.nl> wrote in message
news:8ogjj5$4p7$1@dinkel.civ.utwente.nl...
> How can i read the values from a form that is sent
> with method="get" in Perl?
>
>
> Erik
>
>
------------------------------
Date: Tue, 29 Aug 2000 22:50:35 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: method="get"
Message-Id: <1eg5e2v.peclgj165cudcN%tony@svanstrom.com>
Jevon MacDonald <jevon@islandtelecom.com> wrote:
> "Erik" <e.hofstra@student.utwente.nl> wrote in message
> news:8ogjj5$4p7$1@dinkel.civ.utwente.nl...
> > How can i read the values from a form that is sent
> > with method="get" in Perl?
> There are a few great CGI modules..
>
> You want search.cpan.org
No, you don't search for a module when all you want is
$ENV{'QUERY_STRING'}
/Tony
--
/\___/\ Who would you like to read your messages today? /\___/\
\_@ @_/ Protect your privacy: <http://www.pgpi.com/> \_@ @_/
--oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
on the verge of frenzy - i think my mask of sanity is about to slip
---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
\O/ \O/ ©99-00 <http://www.svanstrom.com/?ref=news> \O/ \O/
------------------------------
Date: Tue, 29 Aug 2000 21:11:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: method="get"
Message-Id: <q89oqsc96f1rihvbr7pubftu87bhcg0fgj@4ax.com>
Jevon MacDonald wrote:
>There are a few great CGI modules..
I've just been searching on CPAN. The package CGI::Minimal looks very
interesting to me.
<http://search.cpan.org/search?dist=CGI-Minimal>
From the docs:
NAME
CGI::Minimal - A lightweight CGI form processing pacakge
DESCRIPTION
Provides a micro-weight alternative to the CPAN CGI.pm module
Rather than attempt to address every possible need of a CGI
programmer, it provides the _minimum_ functions needed
for CGI such as form decoding (including file upload forms), URL
encoding and decoding, HTTP usable date generation (RFC1123
compliant dates) and _basic_ escaping and unescaping of HTMLized
text.
The form decoding interface is somewhat compatible with the
CGI.pm module. No provision is made for generating HTTP or HTML
on your behalf - you are expected to be conversant with how to
put together any HTML or HTTP you need.
Just what I always wanted. Er... I've got my own module, thank you, with
basically the same functionality as this one (plus cookies). This module
here didn't exist at the time. But I think I'll check this one out,
anyway.
--
Bart.
------------------------------
Date: Tue, 29 Aug 2000 23:31:00 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: method="get"
Message-Id: <Pine.GHP.4.21.0008292325150.17917-100000@hpplus03.cern.ch>
On Tue, 29 Aug 2000, Tony L. Svanstrom wrote:
> Jevon MacDonald <jevon@islandtelecom.com> wrote:
>
> > "Erik" <e.hofstra@student.utwente.nl> wrote in message
> > news:8ogjj5$4p7$1@dinkel.civ.utwente.nl...
>
> > > How can i read the values from a form that is sent
> > > with method="get" in Perl?
HTTP methods are case-sensitive. Probably meant that method to be GET.
There's a CGI group thattaway -> comp.infosystems.www.authoring.cgi
> > You want search.cpan.org
>
> No, you don't search for a module when all you want is
> $ENV{'QUERY_STRING'}
Well, there's a little bit of Perl in that...
But the next question is likely to be "what to do with these %xx
things in the query string", and "what if the method is POST
instead", and other things like that. Might as well point them at
CGI.pm already. But no need to search CPAN for that: a version comes
with any recent Perl installation already.
all the best
------------------------------
Date: Tue, 29 Aug 2000 20:11:29 +0200
From: "Mato Nagel" <info_no_spam_@nephrogene.com>
Subject: Need help to delete a file
Message-Id: <8ogug6$fdg$18$1@news.t-online.com>
Sorry for this simple question, but I searched perlfunc.html up and down and
I didn't found a function to delete a file.
I want to remove a directory, but rmdir(DIR) only works when the directory
is empty. But how to empty it out, when I can't remove a file.
I believe the answer will be very simple but I can't figure it out for
myself.
Mato
------------------------------
Date: Tue, 29 Aug 2000 14:29:07 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Need help to delete a file
Message-Id: <brian-ya02408000R2908001429070001@news.panix.com>
In article <8ogug6$fdg$18$1@news.t-online.com>, "Mato Nagel" <info_no_spam_@nephrogene.com> posted:
> Sorry for this simple question, but I searched perlfunc.html up and down and
> I didn't found a function to delete a file.
you would have found unlink() had you searched on the the word "delete".
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Tue, 29 Aug 2000 11:36:36 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: output fun
Message-Id: <39AC02B4.9AA1B37E@ipac.caltech.edu>
> In article <8ogdcm$56v$1@nnrp1.deja.com>, <ankban4@my-deja.com> wrote:
> >Without using the formatting features , how do i print an output like
> >this . i tried but my code is too huge and ugly.
> >
> > ABCDEFGFEDCBA
> > ABCDEF FEDCBA
> > ABCDE EDCBA
> > ABCD DCBA
> > ABC CBA
> > AB BA
> > A A
perl -wle '$a="ABCDEFGFEDCBA";substr($a,7-$_,$_*2-1," "x($_*2-1)),print $a for
(.5,1..6)'
[Forgive the compactness at the expense of readability; I couldn't resist making
it a one-liner.]
--
-- Tim Conrow tim@ipac.caltech.edu 626-395-8435
------------------------------
Date: Tue, 29 Aug 2000 19:17:01 GMT
From: yanick1@sympatico.ca
Subject: Re: output fun
Message-Id: <N_Tq5.205169$Gh.3914777@news20.bellglobal.com>
ankban4@my-deja.com wrote:
: Without using the formatting features , how do i print an output like
: this . i tried but my code is too huge and ugly.
: ABCDEFGFEDCBA
: ABCDEF FEDCBA
: ABCDE EDCBA
: ABCD DCBA
: ABC CBA
: AB BA
: A A
Well, there is:
#! /usr/bin/perl -w
use strict;
sub output_fun {
local $\ = "\n";
$_ = shift;
print and s#.( +).# $1 #g or substr($_,length()/2,1)=' ' while /\w/;
}
output_fun "ABCDEFGFEDCBA";
print "Yanick\n";
output_fun "Yet another Perl hacker."; # :)
--
eval" use 'that poor Yanick' ";
print map{ (sort keys %{{ map({$_=>1}split'',$@) }})[hex] }
qw/8 b 15 1 9 10 11 15 c b 13 1 12 b 13 f 1 c 9 a e b 13 0/;
------------------------------
Date: Tue, 29 Aug 2000 17:02:48 -0400
From: Omri Schwarz <ocschwar@mit.edu>
Subject: Parse::RecDescent and the C grammar of doom.
Message-Id: <39AC24F8.EA8ADAF8@mit.edu>
This is a multi-part message in MIME format.
--------------1C5B7BC034E8647C0C729ED2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi, all! as promised, I'm posting my changes to the
C grammar from Hell now that I'm done picking nits in it.
--------------1C5B7BC034E8647C0C729ED2
Content-Type: application/x-perl;
name="decss3.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="decss3.pl"
#!/afs/athena.mit.edu/contrib/perl5/bin/perl5.6.0
#
use Parse::RecDescent;
local $/;
my $grammar = <DATA>;
my $parser = Parse::RecDescent->new($grammar);
my $text = <STDIN>;
my $parse_tree = $parser->translation_unit($text) or die "bad C code";
__DATA__
<autotree>
primary_expression:
IDENTIFIER
| CONSTANT
| STRING_LITERAL
| '(' expression ')'
postfix_expression:
primary_expression
| (primary_expression)(s) '[' expression ']'
| (primary_expression)(s) '(' ')'
| (primary_expression)(s) '(' argument_expression_list ')'
| (primary_expression)(s) '.' IDENTIFIER
| (primary_expression)(s) PTR_OP IDENTIFIER
| (primary_expression)(s) INC_OP
| (primary_expression)(s) DEC_OP
argument_expression_list:
(assignment_expression ',')(s?) assignment_expression
unary_expression:
postfix_expression
| INC_OP unary_expression
| DEC_OP unary_expression
| unary_operator cast_expression
| SIZEOF unary_expression
| SIZEOF '(' type_name ')'
unary_operator:
'&'
| '*'
| '+'
| '-'
| '~'
| '!'
cast_expression:
unary_expression
| '(' type_name ')' cast_expression
multiplicative_expression:
(cast_expression mul_ex_op)(s?) cast_expression
mul_ex_op : '*' | '/' | '%'
additive_expression:
(multiplicative_expression add_op)(s?) multiplicative_expression
add_op : '+' | '-'
shift_expression:
(additive_expression shift_op )(s?) additive_expression
shift_op : LEFT_OP | RIGHT_OP
relational_expression:
(shift_expression rel_op)(s?) shift_expression
rel_op: '<' | '>' | LE_OP | GE_OP
equality_expression:
(relational_expression eq_ex_op)(s?) relational_expression
eq_ex_op : EQ_OP | NE_OP
and_expression:
(equality_expression '&')(s?) equality_expression
exclusive_or_expression:
(and_expression '^')(s?) and_expression
inclusive_or_expression:
(exclusive_or_expression '|')(s?) exclusive_or_expression
logical_and_expression:
(inclusive_or_expression AND_OP)(s?) inclusive_or_expression
logical_or_expression:
(logical_and_expression OR_OP)(s?) logical_and_expression
conditional_expression:
logical_or_expression
| logical_or_expression '?' expression ':' conditional_expression
assignment_expression:
conditional_expression
| unary_expression assignment_operator assignment_expression
assignment_operator:
'='
| MUL_ASSIGN
| DIV_ASSIGN
| MOD_ASSIGN
| ADD_ASSIGN
| SUB_ASSIGN
| LEFT_ASSIGN
| RIGHT_ASSIGN
| AND_ASSIGN
| XOR_ASSIGN
| OR_ASSIGN
expression:
(assignment_expression ',')(s?) assignment_expression
constant_expression:
conditional_expression
declaration:
declaration_specifiers ';'
{ print "We have a match!\n"; }
| declaration_specifiers init_declarator_list ';'
declaration_specifiers:
storage_class_specifier
| storage_class_specifier declaration_specifiers
| type_specifier
| type_specifier declaration_specifiers
| type_qualifier
| type_qualifier declaration_specifiers
init_declarator_list:
(init_declarator ',')(s?) init_declarator
init_declarator:
declarator
| declarator '=' initializer
storage_class_specifier:
TYPEDEF
| EXTERN
| STATIC
| AUTO
| REGISTER
type_specifier:
VOID
| CHAR
| SHORT
| INT
| LONG
| FLOAT
| DOUBLE
| SIGNED
| UNSIGNED
| struct_or_union_specifier
| enum_specifier
| TYPE_NAME
struct_or_union_specifier:
struct_or_union IDENTIFIER '{' struct_declaration_list '}'
| struct_or_union '{' struct_declaration_list '}'
| struct_or_union IDENTIFIER
struct_or_union:
STRUCT
| UNION
struct_declaration_list:
struct_declaration(s)
struct_declaration:
specifier_qualifier_list struct_declarator_list ';'
specifier_qualifier_list:
type_specifier specifier_qualifier_list
| type_specifier
| type_qualifier specifier_qualifier_list
| type_qualifier
struct_declarator_list:
(struct_declarator ',')(s?) struct_declarator
struct_declarator:
declarator
| ':' constant_expression
| declarator ':' constant_expression
enum_specifier:
ENUM '{' enumerator_list '}'
| ENUM IDENTIFIER '{' enumerator_list '}'
| ENUM IDENTIFIER
enumerator_list:
(enumerator ',')(s?) enumerator
enumerator:
IDENTIFIER
| IDENTIFIER '=' constant_expression
type_qualifier:
CONST
| VOLATILE
declarator:
pointer direct_declarator
| direct_declarator
direct_declarator:
IDENTIFIER
| '(' declarator ')'
| (IDENTIFIER)(s?) ('(' declarator ')')(s?) '[' constant_expression ']'
| (IDENTIFIER)(s?) ('(' declarator ')')(s?) '[' ']'
| (IDENTIFIER)(s?) ('(' declarator ')')(s?) '(' parameter_type_list ')'
| (IDENTIFIER)(s?) ('(' declarator ')')(s?) '(' identifier_list ')'
| (IDENTIFIER)(s?) ('(' declarator ')')(s?) '(' ')'
pointer:
'*'
| '*' type_qualifier_list
| '*' pointer
| '*' type_qualifier_list pointer
type_qualifier_list:
type_qualifier(s)
parameter_type_list:
parameter_list
| parameter_list ',' ELLIPSIS
parameter_list:
(parameter_declaration ',')(s?) parameter_declaration
parameter_declaration:
declaration_specifiers declarator
| declaration_specifiers abstract_declarator
| declaration_specifiers
identifier_list:
(IDENTIFIER ',')(s?) IDENTIFIER
type_name:
specifier_qualifier_list
| specifier_qualifier_list abstract_declarator
abstract_declarator:
pointer
| direct_abstract_declarator
| pointer direct_abstract_declarator
direct_abstract_declarator:
'(' abstract_declarator ')'
| '[' ']'
| '[' constant_expression ']'
| DAD '[' ']'
| DAD '[' constant_expression ']'
| '(' ')'
| '(' parameter_type_list ')'
| DAD '(' ')'
| DAD '(' parameter_type_list ')'
DAD: #macro for direct_abstract_declarator
( '(' abstract_declarator ')' )(s?)
( '[' ']' )(s?)
( '[' constant_expression ']' )(s?)
( '(' ')' )(s?)
( '(' parameter_type_list ')' )(s?)
initializer:
assignment_expression
| '{' initializer_list '}'
| '{' initializer_list ',' '}'
initializer_list:
(initializer ',')(s?) initializer
statement:
labeled_statement
| compound_statement
| expression_statement
| selection_statement
| iteration_statement
| jump_statement
labeled_statement:
IDENTIFIER ':' statement
| CASE constant_expression ':' statement
| DEFAULT ':' statement
compound_statement:
'{' '}'
| '{' statement_list '}'
| '{' declaration_list '}'
| '{' declaration_list statement_list '}'
declaration_list:
declaration(s)
statement_list:
statement(s)
expression_statement:
';'
| expression ';'
selection_statement:
IF '(' expression ')' statement
| IF '(' expression ')' statement ELSE statement
| SWITCH '(' expression ')' statement
iteration_statement:
WHILE '(' expression ')' statement
| DO statement WHILE '(' expression ')' ';'
| FOR '(' expression_statement expression_statement ')' statement
| FOR '(' expression_statement expression_statement expression ')' statement
jump_statement:
GOTO IDENTIFIER ';'
| CONTINUE ';'
| BREAK ';'
| RETURN ';'
| RETURN expression ';'
translation_unit:
external_declaration(s)
external_declaration:
function_definition
| declaration
function_definition:
declaration_specifiers declarator declaration_list compound_statement
| declaration_specifiers declarator compound_statement
| declarator declaration_list compound_statement
| declarator compound_statement
# TERMINALS
reserved_word:
AUTO | BREAK | CASE | CHAR | CONST |
CONTINUE | DEFAULT | DO | DOUBLE | ENUM |
EXTERN | FLOAT | FOR | GOTO | IF |
INT | LONG | REGISTER | RETURN | SHORT |
SIGNED | SIZEOF | STATIC | STRUCT | SWITCH |
TYPEDEF | UNION | UNSIGNED | VOID | VOLATILE |
WHILE
ADD_ASSIGN: '+='
AND_ASSIGN: '&='
AND_OP: '&&'
AUTO: 'auto'
BREAK: 'break'
CASE: 'case'
CHAR: 'char'
CONST: 'const'
CONSTANT: /[+-]?(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?/
CONTINUE: 'continue'
DEC_OP: '--'
DEFAULT: 'default'
DIV_ASSIGN: '/='
DO: 'do'
DOUBLE: 'double'
ELLIPSIS: '...'
ELSE: 'else'
ENUM: 'enum'
EQ_OP: '=='
EXTERN: 'extern'
FLOAT: 'float'
FOR: 'for'
GE_OP: '>='
GOTO: 'goto'
IDENTIFIER: ...!reserved_word /[a-z]\w*/i
IF: 'if'
INC_OP: '++'
INT: 'int'
LEFT_ASSIGN: '<<='
LEFT_OP: '<<'
LE_OP: '<='
LONG: 'long'
MOD_ASSIGN: '%='
MUL_ASSIGN: '*='
NE_OP: '!='
OR_ASSIGN: '|='
OR_OP: '||'
PTR_OP: '->'
REGISTER: 'register'
RETURN: 'return'
RIGHT_ASSIGN: '>>='
RIGHT_OP: '>>'
SHORT: 'short'
SIGNED: 'signed'
SIZEOF: 'sizeof'
STATIC: 'static'
STRING_LITERAL: { extract_delimited($text,'"') }
STRUCT: 'struct'
SUB_ASSIGN: '-='
SWITCH: 'switch'
TYPEDEF: 'typedef'
TYPE_NAME: # NONE YET
UNION: 'union'
UNSIGNED: 'unsigned'
VOID: 'void'
VOLATILE: 'volatile'
WHILE: 'while'
XOR_ASSIGN: '^='
--------------1C5B7BC034E8647C0C729ED2--
------------------------------
Date: 29 Aug 2000 21:11:54 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Parse::RecDescent and the C grammar of doom.
Message-Id: <8oh8uq$2u7$1@towncrier.cc.monash.edu.au>
Omri Schwarz <ocschwar@mit.edu> writes:
>Hi, all! as promised, I'm posting my changes to the
>C grammar from Hell now that I'm done picking nits in it.
Omri, thanks for all your work on this. The entire RecDescent community will
benefit from your efforts. I will be sure to include your updated grammar in
the next release of the module.
All the best,
Damian
------------------------------
Date: Tue, 29 Aug 2000 14:46:22 -0600
From: desi <desi@byu.edu>
Subject: perl prob.
Message-Id: <39AC211E.71DA2001@byu.edu>
I am trying to find if the substring $items1 (a value I get from the
text box of a form) exists in the string $data[i](0<=i<15). data is an
array which has the item name and a price list as each element of the
array.
[FYI: I am doing this in Perl5]
for ($i=0;$i<15;$i++)
{ if ($data[$i] =~ m/$items1/)
{ print "match ".$items1;
}
}
Please let me know what is wrong with this or is there any alternate way
to do this.
Thanks,
Santosh.
------------------------------
Date: Tue, 29 Aug 2000 19:22:39 GMT
From: Paul Eckert <peckert@epicrealm.com>
Subject: Re: perl send/detect ICMP
Message-Id: <39AC0D9A.C741EBBA@epicrealm.com>
"Mr. Chow Wing Siu" wrote:
> I would like to get the examples to send and read/detect ICMP
> messages by perl.
For sending:
Use any of the CPAN Net::Ping modules:
http://search.cpan.org/search?mode=module&query=Net%3A%3APing
For receiving:
The easiest way is to use the module:
http://search.cpan.org/doc/TIMPOTTER/NetPacket-0.01/NetPacket/ICMP.pm
and use the decode method to disassemble the ICMP packet.
I don't know of an easy way to get the ICMP packets, tho', other than to put
your NIC into raw mode and look at everything as it goes by, waiting for ping
packets.
Perhaps someobody else can take this further?
--
Paul Eckert
Sr. Software Engineer
Epicrealm Inc.
1651 N. Glenville Dr., Suite 212
Richardson, TX 75081
(972) 479-0135 x300
peckert@epicrealm.com
------------------------------
Date: Tue, 29 Aug 2000 21:29:12 GMT
From: Jeff <yodajeff@hotmail.com>
Subject: Perl Temperature Grabber
Message-Id: <sqoap8kvc5d45@corp.supernews.com>
I'm looking for a perl script to get the current temperature for a pre-
selected city or zipcode. I've seen some, but all of them retrieve more
information then just the temperature, which is what I want. It can be
taken from weather.com or http://iwin.nws.noaa.gov/ Just have $temp or
something equal the current temperature. Don't worry about the output, I
just need a code to retrieve the current temperature with $zip=90210 or
something similar so I can configure the zip code as needed. I have the
code ready to print it onto a screen in html format so I'll add all the
print information. I just need a simple code to retreive the temperature
as $temp (or something similar) for $zip, and I'll configure the rest.
Thanks and feel free to reply if you have any questions.
Jeff
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Tue, 29 Aug 2000 18:13:22 GMT
From: sean31@my-deja.com
Subject: Re: PGP Redirecting Output
Message-Id: <8ogufc$r04$1@nnrp1.deja.com>
I'm currently using 6.5.3 (soon to upgrade to 6.5.8). I tried adding
+batchmode and VERBOSE=0 (in pgp.cfg), but the darn banner message is
still being printed out to my HTML stream. I was hoping there might be
a Perl trick to suppress the output.
-Sean
> which version of PGP?
>
> there should be a batch mode. look at the command line switches
> to find it.
>
> --
> brian d foy
> CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
> Perl Mongers <URL:http://www.perl.org/>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 29 Aug 2000 18:19:50 GMT
From: sean31@my-deja.com
Subject: Re: PGP Redirecting Output
Message-Id: <8ogure$rk7$1@nnrp1.deja.com>
I thought CGI scripts write STDERR to the Web server's error log (by
default), not the output stream? If I can remember how to redirect
STDERR and I will check it out.
-Sean
In article <39ABDF86.13D6A30C@yahoo.co.uk>,
Nick Condon <nickco3@yahoo.co.uk> wrote:
> sean31@my-deja.com wrote:
>
> > I'm writing a perl CGI script that invokes the PGP command-line
> > utilities. The problem I am having is when inovking these
utilities, a
> > banner message is always printed out, and there doesn't seem to be a
> > switch to turn it off. I tried redirecting the output to /dev/null,
but
> > the banner message is still written to stdout. Any ideas on how I
can
> > get around this? I do not want this banner to be part of the HTML
that
> > I am returning to the end-user.
>
> I don't have pgp so I can't say for sure, but it's probably writing to
> STDERR
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 29 Aug 2000 18:43:53 GMT
From: sean31@my-deja.com
Subject: Re: PGP Redirecting Output
Message-Id: <8oh093$t8k$1@nnrp1.deja.com>
You were right! I thought of that, but I mistakingly thought the STDERR
was written to the web server error log. I appended "&> /dev/null" to
my pgp invokation, and that seems to do the trick. Thanks!
-Sean
In article <39ABDF86.13D6A30C@yahoo.co.uk>,
Nick Condon <nickco3@yahoo.co.uk> wrote:
> sean31@my-deja.com wrote:
>
> > I'm writing a perl CGI script that invokes the PGP command-line
> > utilities. The problem I am having is when inovking these
utilities, a
> > banner message is always printed out, and there doesn't seem to be a
> > switch to turn it off. I tried redirecting the output to /dev/null,
but
> > the banner message is still written to stdout. Any ideas on how I
can
> > get around this? I do not want this banner to be part of the HTML
that
> > I am returning to the end-user.
>
> I don't have pgp so I can't say for sure, but it's probably writing to
> STDERR
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 29 Aug 2000 11:19:15 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Please help: How to check for $var is null or not?
Message-Id: <MPG.14159e7c86d3e63a98aced@nntp.hpl.hp.com>
In article <39abdc8f.8235098@news.earthlink.net> on Tue, 29 Aug 2000
16:01:53 GMT, Jon S. <jonceramic@nospammiesno.earthlink.net> says...
...
> I've been using a scheme (after help from Larry and others a few weeks
> ago) of naming $fooOK = "yes"; only on conditions where $foo actually
> is okay.
>
> So, I'll go...
> my ($foo, $fooOK);
> if ($foo eq "foocriteria") {$fooOK = "yes"}
That draws a warning if $foo is undefined.
Here's a nice way to set true/false:
$fooOK = $foo eq 'foocriteria';
Instead of testing on the condition and setting a flag, just assign the
Boolean value of the condition to the flag.
> In my checks, then, I use
> if ( $fooOK ) {print "foo's okay"}
>
> Or
>
> if ( !$fooOK ) {print "bad foo"}
>
> (I use the !$fooOK when I have to do more complex boolean logic and
> unless doesn't fit right, that's just an example)
>
> Is this acceptable shorthand for what I'm doing, or am I leaving
> something out not using the defined() or length() functions?
Just possible confusion among the various false values:
undefined, "", '0', numeric value of 0
If that doesn't matter, then simplest is best.
> (Sorry if I forgot any ;'s, I usually catch those when I run the
> script! Still a newbie...)
But you should run the test snippets before posting them. No excuse to
post invalid syntax!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 29 Aug 2000 20:14:20 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: Please help: How to check for $var is null or not?
Message-Id: <39ac17e5.1266913@news.earthlink.net>
On Tue, 29 Aug 2000 11:19:15 -0700, Larry Rosler <lr@hpl.hp.com>
wrote:
>In article <39abdc8f.8235098@news.earthlink.net> on Tue, 29 Aug 2000
>16:01:53 GMT, Jon S. <jonceramic@nospammiesno.earthlink.net> says...
>
>...
>
>> I've been using a scheme (after help from Larry and others a few weeks
>> ago) of naming $fooOK = "yes"; only on conditions where $foo actually
>> is okay.
>>
>> So, I'll go...
>> my ($foo, $fooOK);
>> if ($foo eq "foocriteria") {$fooOK = "yes"}
>
>That draws a warning if $foo is undefined.
Gotcha. Hadn't come across it yet because of the way I handle param()
feeds (it's a script for CGI).
>Here's a nice way to set true/false:
>
> $fooOK = $foo eq 'foocriteria';
Why wouldn't this also warn if $foo is undefined?
>Instead of testing on the condition and setting a flag, just assign the
>Boolean value of the condition to the flag.
If I'm using boolean logic to set $fooOK, can I just put the right
hand of the equation in parenthesis? I assume the '$fooOK ='
operation takes whatever you give it on the right hand side, no matter
how hairy, right?
i.e.
$fooOK = ($foo eq 'foocriteria' && $foo eq 'foocriteria2');
<some snipped>
>> (Sorry if I forgot any ;'s, I usually catch those when I run the
>> script! Still a newbie...)
>
>But you should run the test snippets before posting them. No excuse to
>post invalid syntax!
Yeah, yeah... I'm at work, on my windows machine... I'm just a
newbie... yeah, yeah...
:)
Thanks for the great advice again Larry (and San too...).
Jon
------------------------------
Date: Tue, 29 Aug 2000 14:01:46 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Please help: How to check for $var is null or not?
Message-Id: <MPG.1415c491a152a63d98acf4@nntp.hpl.hp.com>
In article <39ac17e5.1266913@news.earthlink.net> on Tue, 29 Aug 2000
20:14:20 GMT, Jon S. <jonceramic@nospammiesno.earthlink.net> says...
> On Tue, 29 Aug 2000 11:19:15 -0700, Larry Rosler <lr@hpl.hp.com>
> wrote:
...
> >Here's a nice way to set true/false:
> >
> > $fooOK = $foo eq 'foocriteria';
>
> Why wouldn't this also warn if $foo is undefined?
Of course it would. Here's a neat way around that:
$fooDH = ($foo || "") eq 'foocriteria';
This '||' tests for trueness as well as definedness, which may not
matter. Oh, for '??'.
> >Instead of testing on the condition and setting a flag, just assign the
> >Boolean value of the condition to the flag.
>
> If I'm using boolean logic to set $fooOK, can I just put the right
> hand of the equation in parenthesis? I assume the '$fooOK ='
> operation takes whatever you give it on the right hand side, no matter
> how hairy, right?
>
> i.e.
> $fooOK = ($foo eq 'foocriteria' && $foo eq 'foocriteria2');
Of course. You don't even need the parentheses in this case (but you
would if the expression included 'and' or 'or' operators, and some
others).
...
> >But you should run the test snippets before posting them. No excuse to
> >post invalid syntax!
>
> Yeah, yeah... I'm at work, on my windows machine... I'm just a
> newbie... yeah, yeah...
http://www.activestate.com/ActivePerl/
> :)
>
> Thanks for the great advice again Larry (and San too...).
De nada.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 29 Aug 2000 18:52:45 GMT
From: "Jevon MacDonald" <jevon@islandtelecom.com>
Subject: Re: Problem with threads in Windows
Message-Id: <1ETq5.166$uR1.23709@sapphire.mtt.net>
Nope (but fork'ing under linux is great and easy), you will need to
interface with the Win32::API to do your threadwork..
You should also specify which module you used to attempt using threads... I
think libwin-0.15 gives you that lovin with Win32::Process.pm ....
Win32::IProc gives you more control.
<rreuss@my-deja.com> wrote in message news:8oflva$ar5$1@nnrp1.deja.com...
> I have installed ActivePerl with a build of perl 5.6.0, and I am coding
> a script that use threads. Now when I use the thread module, I get the
> error: No threads in this perl. I have tried implementing this using
> the fork() call instead, but this make the script crash with some
> memory fault.
> Can it really be, that I have to install Linux to use threads in perl?
>
> Any help is appreciated.
> Rune (rune@egmont-kol.dk)
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Tue, 29 Aug 2000 18:58:38 GMT
From: itgirl57@my-deja.com
Subject: Problems editing text with Perl
Message-Id: <8oh14h$ue3$1@nnrp1.deja.com>
Hi all! I'm VERY new to Perl and am trying to write a script that will
edit a file and then save the file under the same name with the
changes. I've heard that this is something that Perl is supposed to do
very well. However, all I've been able to do is get Perl to make the
changes at the END of the file, which does me no good at all. I've
looked in all of my docs for a solution to no avail. Perhaps someone
here can help? Here's my code:
open(FILE, "+<$file") || die "Can't open $file: $!";
for(<FILE>) {
s/abc/def/g;
print FILE;}
close(FILE);
Here is what the original file looks like:
123456/abc
123456/abc
123456/abc
123456/abc
After I run the script it looks like this:
123456/abc
123456/abc
123456/abc
123456/abc
123456/def
123456/def
123456/def
123456/def
This is NOT what I want! I want a file that contains only the
123456/def lines. I've tried switching the "+<" tag around in front of
$file, but when I move it to +> the file gets clobbered and without the
+ I get a "File opened for read-only" error. Can anybody tell me what
I'm doing wrong?
Thanks!
Itgirl
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 29 Aug 2000 15:38:57 -0400
From: Doug Perham <dperham@dperham.eng.tvol.net>
Subject: Re: Problems editing text with Perl
Message-Id: <81aedvamcu.fsf@wgate.com>
perl -w -p -i -e 's/abc/def/g' foo.txt
--
Doug Perham o{..}o
dperham@wgate.com moo! (oo)___
WorldGate Communications, Inc. (______)\
/ \ / \
------------------------------
Date: Tue, 29 Aug 2000 13:05:24 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Problems editing text with Perl
Message-Id: <MPG.1415b75dd0f5cab98acf3@nntp.hpl.hp.com>
In article <8oh14h$ue3$1@nnrp1.deja.com> on Tue, 29 Aug 2000 18:58:38
GMT, itgirl57@my-deja.com <itgirl57@my-deja.com> says...
> Hi all! I'm VERY new to Perl and am trying to write a script that will
> edit a file and then save the file under the same name with the
> changes. I've heard that this is something that Perl is supposed to do
> very well. However, all I've been able to do is get Perl to make the
> changes at the END of the file, which does me no good at all. I've
> looked in all of my docs for a solution to no avail. Perhaps someone
> here can help? Here's my code:
>
> open(FILE, "+<$file") || die "Can't open $file: $!";
Excellent!
> for(<FILE>) {
Better to use 'while' than 'for'.
> s/abc/def/g;
> print FILE;}
Weird placement of that closing brackets. See `perldoc perlstyle` for
other ways.
> close(FILE);
Even when making equal-length substitutions, you cannot mix input and
output on the same file without careful management of the file-position
indicator, using the seek() function.
For all the details, see:
perlfaq5: "How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the beginning of a
file?"
For as simple a problem as you show, a simple command will do it:
Unix only:
perl -pi -e 's/abc/def/g' filename
For some platforms, you will have to supply the extension for a backup
file, and use double-quotes instead of single-quotes (the double-quotes
would work on Unix too, but people avoid them).
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
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 4167
**************************************