[8358] in Perl-Users-Digest
Perl-Users Digest, Issue: 1975 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 25 19:07:53 1998
Date: Wed, 25 Feb 98 16:00:28 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 25 Feb 1998 Volume: 8 Number: 1975
Today's topics:
Re: ?? How to unpack a string into an array ?? (Martien Verbruggen)
Re: CGI.pm a part of Perl (was Re: Cookies) (Martien Verbruggen)
Changing From address in Mail (Steve)
Re: convert a string to a number (I R A Aggie)
Re: Cookie with Perl (Martien Verbruggen)
Re: Counting number of replaces (Martien Verbruggen)
Re: DBD::mSQL (Johannes la Poutre')
Features Problem <batkins@age.net>
Re: file test inside grep() (Martien Verbruggen)
Re: HELP array stuff (Martien Verbruggen)
Re: How do I create my own perl libraries? (Martien Verbruggen)
Newbie Question: df in a perl script <mc-witt@students.uiuc.edu>
Re: Perl Compiler Problems <cmihaly@fa.disney.com>
Re: Please Tell me:- Differences of Linux and NT. (Martien Verbruggen)
Re: Regex substitutions <joneil@cks.ssd.k12.wa.us>
Re: Regex substitutions chris+usenet@netmonger.net
Re: Regex substitutions <joneil@cks.ssd.k12.wa.us>
Re: Replacement of characters (I R A Aggie)
Re: Replacement of characters (Michael Martin)
Re: Socket question for Win32 <jay@rgrs.com>
Re: Splitting on 2 line feeds? (Martien Verbruggen)
Re: test post <atstarr@negia.net>
Re: The Ineffable Tom C. (Martien Verbruggen)
Re: The Ineffable Tom C. (Martien Verbruggen)
Re: Verifying a form field (Martien Verbruggen)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Feb 1998 22:56:18 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: ?? How to unpack a string into an array ??
Message-Id: <6d27ii$1t1$2@comdyn.comdyn.com.au>
In article <34F468DB.49E5@asptech.com>,
Phil Hutchinson <philh@asptech.com> writes:
> HOW CAN I UNPACK THE $string BACK INTO @array so that I can use
> the elements individually???
Have a look at pack and unpack
perldoc -f pack
perldoc -f unpack
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I think I think, therefore I think I
Commercial Dynamics Pty. Ltd. | am.
NSW, Australia |
------------------------------
Date: 25 Feb 1998 22:25:36 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: CGI.pm a part of Perl (was Re: Cookies)
Message-Id: <6d25p0$1n8$3@comdyn.comdyn.com.au>
In article <34F43AF4.632D@min.net>,
John Porter <jdporter@min.net> writes:
> $.02:
> perl is the language and the interpreter for that language;
> Perl is the distribution and the culture.
> Ergo, some modules are 100% perl, some are partly C.
> Some modules are part of Perl, some aren't.
>
> John Porter
Perldoc perlfaq1
What's the difference between "perl" and "Perl"?
One bit. Oh, you weren't talking ASCII? :-) Larry now uses "Perl"
to signify the language proper and "perl" the implementation of
it, i.e. the current interpreter. Hence Tom's quip that "Nothing
but perl can parse Perl." You may or may not choose to follow
this usage. For example, parallelism means "awk and perl" and
"Python and Perl" look ok, while "awk and Perl" and "Python and
perl" do not.
Where did your definitions come from? Maybe the faq is out of date?
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd. | enough features yet.
NSW, Australia |
------------------------------
Date: Wed, 25 Feb 1998 22:54:31 GMT
From: nospamtovanhalen@coredcs.com-nospammy (Steve)
Subject: Changing From address in Mail
Message-Id: <34f493b0.457051952@enews.newsguy.com>
hello,
I am limited to using cgi-lib.pl on my server as the sysop won't
install cgi.pm. Therefore I am using cgi-lib.pl.
I'm looking to send mail by opening a pipe to the mail command.
However I would also like to change the "From" address of the
resulting messages.
Can this be done?
I'm changing the subject line now with the -s option, but as of yet
have been unable to find any documentation on an option to change the
from address.
------------------------------
Date: Wed, 25 Feb 1998 17:34:53 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: convert a string to a number
Message-Id: <fl_aggie-2502981734530001@aggie.coaps.fsu.edu>
In article <6d2039$hbe$2@usenet53.supernews.com>,
*nospam*mg*nospam*@*nospam*pcg*nospam.net (Maxine G.) wrote:
+ I'm afraid this may be one of those really obvious beginner questions, but
+ here goes:
+ How do I convert a string containing numeric data to a numeric variable?
You don't. Perl does the Right Thing given the Proper Context. Example:
$a="0123";
$b=$a;
print "$b\n"; # result is: 0123
$b+=0;
print "$b\n"; # result is: 123
The first print gives the leading 0 back because its still treating things
as a string. The second print, however, eliminates the leading 0 because
a mathematical operation ($b+=0; is the same as $b=$b+0;) has been
performed, and the leading 0 is extraneous for mathematical needs.
This is one of the beauties of perl: you may use numbers either as
numbers or as strings just by specifying the proper context, and not
have to explicitly convert them.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: 25 Feb 1998 22:43:20 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Cookie with Perl
Message-Id: <6d26q8$1n8$7@comdyn.comdyn.com.au>
In article <6d1d6l$2j28@lyra.hkstar.com>,
"Martin" <koala1998@hotmail.com> writes:
> I have written a perl script to expire a cookie. But when i pressed the
> back button on the browser, the cookie is set back to its origianl value.
> Anyone experienced that? Can somebody help?
This has absolutely nothing at all to do with perl. Please go to one of the
comp.infosystems.www.* groups, and ask the people there.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | What's another word for Thesaurus?
NSW, Australia |
------------------------------
Date: 25 Feb 1998 22:41:35 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Counting number of replaces
Message-Id: <6d26mv$1n8$6@comdyn.comdyn.com.au>
In article <34F4176C.4EFCBF8A@dircon.co.uk>,
Alex Schajer <schajer@dircon.co.uk> writes:
> Is there anyway to count how many time a regexp replace has occurred
> $var =~ s/1/2/g ?
perldoc perlop
(find s/PATTERN/REPLACEMENT/egimosx)
Searches a string for a pattern, and if found,
replaces that pattern with the replacement text and
returns the number of substitutions made.
[snip]
$count = ($paragraph =~ s/Mister\b/Mr./g);
Please, read the documentation before posting next time.
> Please reply to alex@online.emap.com as well as to the group,
Nope. Your From: Header had a different address, and I refuse to type
this one.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Thu, 26 Feb 1998 00:03:52 +0100
From: jlpoutre@inter.NL.net (Johannes la Poutre')
Subject: Re: DBD::mSQL
Message-Id: <jlpoutre-ya02408000R2602980003520001@news.leiden.nl.net>
In article <34F2F7ED.96AD0C26@muc.de>, Lutz Albers <lutz@muc.de> wrote:
>kevin graham wrote:
>
>> my $h_idexists = $dbh->prepare($SQL) || die $dbh->errstr;
>>
>> print "hope";
>> $h_idexists->execute($SQL) || print "dammit"; #die $dbh->error
>
>Hmm, why do give a parameter to execute ? $h_idexists->execute; should be
>enough, it worked for me this way.
>
>ciao
> lutz
Moreover, today I erroneously typed a parameter to the execute() method,
and my (ePerl embedded-) script died with a warning message about it ;-)
Just $0.02...
Joe.
--
Johannes la Poutre', NL
------------------------------
Date: Wed, 25 Feb 1998 18:20:27 -0500
From: Brad Atkins <batkins@age.net>
Subject: Features Problem
Message-Id: <34F4A73B.399D03A1@age.net>
I have a chat script, that will work fine for a bit then after a while
the private messages will stop working. It might be because I changed
something, but chances are that isn't the case. I re-install a fresh
copy, paths are correct, and they still don't work
Does it make sense for certain features to just not work?! If you can
help, or have suggestions, get back to me, PLEASE:)
Brad Atkins
batkins@tamrockcanada.ca
------------------------------
Date: 25 Feb 1998 22:55:14 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: file test inside grep()
Message-Id: <6d27gi$1t1$1@comdyn.comdyn.com.au>
In article <34F44CFE.313DD44F@sedona.intel.com>,
Franklin Brodsky <fbrodsky@sedona.intel.com> writes:
> #!/usr/bin/perl -w
-w, good :)
no use strict? :(
> # open the current directory
> opendir(WORKDIR, ".") || die "Can't open directory '.'\n";
You might want to include the $! variable in your message string. It
will tell you why the opendir failed.
> # look for names of directories which contain a "." but do not start
> with it.
> @subdirs = grep ( /\./ , grep ( !/^\./ , grep ( -d ,
> readdir(WORKDIR))));
alternatives:
@subdirs = grep { /\./ and ! /^\./ } readdir(WORKDIR);
@subdirs = grep { /^[^\.]+\./ } readdir(WORKDIR);
> # Find any files within these directories whose names begin with the
> # name of the directory
>
> foreach $dir (@subdirs) {
> print "Looking in ./$dir\n";
> opendir(SUBDIR, "./${dir}") || die "Can't open directory ./${dir} :
> $!\n";
Heh, you obviously did know about $! :) Why the curlies around dir?
> # The following line should (a) read the contents of the SUBDIR directory
> # (b) filter *out* files which are not plain files
> # (no directories or links for me, please)
> # (c) pass along the names of only those files
> # whose names begin with the name of the
> # directory in which they are found
> @testfiles = grep ( /^$dir/ , grep ( -f , readdir(SUBDIR)));
readdir returns a list of files in the directory, but not woth the
directory name prepended. You will need to test
@testfiles = grep { /^$dir/ and -f "$dir/$_" } readdir(SUBDIR);
otherwise -f tests just $_, which is not a file in the current
directory.
Hope these solve it, or at least make your greps a bit more legible.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use being
NSW, Australia | a damn fool about it.
------------------------------
Date: 25 Feb 1998 22:28:10 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: HELP array stuff
Message-Id: <6d25tq$1n8$4@comdyn.comdyn.com.au>
In article <34F34A91.6F0CB71E@collins.rockwell.com>,
Tim Countryman <tlcountr@collins.rockwell.com> writes:
> This works for me - if I substitute @array2 for @prodata in
> the 'foreach'
without changing $A or $A1?
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd. | you come to the end; then stop.
NSW, Australia |
------------------------------
Date: 25 Feb 1998 22:58:55 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How do I create my own perl libraries?
Message-Id: <6d27nf$1t1$3@comdyn.comdyn.com.au>
In article <34F3FCFF.5E5194AF@pacificnet.net>,
Joey Garcia <bear@pacificnet.net> writes:
> Hello, I'm sort of new but I'm getting the hang of everything here
> pretty quickly. I've written a few working cgi scripts and I keep
> coming up with more. The problem I have is that I use alot of the same
> code in each one. I wanted to know if there was a way I can make my own
> perl libraries or modules that I can include into the actual perl
> execuables. Also, can I run my personal libraries from the same
> directory that contain the cgi programs? Thanks for the help.
perldoc -f require
perldoc -f use
perldoc perlmod
perldoc perlmodlib
If you want to do it in an OO way
perldoc perltoot
perldoc perlref
perldoc perlobj
perldoc perlbot
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use being
NSW, Australia | a damn fool about it.
------------------------------
Date: Wed, 25 Feb 1998 17:31:39 -0600
From: Mark <mc-witt@students.uiuc.edu>
Subject: Newbie Question: df in a perl script
Message-Id: <Pine.SOL.3.96.980225172653.8611A-100000@ux9.cso.uiuc.edu>
Hey everyone!
I'm getting a crash course in Perl scripts at work right now and I've hit
a snag.
Is there anyway to similulate or pass a df -k command in a perl script?
Specifically, I need to find the percent of capacity occupied on the disk.
I've tried to use stat but it isn't supplying the info I need.
Thanks in advance!
--Mark Witt-- --"Psychiatrists say that 1 of 4--
--mc-witt@students.uiuc.edu-- --people are mentally ill. Check 3--
--www.students.uiuc.edu/~mc-witt-- --friends. If they're O.K., you're it."--
------------------------------
Date: Wed, 25 Feb 1998 15:18:01 -0800
From: Chris Mihaly <cmihaly@fa.disney.com>
To: perlbug@perl.com
Subject: Re: Perl Compiler Problems
Message-Id: <34F4A6A9.F5058337@fa.disney.com>
Some additional information to this problem (plus I thought I would
post it to the perl newsgroup in case someone there has some insight).
If I add the -c switch (syntax check only, no execution) it still core
dumps. This seems to me to indicate that the compiler is unhappy about
some syntax element. I'm thinking of building perl with the debug flag
on (however, I fear that this will fix the problem since it will change
the memory pattern and the path to perl will change which will also
seems to effect this). Is there some switch I can use to see what the
Perl compiler was dealing with when the dump happened?
We have also seen this core dump in other programs that use some of the
same modules, again only in very specific environments, subtle changes
will cause the problem not to appear.
Thanks
Chris
Chris Mihaly wrote:
>
> We have a very difficult to diagnose problem. We have a Perl script
> that has a recurring coredump. It appears, to the best of our
> dianostics, to be during the script parsing/compilation phase.
>
> This core dump will go away with very slight changes, even
changes to
> the UNIX environment. For instance, just defining a new UNIX
> environment variable will cause the core dump to go away. Adding an
> addition switch will cause it to go away. Adding, or removing a
comment
> from any of our Perl modules/code will cause it to go away.
However,
> when it does core-dump, it does so 100% until something get changed.
>
> Generally, it will work fine when running the debugger,
however we have
> got it to core dump in this situation (which core dumps before the
> debugger goes interactive). We have put in BEGIN blocks, which
either
> makes the entire tree work, or never gets invoked depending on where
we
> place the BEGIN block.
>
> The call tree stack of the core dump is attached as
perl.trace.
>
> So I am hoping that someone can give me a clue, maybe from
the stack
> trace, or any hint on things that might shed some more light on what
is
> happening. The script is fairly large, it does use GetOpt and Carp
and
> a few other packages that come standard with Perl, we have some
packages
> of our own that are used. Nothing appears to be too strange or that
we
> would suspect causes this problem. Again, the slightest thing will
> cause the core dump to move.
>
> Any help would be great!
> Chris
>
>
------------------------------------------------------------------------
> _lmalloc(<stripped>) ["malloc.c":529]
> _malloc(<stripped>) ["malloc.c":105]
> safemalloc(<stripped>) ["util.c":84]
> Perl_newBINOP(<stripped>) ["op.c":1707]
> Perl_newWHILEOP(<stripped>) ["op.c":2584]
> Perl_newFOROP(<stripped>) ["op.c":2644]
> Perl_yyparse(<stripped>) ["perly.y":200]
> Perl_doeval(<stripped>) ["pp_ctl.c":1996]
> Perl_pp_require(<stripped>) ["pp_ctl.c":2145]
> Perl_runops(<stripped>) ["run.c":29]
> perl_call_sv(<stripped>) ["perl.c":786]
> Perl_calllist(<stripped>) ["perl.c":2051]
> Perl_newSUB(<stripped>) ["op.c":2883]
> Perl_utilize(<stripped>) ["op.c":2063]
> Perl_yyparse(<stripped>) ["perly.y":271]
> perl_parse(<stripped>) ["perl.c":471]
> main(<stripped>) ["perlmain.c":45]
> __start(<stripped>) ["crt1text.s":166]
------------------------------
Date: 25 Feb 1998 23:07:19 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Please Tell me:- Differences of Linux and NT.
Message-Id: <6d2877$1t1$4@comdyn.comdyn.com.au>
[removed alt.perl and from newsgroups line. My server doesn't carry it,
and rightfully so, in my opinion.]
[also removed tw.bbs.comp.lang.perl]
In article <6d1pqh$r6$1@news.enterprise.net>,
"Mr. Adam ALLEN." <adamallen@@@mail-me.com> writes:
> I currently use NT for my scripts, what's the difference between Linux and
> NT?
Lots of differences. If your scripts are well written, none you should
worry about. Check the perl for win32 FAQ at
http://www.perl.com/CPAN/doc/FAQs/win32/Perl_for_Win32_FAQ.html
> Does Linux have filepermissions like Unix, and if writing a text file in a
> perl does it need to have permssions set, and how would you do it?
Linux is a Unix, so the answers are: yes, the same way as on any other
unix.
> Are there anyother differences which would stop a perl working?
differences between what and what? perl works fine on Linux, it works
as well as can be expected on NT, and runs on lots of other platforms
without problems.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd. | excuse - Lazarus Long
NSW, Australia |
------------------------------
Date: Wed, 25 Feb 1998 15:00:45 -0800
From: Jerome O'Neil <joneil@cks.ssd.k12.wa.us>
To: Dan Boorstein <dboorstein@shopcfn.com>
Subject: Re: Regex substitutions
Message-Id: <34F4A29D.6A2873E9@cks.ssd.k12.wa.us>
Dan Boorstein wrote:
> my idea is to replace the end of the string, that is all the
> parens and their possible leading space, with themselves
> preceded by a space and the string to add.
>
> #!/usr/bin/perl -w
> $scalar0 = 'Beacon Hill';
> $scalar1 = 'Beacon Hill (B)';
> $scalar2 = 'Beacon Hill (B)(D)';
> $add = 'Half Day K';
>
That is a soulution, but the context of my (within a loop) regex precludes
it. It looks like this:
while(($schlid,$opt,$hg,$lg,$dooc,$schlnm) = $sth->FetchRow()) # Grabing a
whole lot of stuff from an rdbms
{
$schlnm =~ s/(.+?)(\(.\){0,2})/$1 Half Day K $2/; # A working regex
(Thanks Jack!)
# Other interesting things with $schlnm
}
so it would require another regex just to determine which of the three
possible formats it was in. The problem was that .+ is a greedy operator,
and misunderstood what that meant. The .+? fixed it.
Thanks for the help, though.
Jerome
> for ($scalar0, $scalar1, $scalar2) {
> # s/(\s*(?:\(.\)){0,2})?$/ $add$1/;
> s/( # begin optional capture
> \s* # 0 or more spaces
> (?: # begin group
> \(.\) # grab parenthesized letter
> ){0,2} # between 0 and 2
> )? # end optional capture
> $/ $add$1/x; # tied to end of string
> print "$_\n";
> }
>
> --
> dan boorstein <dboorstein@shopcfn.com>
> #!/usr/bin/perl -w -- 2 for 1
> # my first Just another Perl hacker,
> seek DATA,0,0;{$_=<DATA>,/#!/&&redo}print join(' ',(split)[3..6])__END__
> # my second Just another Perl hacker,
------------------------------
Date: 25 Feb 1998 22:58:36 GMT
From: chris+usenet@netmonger.net
Subject: Re: Regex substitutions
Message-Id: <6d27ms$91m$1@schenectady.netmonger.net>
In article <34F48830.E6D72D5D@cks.ssd.k12.wa.us>,
Jerome O'Neil <joneil@cks.ssd.k12.wa.us> wrote:
> I'm stuck on a regex.
>
> I have a scalar consisting of a variable number of characters, followed
> by zero, one or two sets of parens arround a single character.
>
> Three examples are
>
> Beacon Hill
> Beacon Hill (B)
> Beacon Hill (B)(D)
>
> I need to concatenate another string between the parenthesis and the
> text string.
>
> So 'Beacon Hill (B)' becomes 'Beacon Hill Half Day K (B)'
>
> $schlnm =~ s/ # Start a substitution regex
>
> (.+) # Match all the text
> from the begining of the string and assign it to $1
> (\(.\)) # Match a paretethis
> surounding a character i.e. (G) and save it in $2
> {0,2} # Match at least zero
> but no more than two of the last group
> /$1 Half Day K $2/x; # Substitute the match with this
> and add some comments.
That sure is scary. Rather than worry about what it's doing, I'll
start over. From your description, the string ends with 0-2 instances
of \(.\), so I would anchor the end and match that:
/(?:\(.\)){0,2}$/
(?: ... ) used for grouping without capturing. With the repetition {0,2},
you really want to capture the whole repeating sequence, not each
\(.\) group. So throw an extra set of parens around the whole thing...
/((?:\(.\)){0,2})$/
That's pretty good, except that when you use it in a substitution, there's
extra whitespace left on the "untouched" beginning of the string sometimes.
But that's easy to handle, so we end up with:
s/(\s*(?:\(.\)){0,2})$/ Half Day K$1/
I think that does what you want.
--
Christopher Masto <chris+usenet@netmonger.net>
Director of Operations, NetMonger Communications, Inc.
------------------------------
Date: Wed, 25 Feb 1998 15:16:36 -0800
From: Jerome O'Neil <joneil@cks.ssd.k12.wa.us>
To: chris+usenet@netmonger.net
Subject: Re: Regex substitutions
Message-Id: <34F4A654.1D767F85@cks.ssd.k12.wa.us>
chris+usenet@netmonger.net wrote:
> s/(\s*(?:\(.\)){0,2})$/ Half Day K$1/
>
> I think that does what you want.
> --
>
Indeed it does. With an excellent lesson to boot. Thanks!
Jerome
------------------------------
Date: Wed, 25 Feb 1998 17:37:30 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Replacement of characters
Message-Id: <fl_aggie-2502981737310001@aggie.coaps.fsu.edu>
In article <34F48893.C07C6FF5@nortel.ca>, Yu Xie <xieyum@nortel.ca> wrote:
+ I want to replace %28 to ( and %29 to )
+ However, when I execute the following command:
+
+ $buffer =~ tr/%28/(/;
+ $buffer =~ tr/%29/)/;
You mean 'substitute'? like:
$buffer = "He%28Mike%29 is a good teacher.";
$buffer=~s/%28/(/g;
$buffer=~s/%29/)/g;
print "$buffer\n";
He(Mike) is a good teacher.
??
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: 25 Feb 1998 23:06:11 GMT
From: dmmartin@home.net (Michael Martin)
Subject: Re: Replacement of characters
Message-Id: <6d2853$1h$1@ha2.rdc1.sfba.home.com>
In article <34F48893.C07C6FF5@nortel.ca>, xieyum@nortel.ca says...
>$buffer =~ tr/%28/(/;
>$buffer =~ tr/%29/)/;
>
>the result is "He(((Mike))) is a good teacher.
Ok, the prob here is that tr/// translates individual charictors, not strings.
So what you were saying with those tr/// statements is: translate %, 2, and 8
into ( and translate %, 2 and 9 into ). You want to use substitute (s///).
and the code would be:
$buffer =~ s/%28/(/ig; #the i and the g tell perl to be case insensitive, and
#to match multiple times in one string
$buffer =~ s/%29/)/ig;
__END__
HTH,
Philip Martin
------------------------------
Date: 25 Feb 1998 18:08:30 -0500
From: Jay Rogers <jay@rgrs.com>
To: "Andy Jacobs" <andyj@scn.org>
Subject: Re: Socket question for Win32
Message-Id: <82zpjfgu4x.fsf@shell2.shore.net>
"Andy Jacobs" <andyj@scn.org> writes:
> I'm trying to use perl to automate a telnet session I do frequently. I'm
> using perl 5.003_07 on NT Server.
>
> But when I connect it to the telnet host, I only get some garbage
> characters (when using read() rather than <S>). Any idea what's
> going wrong? Here's the script (with the default host and port):
>
> #Copied and modified from the sample: tcp-client
> ($them, $port) = @ARGV;
>
> $port = 'telnet' unless $port;
> $them = 'infonet.kcls.org' unless $them;
You have to follow the TELNET protocol if you're going to speak with a
TELNET port (see ftp://ftp.isi.edu/in-notes/rfc854.txt). The server
is probably waiting for you to respond to it's query for option
negotiation (i.e the garbage characters).
Net::Telnet will transparently handle this for you. Find it at your
neighborhood CPAN.
Unfortunately, the particular site to which you're connecting, only
sends output with embedded terminal escape sequences. It can be nasty
trying to weed through that type of output looking for data of
interest. Good luck :-)
use Net::Telnet ();
$t = new Net::Telnet (-timeout => 20,
-dump_log => "/tmp/dump.log");
$t->open("infonet.kcls.org");
print $t->waitfor('/login: $/');
$t->print("kcls");
print $t->waitfor(-string => "Enter terminal type or number: ");
$t->print("2");
print $t->waitfor(-string => "test the terminal emulation? (Y/[N]) ");
$t->print("N");
print $t->waitfor(-string => "Press <Enter> to see next screen : \e[0m ");
$t->print("Q");
print $t->waitfor(-string => "press the key labeled \"Return.\"");
$t->print("");
print $t->waitfor(-string => "press <Enter> : \e[0m ");
$t->print("14");
while (! $t->eof) {
print $t->get;
}
$t->close;
exit;
--
Jay Rogers
jay@rgrs.com
------------------------------
Date: 25 Feb 1998 23:15:05 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Splitting on 2 line feeds?
Message-Id: <6d28lp$1t1$5@comdyn.comdyn.com.au>
In article <6d1tkr$omn$1@nnrp1.dejanews.com>,
kperrier@neosoft.com writes:
> What I want the script to do (btw perl 5.004_4 on AIX 4.1.4) is read in the
> output of the lsuser command (it gives output in the format above) and in each
> element of the array have each users information, i.e. I want to split on the
> two /n characters that separate the records.
you mean \n?
have a look at the $/ variable (perldoc perlop). That might actually
be more what you'd like.
$/ = "";
or
$/ = "\n\n";
depending on what exactly you want to allow. See perlvar for more
details on the $/ variable.
> my (@DATA) = <SOURCE>;
If you want to do it this way, you'll have to make sure that the regex
can span multiple lines:
perldoc perlre
s Treat string as single line. That is, change "." to
match any character whatsoever, even a newline, which it
normally would not match.
> my (@CHUNKS) = split (/\n\n/, @DATA);
my (@CHUNKS) = split (/\n\n/s, @DATA);
Martien
--
Martien Verbruggen | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd. | I can ask him what he meant - Steven
NSW, Australia | Wright
------------------------------
Date: Wed, 25 Feb 1998 16:56:34 -0500
From: Andrew Starr <atstarr@negia.net>
Subject: Re: test post
Message-Id: <atstarr-2502981656340001@news.negia.net>
In article <34F44399.5A83C041@sedona.intel.com>, dervin
<dervin@sedona.intel.com> wrote:
> test
Best way to test is to use the groups misc.test, comp.test, alt.test, etc.
Use "ignore" as subject line and first line of message to insure you don't
get about 20-30 messages confirming your post, sent by automated response
agents around the world.
On the other hand, without such responses (or access to another news server
or checking for your post on DejaNews), there is no way for you to ensure
your post has made it past your local server. I.e. if you post to a
newsgroup, close your newsreader, then reopen it and you see your post,
that just means your local server has it. Doesn't necessarily mean your
local server sent it upstream as it should.
-Andrew
--
Andrew Starr http://www.amherst.edu/~atstarr
------------------------------
Date: 25 Feb 1998 22:18:34 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: The Ineffable Tom C.
Message-Id: <6d25bq$1n8$1@comdyn.comdyn.com.au>
In article <6d1440$jn$1@nnrp1.dejanews.com>,
shaker@netusa1.net writes:
> In article <6d03j8$pum$1@comdyn.comdyn.com.au>,
> mgjv@comdyn.com.au (Martien Verbruggen) wrote:
>
> < snip >
>
>> For anyone with enough sense to look at a URL like
>> http://www.perl.com/ or http://www.perl.org/. For anyone with enough
>> sense to see if there maybe was some doucmentation that came with that
>> neat little programming thingie. For anyone with enough sense to look
>> around on yahoo.
>>
>
> (1) There are folks who do not get access past the firewall, at their places
> of work. (Of course, they can get access to the Web at home. They can also
> look into solutions such as the new O'Reilly Resource Kit, if it will serve
> as a reasonable alternative to the info available via the URLs posted above.)
> They get clpm inside the firewall.
If you have to use perl for your work, but they won't even give you
access through the firewall through a proxy, or through a SOCKSified
ftp, then they're making your life unnecessarily hard. There simply is
NO reason to not provide proxied access to the Internet.
> (2) As for online documentation and other online stuff: one has to know
> either where these are located or what all are available in their 'normal
> path'; if I am missing something, please let me know. Let me 'splain'. I know
perldoc perl
or
man perl
or
look at the main entry point to the documentation however you or your
company has that installed. HTML, PDF, PostScript, print, GIFs, TIFFs,
roff output, TeX, DVI, no matter how. the perl page has references to
all the other pages.
> for instance. I also know that several other pieces of documentation (such as
> perlfunc, perlobj, etc.) exist. Recently, I started making a list of these as
> I see them mentioned in various places (different postings and books for
> instance), so that I can 'perldoc' them. I have never tried
The list is contained in the perl man page, or documentation page, or
however you want to call it.
> Maybe this will work. I want to look at the Perl source code. I don't know
> whether it is available online on our system or not - whether it has been
You can always download it and unpack it somewhere. Normally, you
don't need to look at the source code of perl. If you mean, the source
code of the modules, check your @INC array,
My point still is: All the documentaition is freely available, and
comes with perl. There are numerous pointers around telling you where
and how to get to the documentation. Sure, the first thing you need to
know is how to fidn that first pointer, but if someone cannot even try
www.perl.com or 'man perl' or 'open windows explorer, go to perl
directory, look around for documentation', then nobody can help them.
I refuse to take situations into account where 'your comapny' due to
paranoia refuses you access to the web, news groups, source codes, or
documentation. They might as well lock all the reference books in a
closet, and throw away the key.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use being
NSW, Australia | a damn fool about it.
------------------------------
Date: 25 Feb 1998 22:20:27 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: The Ineffable Tom C.
Message-Id: <6d25fb$1n8$2@comdyn.comdyn.com.au>
In article <34f47135.9387451@news.clara.net>,
wrdcom@clara.net (Sean Ahern) writes:
> On 25 Feb 1998 03:36:08 GMT, mgjv@comdyn.com.au (Martien Verbruggen)
> wrote:
>
>
>>whose? And the term 'elitism' in this context is just a term used by
>>people who are jealous of other people's accomplishments.
>
> Erm, exactly whose accomplishments am I supposed to be jealous
> of?
People who know when to use "its" and when to use "it's".
You're trolling. You're killfiled.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | A Freudian slip is when you say one
Commercial Dynamics Pty. Ltd. | thing but mean your mother.
NSW, Australia |
------------------------------
Date: 25 Feb 1998 22:38:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Verifying a form field
Message-Id: <6d26h8$1n8$5@comdyn.comdyn.com.au>
[original post not here yet, thus responding to this followup]
In article <Pine.HPP.3.95.980225093442.12884A-100000@u30045.rsv.svskt.se>,
Reine Persson <reiper@rsv.se> writes:
> On Tue, 24 Feb 1998, Cactus wrote:
>
>> Hello, I'm writing a Perl script to read in a number from the
>> query_string and verifly that it is only a number and no letters or
>> neg-nums. Any clues as to how I can verify this?
> One way:
>
> if ( $Amount =~ /^[0-9]+$/ ) {
> print "Just number's in string Amount\n";
> }
perldoc perlfaq4
/How do I determine whether a scalar is a number/whole/integer/float?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd. | enough features yet.
NSW, Australia |
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 1975
**************************************