[22516] in Perl-Users-Digest
Perl-Users Digest, Issue: 4737 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 21 03:05:52 2003
Date: Fri, 21 Mar 2003 00:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 21 Mar 2003 Volume: 10 Number: 4737
Today's topics:
Re: Am I asking too much of "map"? <kkeller-spammmm@wombat.san-francisco.ca.us>
Re: Am I asking too much of "map"? <uri@stemsystems.com>
Re: Chopping of everything after a certain word <me@privacy.net>
Re: Chopping of everything after a certain word <babydesmet@hotmail.com>
Re: creating an error box <bwalton@rochester.rr.com>
Re: doubts on \n <fxn@hashref.com>
Re: Find and replace a block of lines with PERL <idont@thinkso.net>
Re: help <jkeen@concentric.net>
Re: help (Tad McClellan)
Re: How can I....? (Cyber Scorpion)
How reliable are Net::FTP status codes? (Tom Beer)
Re: Need a little help with a short script <tassilo.parseval@rwth-aachen.de>
Re: new Perl feature request: call into shared libs <nospam-abuse@ilyaz.org>
Re: new Perl feature request: call into shared libs <mgjv@tradingpost.com.au>
Re: Perl querystring encoding question <mbudash@sonic.net>
perl2exe question <itodd@org.itodd>
Problem using CGI.pm and SSL. <shah@typhoon.xnet.com>
Re: Problem using CGI.pm and SSL. <me@privacy.net>
Problem with Getopt::Std and getopts().... (John Smith)
Re: Problem with Getopt::Std and getopts().... (Tad McClellan)
Re: Problem with Getopt::Std and getopts().... (Jay Tilton)
Re: pulling datafrom database <jkeen@concentric.net>
Re: pulling datafrom database (Tad McClellan)
Re: pulling datafrom database <stevenm@bogus.blackwater-pacific.com>
Re: Reverse assignment operator <torelg@start.no>
Wanted: exetype.pl and related info (Malcolm Dew-Jones)
Re: Wanted: exetype.pl and related info <jurgenex@hotmail.com>
Why can not convet binary to decimal using oct? (W.J cnqin )
Re: Why can not convet binary to decimal using oct? <kalinabears@hdc.com.au>
with ActivePerl, PPM "search" missing results that matc (Bennett Haselton)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 20 Mar 2003 16:59:22 -0800
From: Keith Keller <kkeller-spammmm@wombat.san-francisco.ca.us>
Subject: Re: Am I asking too much of "map"?
Message-Id: <a5od5b.96b.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In article <x7y939ekjd.fsf@mail.sysarch.com>, Uri Guttman wrote:
>>>>>> "KK" == Keith Keller <kkeller-spammmm@wombat.san-francisco.ca.us> writes:
>
> KK> my %h = map { /$regexhere/; $h{$3}=$1 } @array;
>
> KK> ?
>
> if you are not sure, why post a guess?
The guess was for what the OP wanted, not the code. (Though, as
you point out, the code is wrong, too. It happens sometimes.)
> what you might have been thinking of is:
>
> my %h = map { /$regexhere/; ($3, $1) } @array;
No, but close enough:
my %h;
map { /$regexhere/; $h{$3} = $1 } @array;
which I think was posted already.
- --keith
- --
kkeller-mmmspam@wombat.san-francisco.ca.us
(try just my userid to email me)
public key: http://wombat.san-francisco.ca.us/kkeller/kkeller.asc
alt.os.linux.slackware FAQ: http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAj56Y+kACgkQhVcNCxZ5ID8zFACfU6dwQWVIaJA1c3bKBlrmFCs0
po0AnRJZYWZN/Sa8P1hjaUCp9T5hRI1i
=MDtE
-----END PGP SIGNATURE-----
------------------------------
Date: Fri, 21 Mar 2003 01:04:23 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Am I asking too much of "map"?
Message-Id: <x7u1dxedig.fsf@mail.sysarch.com>
>>>>> "KK" == Keith Keller <kkeller-spammmm@wombat.san-francisco.ca.us> writes:
KK> In article <x7y939ekjd.fsf@mail.sysarch.com>, Uri Guttman wrote:
>> what you might have been thinking of is:
>>
>> my %h = map { /$regexhere/; ($3, $1) } @array;
KK> No, but close enough:
KK> my %h;
KK> map { /$regexhere/; $h{$3} = $1 } @array;
KK> which I think was posted already.
and that is using map in a void context which is not cool (to most perl
hackers). the OP wanted to use map to assign directly to %h.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Fri, 21 Mar 2003 15:35:43 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Chopping of everything after a certain word
Message-Id: <b5e4r1$28v99l$1@ID-172104.news.dfncis.de>
"bandb" <babydesmet@hotmail.com> wrote in message
news:wqpea.22132$Vq.1570@afrodite.telenet-ops.be...
> Hello,
>
> I have a maybe easy question, but haven't found the answer yet.
>
> How can I make perl chop of everything that comes after a given word in a
> data-entry?
> E.g. blablabla/blablabla/work_this have to disappear has to become
> blablabla/blablabla/
Looks like you want to work out dirnames and filenames???
#!/usr/bin/perl
use File::Basename;
$path='blablabla/blablabla/work_this';
$dir=dirname($path);
------------------------------
Date: Fri, 21 Mar 2003 07:49:47 GMT
From: "bandb" <babydesmet@hotmail.com>
Subject: Re: Chopping of everything after a certain word
Message-Id: <vuzea.22683$Vq.2140@afrodite.telenet-ops.be>
"Ben" <ben_altman@deadspam.com> schreef in bericht
news:b5d8um$250vs9$1@ID-121117.news.dfncis.de...
> bandb wrote:
> > How can I make perl chop of everything that comes after a given word in
a
> > data-entry?
> > E.g. blablabla/blablabla/work_this have to disappear has to become
> > blablabla/blablabla/
>
> $string = "blabablabl/blab/work_this...";
> $word = "blab/";
>
> $string =~ s/$word.*/$word/;
>
> It will clobber more than one occurance of word.
>
> regards,
> Ben
Thanks!
Pedro
-------
http://www.blueandbroke.be
------------------------------
Date: Fri, 21 Mar 2003 03:29:09 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: creating an error box
Message-Id: <3E7A8444.4010105@rochester.rr.com>
Ben wrote:
> Hi,
>
> I have a perl script called by several applications that currently logs
> errors to a log (when one occurs) but does not inform the user about the
> error. What I would like to do is to pop up an error window that the
> user can click "ok" on aside from the logging of the error that is
> currently happening.
>
>
> Can someone point me to what I would need to use to accomplish this?
>
> Thanks,
> Ben
>
The Tk module would be a nice way to accomplish this. I assume your
script is not a CGI script -- if it is, then check the FAQ in a CGI
newsgroup about how to do it.
--
Bob Walton
------------------------------
Date: Fri, 21 Mar 2003 06:50:29 +0000 (UTC)
From: Xavier Noria <fxn@hashref.com>
Subject: Re: doubts on \n
Message-Id: <b5ecnk$891$1@news.ya.com>
In article <b5d2oi$9fo$1@mamenchi.zrz.TU-Berlin.DE>, Anno Siegel wrote:
: Xavier Noria <fxn@hashref.com> wrote in comp.lang.perl.misc:
:> If "\n" eq "\012" is true in all platforms (as strings, no I/O), how does
:> the I/O system know the first might need translation but not the second?
:> Does the underlying data managed by the interpreter has a flag in that
:> character that marks it as logical newline?
:
: No need for that. All "\n"s are equal and are treated equally.
Thanks to this thread everything is beginning to have sense. Excellent!
From your comment I see I had another misunderstanding. I thought you had to
use "\015\012" in HTTP because hard-coded ASCII codes by-passed the newline
translation of "\n" and friends. Now, it seems that's wrong.
Is that I/O with sockets works different than I/O with files regarding
newline translations? Is "\012" converted to crlf printing to sockets under
Windows so that "\015\015\012" is want is sent behind the scenes? What about
printing to or reading from a process as in open PROC, "| foo"?
I think that's the last piece I need to fit in this puzzle.
Thank you very much to all who contributed!
-- fxn
------------------------------
Date: Thu, 20 Mar 2003 18:29:15 -0500
From: "Chris W" <idont@thinkso.net>
Subject: Re: Find and replace a block of lines with PERL
Message-Id: <tnmdnTExP4gn0-ejXTWcpg@comcast.com>
"KP" <kunal.patel@motorola.com> wrote in message
news:b58ef5$ne8$1@newshost.mot.com...
> I need to replace multiple lines in a text file
>
> eg: File.txt
>
> Line 1> Token 1
> Line 2> 22222222222222222222222222222222
> Line 3> 00000000000000000000000000000000
>
> I need to replace the above lines with
> Line 1> NEW Token
> Line 2> 33333333333333333333333333333333
> Line 3> 11111111111111111111111111111111
>
> only if the first "n" lines (3 in this example) are a perfect match.
>
> I got the script to work if the token exists on only one line. eg: If the
> script finds "Token 1", it will replace it with "NEW Token" but it does
not
> look at the next 3 lines to see if they match.
>
> Any clues on how to fix this ?
> ===============================================
> Usage :> perl find_replace.pl <String to replace> <String to replace with>
>
> foreach $f (@file_list)
> {
> chomp ($f);
> #print $f, "\n";
> $tmp_file = $f;
>
> # retrieve complete file
> open (IN, $tmp_file) or die "cannot open $tmp_file";
> {
> undef $/;
> $infile = <IN>;
> }
> close (IN) || die("Error Closing File: $tmp_file $!");
>
> $infile =~ s/$lhs/$rhs/g;
>
>
> # write complete file
> open (OUT, ">$tmp_file") || die("Error Writing to File: $tmp_file
> $!");
> print OUT $infile;
>
> close (OUT) || die("Error Closing File: $tmp_file $!");
Your example script isn't very well done. Your USAGE line says this script
gets its input from the command line, but it never reads the command line.
You get your first (and only.. keep reading) input file from an array
(@file_list), using a foreach loop. But you never close the loop (no ending
brace) so it falls out the bottom after processing only the first filename
in the array. But most of all, we have no idea where you get values for
$rhs and $lhs. Since this is purportedly a stand alone script, these are
undefined vars. But more importantly, since you probably just left that
part out, we can't tell if they were initialized correctly. It's obviously
the substitution that is failing, so this missing piece is crucial.
That said, according to Programming Perl, undefining $/ (the input record
terminator) SHOULD allow $infile to accept the entire file as one scalar.
(BTW, it also says it is safer to use 'local' instead of undef. The local
$/ will override the global version for the remainder of the block.) Try
printing $infile just before and after the replacement. Or you could read
the file a line at a time, compare each line separately, and use an ugly
three level IF to compare the values you want.
Assuming you print out $infile and the 'before' version does indeed hold the
whole file, but the 'after' version doesn't look the way you want, try
getting the return value from the subtitution operator:
my $count = ( $infile =~ s/$lhs/$rhs/g );
$count will hold the number of times that the substitution found a match and
replaced it. (Since you append the output to your file every time thru,
this could be many times if $rhs and $lhs change.)
Without knowing the parts of the script that are missing, I'm afraid this is
all the help I can give. Good luck.
------------------------------
Date: 20 Mar 2003 23:11:58 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: help
Message-Id: <b5dhru$g8i@dispatch.concentric.net>
"nonsparker" <ajc1234@yahoo.com> wrote in message
news:12ab8c2f.0303201140.59a88891@posting.google.com...
> i need to know what is wrong with this script
>
> #!/usr/bin/perl
> &get_form_data;
> &send_mail;
>
1. Let Perl help you identify what's wrong with the script. Your script
should begin:
#!/usr/bin/perl
use strict;
use warnings;
Fix any problems that Perl identifies once these pragmata are in use, then
get back to us.
2. Can you describe what you expect/want to happen with the script, and
then what _does_ happen? Otherwise, we have no way of judging what you mean
by "wrong".
------------------------------
Date: Thu, 20 Mar 2003 17:52:26 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: help
Message-Id: <slrnb7kl1q.1vu.tadmc@magna.augustmail.com>
nonsparker <ajc1234@yahoo.com> wrote:
> Subject: help
Please put the subject of your article in the Subject of your article.
> i need to know what is wrong with this script
So do we.
Tell us.
What is it that you expect it to do?
What is it doing instead?
> #!/usr/bin/perl
> &get_form_data;
> &send_mail;
>
>
> sub get_form_data
use CGI;
Don't reinvent that wheel.
> sub send_mail
> {
>
>
> @to = ($FORM('options'));
>
> #open(MAIL, "|/usr/sbin/sendmail -t @to") || die("can't open
^
^
That might be a problem...
> print MAIL "If this email has come to you some on has filled out a
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 20 Mar 2003 21:18:44 -0800
From: cyberscorpion@mail.bg (Cyber Scorpion)
Subject: Re: How can I....?
Message-Id: <38d3b40.0303202118.72f7fae3@posting.google.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3E7A276B.2CF4F288@earthlink.net>...
> Cyber Scorpion wrote:
> >
> > I want to compare 2 strings in case in-sensitive mode, but the strings
> > contain cyrillic characters (ascii code > 127 and < 255) and the
> > standart way does not work, i.e. the following code:
> >
> > if ($sdata =~ /$rdata/i)
> > {
> > ....
> > }
> >
> > doesn't work. How can I do this? Please advice!
>
> Convert both strings from ISO8859-5 into perl's native utf8 using either
> the 'encoding' pragma, or a ":encoding(ISO8859-5)" perlio layer, or
> subroutines from the Encode (or Encode::compat) module, or Text::IConv.
>
> Then, you would do as normal:
>
> if( $sdata =~ /^\Q$rdata\E\z/i )
> or:
> if( lc($sdata) eq lc($rdata) )
> or:
> if( uc($sdata) eq uc($rdata) )
>
> Where are $sdata and $rdata coming from? Literal strings? Files? A
> database? (The answer to this question is to know what module will best
> suit your needs for conversion).
I will look for the 'encoding' pragma in perl help. $sdata and $rdata
are coming from .html files (this is a part from a simple search
engine). $sdata is part of the search string (single word) , $rdata is
single word from .html file. Thanks for your help!
------------------------------
Date: 20 Mar 2003 20:09:22 -0800
From: tom.beer@btfinancialgroup.com (Tom Beer)
Subject: How reliable are Net::FTP status codes?
Message-Id: <aa52b6f.0303202009.24d28ff1@posting.google.com>
Hi all,
I want to use ftp to send some large files to another server, but I
need to be 100% sure that the whole file has arrived correctly (or
else an error condition should be returned).
If Net::FTP returns a 0 status from the put, can I be 100% sure the
whole file arrived successfully?
Sorry to ask what may seem to be an obvious question, but I've had
problems trapping errors from FTP before. I have googled and
perldoced, but I haven't got a definitive answer to this question.
Thanks in advance,
Tom.
------------------------------
Date: 21 Mar 2003 07:10:43 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Need a little help with a short script
Message-Id: <b5edtj$hot$1@nets3.rz.RWTH-Aachen.DE>
Also sprach HKVandal:
> Thank you both very much, I appreciate your help excpecially the links
> to other resources. I have been trying to learn perl by using perldoc
> and it has been slow going
The perldocs are fine actually but they require a little experience to
be really useful (sometimes the organization of topics is slightly,
well, idiosyncratic). You'll have that soon. Also, it can't hurt to know
a little more about Perl otherwise parts of them may appear hard to
understand. But you can always ask about those parts you don't fully
understand and be sure that this wont earn you a smack on the head.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Thu, 20 Mar 2003 23:20:17 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <b5dibh$2ju4$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Walter Roberson
<roberson@ibd.nrc-cnrc.gc.ca>], who wrote in article <b5b15p$og9$1@canopus.cc.umanitoba.ca>:
> In article <b59b0u$17iv$1@agate.berkeley.edu>,
> Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> :If the sufficient need arises, any compiler allows to code the
> :solution in ASM.
>
> Use of inline assembler is not part of the ANSI-C standard
Given that no useful program can be written in limits of ANSI-C, I
hardly see why this is relevent to the discussion at hand.
> The SGI compilers for IRIX do not support inline assembler.
...when run on ix86? ;-)
Ilya
------------------------------
Date: Fri, 21 Mar 2003 01:08:12 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <slrnb7kpfs.8eh.mgjv@verbruggen.comdyn.com.au>
[F'ups set away from both current groups]
On Thu, 20 Mar 2003 23:20:17 +0000 (UTC),
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> [A complimentary Cc of this posting was sent to
> Walter Roberson
><roberson@ibd.nrc-cnrc.gc.ca>], who wrote in article <b5b15p$og9$1@canopus.cc.umanitoba.ca>:
>> In article <b59b0u$17iv$1@agate.berkeley.edu>,
>> Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
>> :If the sufficient need arises, any compiler allows to code the
>> :solution in ASM.
>>
>> Use of inline assembler is not part of the ANSI-C standard
>
> Given that no useful program can be written in limits of ANSI-C, I
> hardly see why this is relevent to the discussion at hand.
That, of course, is nonsensical without the qualification of what
_you_ mean by "useful". I have many large slabs of code, some
libraries and some programs, written in compliance with the ISO C
standard. I have never been aware before that none of those is useful.
This is also stupidly off-topic in both groups this is posted to. If
you want to maintain your viewpoint, and try to defend it, do so in
comp.lang.c.
Martien
--
|
Martien Verbruggen | The world is complex; sendmail.cf reflects
Trading Post Australia | this.
|
------------------------------
Date: Fri, 21 Mar 2003 00:30:30 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Perl querystring encoding question
Message-Id: <mbudash-DDD924.16302720032003@typhoon.sonic.net>
In article <907e039c.0303201234.1de824c4@posting.google.com>,
rdodd@xltech.net (Robert Dodd) wrote:
> I am trying to pass values in a querystring that come from a a flat
> file db extracted using Perl (see code below) Can anyone tell me how
> to encode the variable encoding querystring variables $job_title?
> right now it get truncated because it contains a / the code is below
[snip unnecessary code example]
> application.shtml?email=$contact_email&state=$state&position=$job_title
[snip rest of unnecessary code example]
if you're using the CGI perl module:
my $href = 'application.shtml?email=' .
CGI::escape($contact_email) .
'&state=' .
CGI::escape($state) .
'&position=' .
CGI::escape($job_title);
if you're not using the CGI perl module, :
use URI::Escape;
my $href = 'application.shtml?email=' .
uri_escape($contact_email) .
'&state=' .
uri_escape($state) .
'&position=' .
uri_escape($job_title);
hth-
------------------------------
Date: Thu, 20 Mar 2003 00:38:55 -0500
From: itodd <itodd@org.itodd>
Subject: perl2exe question
Message-Id: <v7kofeqft824f2@corp.supernews.com>
I'm using perl2exe to convert my perl script into an exe so I can
distribute it easily.
I'm having trouble compiling the exe on Linux. No matter what I do, I
get this error message:
$ ./perl2exe -platform=Win32 ebay.pl
Perl2Exe V7.00 Copyright (c) 1997-2003 IndigoSTAR Software
ERROR: Unsupported perl version 5.008
I'm assuming they get the 5.008 version number from perl2exe-Win32.ini
since i can change the PERLVERSION variable there and have the error
reflect those changes. I don't know why it defaults to 5.8.0. The
ActivePerl release I'm using is 5.6.1. Changing the variable to 5.006001
doesn't have the desired effect-- it stops the error and actually
compiles the exe but when I go to run the exe I get:
Z:\perl2exe>ebay
Perl lib version (v5.8.0) doesn't match executable version (v5.6.1) at
PERL2EXE_STORAGE/Config.pm line 21.
If anyone has any ideas, I'd appreciate some pointers. Thanks...
--
Todd
------------------------------
Date: Fri, 21 Mar 2003 00:30:52 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: Problem using CGI.pm and SSL.
Message-Id: <b5dmfs$3ea$1@flood.xnet.com>
Folks,
We have apache server installed with SSL support. When I use
https://www.mysite.com, it brings up standard apache intro page. So SSL
seems to work.
I wrote a web page using perl CGI.pm and can display it via
http://www.mysite.com/myscript.pl. When I run the same script using
https://www.mysite.com/myscript.pl I get server error displayed in the
browser. When I looked at the apache error_log, it following message
Premature end of script headers: /full/path/to/myscript.pl
What am I missing?
I have print $q->header; in my script.
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
------------------------------
Date: Fri, 21 Mar 2003 16:05:43 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Problem using CGI.pm and SSL.
Message-Id: <b5e6j9$1d36ve$1@ID-172104.news.dfncis.de>
"Hemant Shah" <shah@typhoon.xnet.com> wrote in message
news:b5dmfs$3ea$1@flood.xnet.com...
>
> Folks,
>
> We have apache server installed with SSL support. When I use
> https://www.mysite.com, it brings up standard apache intro page. So SSL
> seems to work.
>
> I wrote a web page using perl CGI.pm and can display it via
> http://www.mysite.com/myscript.pl. When I run the same script using
> https://www.mysite.com/myscript.pl I get server error displayed in the
> browser. When I looked at the apache error_log, it following message
>
> Premature end of script headers: /full/path/to/myscript.pl
>
> What am I missing?
>
>
> I have print $q->header; in my script.
This has nothing to do with Perl, although I suspect you may have two
versions of the script, as it is highly unlikely that the http https
directory paths are the same.
------------------------------
Date: 20 Mar 2003 16:36:36 -0800
From: clearguy02@yahoo.com (John Smith)
Subject: Problem with Getopt::Std and getopts()....
Message-Id: <500f84f3.0303201636.7582a09f@posting.google.com>
Hi all,
Below is the interested part of my code: (script name is test.pl)
------------------------------------
#! C:/perl/bin/perl -w
use Getopt::Std;
getopts('1:2:3:');
if ($opt_1)
{
$count = 1;
}
elsif ($opt_2)
{
$count = 2;
}
elsif ($opt_3)
{
$count = 3;
}
else
{
$count = 4;
}
--------------------------------------
Now when I run the following command at CMD,
C:\>test.pl 1
It compiles with no errors, but it is taking 4 as $count value (from
else statement).
Similary, when I give 2 or 3 as switch arguments to test.pl, it always
gets 4 for $count variable.
What is wrong here? I want $count =1, when I give 1 as switch and
$count =2, when I give 2 as switch and so on.
Thanks,
John
------------------------------
Date: Thu, 20 Mar 2003 21:29:54 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem with Getopt::Std and getopts()....
Message-Id: <slrnb7l1pi.2eh.tadmc@magna.augustmail.com>
John Smith <clearguy02@yahoo.com> wrote:
> use Getopt::Std;
>
> getopts('1:2:3:');
> Now when I run the following command at CMD,
>
> C:\>test.pl 1
You are invoking the program with one argument, but zero switches.
> It compiles with no errors, but it is taking 4 as $count value (from
> else statement).
That is what it is supposed to do when you call it with no switches.
> What is wrong here?
You are not invoking the program with any switches.
Switches start with a hyphen character (or maybe a slash on your
platform? I dunno).
C:\>test.pl -1
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 21 Mar 2003 03:55:10 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Problem with Getopt::Std and getopts()....
Message-Id: <3e7a8b13.60562201@news.erols.com>
clearguy02@yahoo.com (John Smith) wrote:
: Below is the interested part of my code: (script name is test.pl)
: ------------------------------------
: #! C:/perl/bin/perl -w
:
: use Getopt::Std;
:
: getopts('1:2:3:');
:
: if ($opt_1)
: {
: $count = 1;
: }
: elsif ($opt_2)
: {
: $count = 2;
: }
: elsif ($opt_3)
: {
: $count = 3;
: }
: else
: {
: $count = 4;
: }
:
: --------------------------------------
:
: Now when I run the following command at CMD,
:
: C:\>test.pl 1
:
: It compiles with no errors, but it is taking 4 as $count value (from
: else statement).
Two things:
1) Switches start with a hyphen.
2) The colons in "getopts('1:2:3:')" mean those switches take
arguments.
If you want arguments for the switches, invoke the program like
"test.pl -1 foo" and test the defined-ness of $opt_1 instead of its
boolean true/false state.
If you just want boolean switches, remove the colons and invoke the
program like "test1.pl -1".
------------------------------
Date: 20 Mar 2003 23:11:56 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: pulling datafrom database
Message-Id: <b5dhrs$g8o@dispatch.concentric.net>
"ramesh" <rpalla@kentlaw.edu> wrote in message
news:2b0865a8.0303201446.47629e6d@posting.google.com...
> while( $row = $csr->fetchrow_hashref ) {
> print Dumper($row);
> }
> and My outputis like this.
> $VAR1 = {
> 'ENVOBJID' => '226'
> };
>
> but i want to caputure only 226. How to get this through
> program...i am just sstarted learning perl.
If each instance of %$row consists of only one key-value pair, then, as far
as I can tell, you can avoid Data::Dumper entirely:
my %row = ('ENVOBJID' => '226');
print "$row{$_}\n" foreach (sort keys %row);
If that doesn't work, then perhaps you can clarify your objective. HTH.
Jim Keenan
------------------------------
Date: Thu, 20 Mar 2003 17:57:44 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: pulling datafrom database
Message-Id: <slrnb7klbo.1vu.tadmc@magna.augustmail.com>
ramesh <rpalla@kentlaw.edu> wrote:
> while( $row = $csr->fetchrow_hashref ) {
> and My outputis like this.
>
> $VAR1 = {
> 'ENVOBJID' => '226'
> };
>
> but i want to caputure only 226. How to get this through
> program
print $row->{ENVOBJID};
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 20 Mar 2003 16:15:36 -0800
From: Steve May <stevenm@bogus.blackwater-pacific.com>
Subject: Re: pulling datafrom database
Message-Id: <b5dl0c$r3e$1@quark.scn.rain.com>
ramesh wrote:
> Hi
>
> I am pulling data from database (msaccess and odbc oracle driver)
> through select command.
>
> my select statement and code is as follows
>
> if (defined $dbh) {
> $csr =$dbh->prepare("select ENVOBJID from
> HARENVIRONMENT where
> environmentname like 'Release2%'");
>
> $csr->execute() || die "Could not execute SQL
> statement, ma
> ybe invalid?";
>
> while( $row = $csr->fetchrow_hashref ) {
>
> print Dumper($row);
>
> }
>
>
> and My outputis like this.
>
>
> $VAR1 = {
> 'ENVOBJID' => '226'
> };
>
> but i want to caputure only 226. How to get this through
> program...i am just sstarted learning perl.
If all you are looking for is a single value per row,
do you really need to fetch a hashref?
while( my @row = $csr->fetchrow_array() ){
print "$row[0]\n";
}
*might* be closer to what you need...
perldoc DBI
s.
------------------------------
Date: Fri, 21 Mar 2003 07:58:05 +0000 (UTC)
From: Tore Linde Gustavsen <torelg@start.no>
Subject: Re: Reverse assignment operator
Message-Id: <slrnb7lhht.2os.torelg@localhost.localdomain>
Copied from my last post:
Thanks to both Tassilo and Bernard for answers.
I've heard that perl6 will and that it `will come when it's finished'.
As long as The Linguist doesn't incorporate the 'ever evolve, never
finished'-property of spoken languages into perl6, this is fine.
Ok, so noone knows. But maybe someone could shed a little light. We're
talking about years?
--
Tore Gustavsen,
torelg@start.no
------------------------------
Date: 20 Mar 2003 22:30:37 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Wanted: exetype.pl and related info
Message-Id: <3e7ab18d@news.victoria.tc.ca>
This is most frustrating since I have played around with this axact issue
in the past. I'm sure it's even a faq, but which one?
I want to touch perl.exe to convert it into a non-console program so it
does not display the dos window. There used to be a script called
exetype.(pl|bat), which apparently just toggles one byte in the perl.exe
file to do this. However this script no longer seems to come with active
state perl, and I also haven't found it in my archived copies of
activestate perl. I must have deleted/lost the version that had it.
Which byte must be toggled? What url has the exe format documented?
------------------------------
Date: Fri, 21 Mar 2003 06:36:08 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Wanted: exetype.pl and related info
Message-Id: <spyea.45118$Ad6.32691@nwrddc01.gnilink.net>
Malcolm Dew-Jones wrote:
> This is most frustrating since I have played around with this axact
> issue in the past. I'm sure it's even a faq, but which one?
>
> I want to touch perl.exe to convert it into a non-console program so
> it does not display the dos window.
If you are running ActiveState Perl just use wperl.exe instead of perl.exe.
jue
------------------------------
Date: 21 Mar 2003 12:08:07 +0800
From: qin@freebsd.lzu.edu.cn (W.J cnqin )
Subject: Why can not convet binary to decimal using oct?
Message-Id: <86d6klcqfs.fsf@freebsd.lzu.edu.cn>
When I read perldoc , I notice that oct can convert binary or heximal
to decimal. I write a simple script to test it. But the result is not
what I want. Why?
#!/usr/bin/perl -w
use strict;
my @list= ("0b0011", "0x041");
foreach (@list){
print oct($_),"\n";
}
The result is:
0
65
Any help is appreciated.
------------------------------
Date: Fri, 21 Mar 2003 17:12:58 +1100
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Why can not convet binary to decimal using oct?
Message-Id: <3e7aae47$0$885@echo-01.iinet.net.au>
"W.J cnqin " <qin@freebsd.lzu.edu.cn> wrote in message
news:86d6klcqfs.fsf@freebsd.lzu.edu.cn...
>
> When I read perldoc , I notice that oct can convert binary or heximal
> to decimal. I write a simple script to test it. But the result is not
> what I want. Why?
>
> #!/usr/bin/perl -w
>
> use strict;
> my @list= ("0b0011", "0x041");
>
> foreach (@list){
> print oct($_),"\n";
> }
>
> The result is:
> 0
> 65
>
> Any help is appreciated.
>
Works fine for me - prints
3
65
Is that an actual cut'n'paste of your script ?
Cheers,
Rob
------------------------------
Date: 20 Mar 2003 23:29:11 -0800
From: bennett@peacefire.org (Bennett Haselton)
Subject: with ActivePerl, PPM "search" missing results that match regular expression?
Message-Id: <e614455c.0303202329.78b8ceac@posting.google.com>
I'm running ActivePerl 5.6.0 with PPM interactive shell (2.1.2). When
I type
ppm search
I get a whole lot of screenfuls of module names, and if I hit Enter
enough times and scroll far enough through the list, I can see
Crypt-SSLeay listed:
>>>>>>
Crypt-RandPasswd [0.02 ] random
password
generator
based on
FIPS-181
Crypt-Random [1.12 ]
Cryptographically
Secure, True
Random
Number
Generator.
Crypt-Rijndael [0.05 ] Crypt::CBC
compliant
Rijndael
encryption
module
Crypt-Rijndael_PP [0.04 ] Pure Perl
implementation
of
Rijndael (AES)
Crypt-Rot13 [0.04 ] a rotational
deviator
Crypt-SKey [0.05 ] Perl S/Key
calculator
Crypt-SSLeay [0.49 ] OpenSSL glue
that
provides LWP
https
support
Crypt-SecurID [0.03 ] module for
generating
and verifying
SecurID
time hash
codes
Crypt-Serpent [1.01 ] Crypt::CBC
compliant
Serpent block
cipher
encryption
module
>>>>>>
But if I do
ppm search "crypt"
then some of the ones listed above are missing from the results:
>>>>>>
Crypt-Beowulf [0 ]
Crypt-Blowfish [2.09 ] Perl Blowfish encryption module
Crypt-Blowfish_PP [1.12 ] Blowfish encryption algorithm
implemented purely
in Perl
Crypt-CAST5 [0.02 ] CAST5 block cipher
Crypt-CAST5_PP [1.02 ] CAST5 block cipher in pure Perl
Crypt-CBC [2.08 ] Encrypt Data with Cipher Block Chaining
Mode
Crypt-CBCeasy [0.24 ] Easy things make really easy with
Crypt::CBC
Crypt-CFB [0.01 ] Encrypt Data in Cipher Feedback Mode
Crypt-Caesar [0.01 ] Decrypt rot-N strings
Crypt-CipherSaber [0.61 ] Perl module implementing CipherSaber
encryption.
Crypt-Ctr [0.01 ] Encrypt Data in Counter Mode
Crypt-DES [2.03 ] Perl DES encryption module
Crypt-DES_EDE3 [0.01 ] Triple-DES EDE encryption/decryption
Crypt-DES_PP [1.00 ] Perl extension for DES encryption
Crypt-ECB [1.1-2] Encrypt Data using ECB Mode
Crypt-Enigma [1.1 ] Perl extension for emulating a World
War II
Enigma
Crypt-GOST [1.00 ] The GOST Encryption Algorithm
Crypt-GOST_PP [1.10 ] Pure Perl implementation of the GOST
encryption
algorithm
Crypt-GeneratePassword [0.02 ] generate secure random pronounceable
passwords
Crypt-Memfrob [1.00 ] memfrob implementation in pure Perl
Crypt-Mimetic [0.02 ] Camouflage a file behind another one
Crypt-NULL [1.02 ] NULL Encryption Algorithm
Crypt-OOEnigma [0.3 ] A World War II Enigma machine in a
flexible OO
framework
Crypt-OTP [2.00 ] Perl implementation of the One Time Pad
(hence,
OTP) encryption method.
Crypt-PGP2 [0.03 ] module for programmatic PGP 2.x on Unix
Crypt-PGPSimple [0.13 ] Object-oriented interface to PGP
Crypt-PasswdMD5 [1.2 ] Provides interoperable MD5-based
crypt()
function
Crypt-RC4 [2.02 ] Perl implementation of the RC4
encryption
algorithm
Crypt-RC5 [2.00 ] Perl implementation of the RC5
encryption
algorithm.
Crypt-RC6 [1 ] Crypt::CBC compliant RC6 block cipher
encryption
module
Crypt-RIPEMD160 [0.04 ] Perl extension for the RIPEMD-160 Hash
function
Crypt-RandPasswd [0.02 ] random password generator based on
FIPS-181
Crypt-Rijndael [0.05 ] Crypt::CBC compliant Rijndael
encryption module
Crypt-Rijndael_PP [0.04 ] Pure Perl implementation of Rijndael
(AES)
Crypt-Rot13 [0.04 ] a rotational deviator
Crypt-Serpent [1.01 ] Crypt::CBC compliant Serpent block
cipher
encryption module
Crypt-Simple [0.06 ] encrypt stuff simply
Crypt-SmbHash [0.02 ] Perl-only implementation of lanman and
nt md4
hash functions, for use in Samba style
smbpasswd
entries
Crypt-Solitaire [2 ] Solitaire encryption
Crypt-TEA [1.25 ] Tiny Encryption Algorithm
Crypt-Tea [1.43 ] Tiny Encryption Algorithm in Perl and
JavaScript
Crypt-TripleDES [0.24 ] Triple DES encyption.
Crypt-Twofish [2.12 ] The Twofish Encryption Algorithm
Crypt-Twofish2 [0.06 ] Crypt::CBC compliant Twofish encryption
module
Crypt-UnixCrypt [1 ] perl-only implementation of the "crypt"
function.
Crypt-Vigenere [0.07 ] Perl implementation of the Vigenere
cipher
Games-Cryptoquote [1.30 ] Solves Cryptoquotes
Module-CryptSource [0.02 ] Encrypt and Decrypt source for Binary
Packagers
Tie-EncryptedHash [1.21 ] Hashes (and objects based on hashes)
with
encrypting fields.
>>>>>>>
Specifically, Crypt-Random, Crypt-SKey, Crypt-SSLeay, and
Crypt-Serpent (and probably some others; I didn't check all the
Crypt-* modules) are listed in the first set of results, but not in
the second set. Why would a search for "crypt" not include those
modules in the results?
I also tried doing:
ppm search SSLeay
but that turned up zero results, even though "Crypt-SSLeay" is listed
in the first set of results above.
Is PPM doing something wrong, or am I?
-Bennett
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4737
***************************************