[8819] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2436 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 27 23:04:06 1998

Date: Mon, 27 Apr 98 20:00:39 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 27 Apr 1998     Volume: 8 Number: 2436

Today's topics:
    Re: "magical autoincrement algorithm?" <rjk@coos.dartmouth.edu>
    Re: "Slurp"? <blan0416@uidaho.edu>
    Re: Anyone know how to cancel a Perl program? <zisa@onramp.net>
    Re: Anyone know how to cancel a Perl program? (Martien Verbruggen)
    Re: Binary Copy under Perl32 (Andrew M. Langmead)
    Re: books for learning perl <rjk@coos.dartmouth.edu>
    Re: cgi-lib.pl or CGI.pm? (I R A Aggie)
    Re: Credit Card Verification scripts? <zisa@onramp.net>
    Re: Credit Card Verification scripts? <zisa@onramp.net>
    Re: Dummie question: EASY !! file copy wanted (gettin'  <fecund@fatnet.net>
    Re: How do you make delay program? <sowmaster@juicepigs.com>
    Re: How do you make delay program? (Martien Verbruggen)
    Re: How to edit a file most efficiently? <rjk@coos.dartmouth.edu>
    Re: How to get times in different timezones? (Paul Eggert)
    Re: http Reg Exp <rjk@coos.dartmouth.edu>
    Re: http Reg Exp (Martien Verbruggen)
    Re: Need help with pattern matching... (Martien Verbruggen)
    Re: QRe: == vs. eq <rjk@coos.dartmouth.edu>
    Re: Question on sorting <rjk@coos.dartmouth.edu>
    Re: Radio buttons and check boxes <blan0416@uidaho.edu>
    Re: REQ: Win32 POP3 client (Sean Dowd)
    Re: RFI:  Counting repeated substrings within a string <rjk@coos.dartmouth.edu>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 27 Apr 1998 22:53:02 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: "magical autoincrement algorithm?"
Message-Id: <35454493.48BBBC76@coos.dartmouth.edu>

Grinch wrote:
> 
> Where can I find out more about the "magical autoincrement algorithm" used
> for the range operator?

In the documentation under the autoincrement operator, ++.

> More specifically, can anyone tell me how to obtain a mixed-case list? I
> expected ('AA'..'zz') to work, but it returns all 676 upper case
> combinations. ('aa'..'ZZ') returns all 676 lower case combinations. What I
> want is all 2704 mixed-case, two-letter combinations.

You cannot obtain a mixed case list with the .. operator.  Autoincrement on
strings 'preserves each character within its range', which apparently means
that numbers stay numbers, lower case letters stay lowercase, and uppercase
letters stay uppercase.

Note that autoincrement, and thus the .. operator, works its magic only on
strings which match /^[a-zA-Z]*[0-9]*$/ [1], so constructs such as ("\x00" ..
"\xFF") will not work.

> I can come up with workarounds using various looping constructs, and for my
> current project I'll probably wind up doing exactly that.

Most likely.

[1]: Actually /^[a-zA-Z]*[0-9]*$(?!\n)/.  A trailing newline is not allowed.  :-)

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: Mon, 27 Apr 1998 18:46:44 -0700
From: Derek Blandford <blan0416@uidaho.edu>
Subject: Re: "Slurp"?
Message-Id: <35453504.356946A5@uidaho.edu>

> root (jimmer@charm.net) wrote on MDCC September MCMXCIII in
> <URL: news:ogxnla05.fsf@jimmer.charm.net>:
> ++
> ++ I vaguely remember seeing a technique once where an entire input file
> ++ is read in with a single command, carriage returns and all.  My poor
> ++ memory also seems to think it was called "slurping" the file, but I
> ++ cannot find any reference to it in the camel book, the newsgroup, or
> ++ the FAQ.  Is there such a thing.  If so, how is it done (and what is
> ++ it really called)?
>
> {local $/; $file = <FILE>}
>
> You can deduce this from the manual, but the section that talks about
> the <> operator only mentions $/ (and then only briefly) when `` is
> being discussed. Maybe $/ should be mentioned in combination with <>
> as well, with a pointer to perlvar.
>

Hmmmmff.
@file = <FILE>;

Jason



------------------------------

Date: Mon, 27 Apr 1998 20:07:50 -0600
From: Zisa <zisa@onramp.net>
Subject: Re: Anyone know how to cancel a Perl program?
Message-Id: <354539F3.6207760@onramp.net>



Bob Trieger wrote:

> Zisa wrote:
>
> > Is there a command or escape code for interrupting a running script?
>
> ^C
>
> or in windowspeak "Hold down the Ctrl key and press the letter c"
>
> I don't know the MAC equivalent.



Thanks a whole lot. I played with it and found that the Mac equivalent is
control-option-c, in case any other Mac user needs this info.
Incidentally, you have to do it twice to escape an active sequence. None
of the regular escape commands seemed to work, but I never thought of
using "c". Thanks again!!!

Zisa



------------------------------

Date: 28 Apr 1998 02:12:02 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Anyone know how to cancel a Perl program?
Message-Id: <6i3dti$f2r$2@comdyn.comdyn.com.au>

In article <35452EA3.FD662BB0@onramp.net>,
	Zisa <zisa@onramp.net> writes:
> I am very new at Perl and when I make a program (like the password
> program in the Llama book)
> I have no way of stopping the program without  finishing it.
> 
> Is there a command or escape code for interrupting a running script?

You do that the same way as you would interrupt other programs. There
is no standard way. It depends on your shell, and the settings you
chose for that shell (yes, command.com and equivalents are just shells
as well). 

Often ctrl-c will work. Sometimes ctrl-break will. You'l have to try,
and check the documentation for your shell.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


------------------------------

Date: Tue, 28 Apr 1998 02:30:58 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Binary Copy under Perl32
Message-Id: <Es3qzM.HHz@world.std.com>

drummj@mail.mmc.org (Jeffrey Drumm) writes:
>On Mon, 27 Apr 1998 17:43:31 GMT, Tom Phoenix <rootbeer@teleport.com>
>wrote:

>>Perl doesn't, your system does. Use a module to copy files, or check out
>>binmode in perlfunc. Or both! :-)

>Uh huh, so . . . in what way does binmode() change the way my _system_
>functions?

>I could've sworn it changed the way _Perl_ functions . . . on my (everybody
>together now, with feeling . . . "sadly broken excuse for a") system.  :-)

It depends on what you call "the system." I tend to think of the C
library (where the setmode() function resides) as part of "the
program", not part of "the system" but the Free Software Foundation,
(and apparently Tom) seem to have a different view.

>In my sometimes-not-humble-enough opinion, how Perl handles file output
>seems the exception rather than the rule for the languages available on the
>'doze platforms . . . i.e. if you write a line feed character to a file
>from <insert language of choice here, with the unfortunate exception of
>Perl> you get a line feed character, and only a line feed character, in the
>resulting file. With Perl, you get a line feed and a carriage return . . .
>unless, of course, you use binmode() to disable Perl's built-in EOL
>translation.

This is the same manner in which every MS-DOS and Windows C compiler
that I've seen works, except that C programmers tend to set the
text/binary flag with the second argument to fopen().

But you might be better of thinking of "\n" as a "newline," not a
"linefeed." On systems where lines are terminated by linefeed
characters, they may be interchangable, but don't expect it to carry
to systems that terminate line differently. A newline is an abstract
construct, a linefeed is a specific bit sequence that may be used to
represent a newline.

>Note, though, that my comments are based only on empirical evidence, and no
>specific knowledge of what happens behind the curtain . . . it could very
>well be Microsoft converting all those LFs to CRLFs (but I doubt it).

Well they do, but they do it in their C library, not in their
operating system.
-- 
Andrew Langmead


------------------------------

Date: Mon, 27 Apr 1998 22:22:28 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: books for learning perl
Message-Id: <35453D69.CF5B9640@coos.dartmouth.edu>

Tom Christiansen wrote:
> 
> :Refer to your topic, my friend....  Learning Perl, from O'Reilly, by
> :Randall Schwartz, is the book to get.  You'll not find better.
> 
> Er, that's not his name -- it's Randal.
> And I'm co-author, you know. :-)
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Hopefully he won't let that stop him from buying the book.  ;-)

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: Mon, 27 Apr 1998 22:11:54 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: cgi-lib.pl or CGI.pm?
Message-Id: <fl_aggie-2704982211540001@aggie.coaps.fsu.edu>

In article <35450C16.77FDFAE5@shell.com>, Yong Huang <yong@shell.com> wrote:

+ Is there any compelling reason to use CGI.pm instead of the "old" and
+ "glorified" cgi-lib.pl?

cgi-lib is buggy? at least in my experience, it had a tendency to be
intermittently buggy. Once I switched to CGI.pm, the gremlins disappeared.
And as far as I know, no one is updating/bug-fixing cgi-lib.

And its trivially easy to switch to CGI.pm. Simply replace the require
statement with the use statement:

#require "cgi-lib.pl";
use CGI qw(:cgi-lib);

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: Mon, 27 Apr 1998 20:01:21 -0600
From: Zisa <zisa@onramp.net>
Subject: Re: Credit Card Verification scripts?
Message-Id: <3545386F.C9E77048@onramp.net>



Abigail wrote:

> Maybe the best advice is: if you're new, don't do things like
> dealing with credit card numbers.



The focus here is not credit card numbers but learning. I'm 12 and have plenty of time to get it right but it wont do me any good if you don't answer my questions. Don't worry, I have plenty of adult guidence to keep me out of trouble. I just need
the information.



------------------------------

Date: Mon, 27 Apr 1998 19:56:35 -0600
From: Zisa <zisa@onramp.net>
Subject: Re: Credit Card Verification scripts?
Message-Id: <35453751.1498B0F4@onramp.net>



Martien Verbruggen wrote:

> A very important pointer (write it down, and never forget it): If you
> want to know if someone has written something you might be able to
> use, you check CPAN.



Thankyou for your help! I went there and got a lot of other questions
answered.



------------------------------

Date: Mon, 27 Apr 1998 18:39:59 -0700
From: "yary h." <fecund@fatnet.net>
Subject: Re: Dummie question: EASY !! file copy wanted (gettin' hairy)
Message-Id: <3545336F.5778@fatnet.net>

Is File::Copy guarunteed to work properly on broken OS's like Windows
where binary and text files are different beasts, and will it keep the
readonly attribute?  (checks the docs, sees that "binmode is called
when appropriate"). Will it copy attributes under BeOS and the resource
fork under MacOS?  Does it preserve user, group, permissions under Unix?
(I suppose Copy.pm would have to be suid root, or make a system call. 
Can a module be suid while the script calling it isn't? That would be a
trick.)

Looking at the code, it copies contents admirably, but can't copy
meta-info, unless it's running under VMS or OS/2.  And there isn't any
way to fix it without some platform-specific C code, compiling in a
"syscopy" subroutine or providing a module for reading & setting file
meta-info.

It always bothered me that Perl comes with "rename", but not "copy".

We're converting our product's installer to Perl.  We set a $copy
variable at the top of the script to be that OS's copy program, and use
"system $copy,$source,$dest".  It was slightly trickier to get "cp -R"
and "xcopy" working together, but not much (xcopy needed some arguements
at the end, I think).  That method won't work for MacOS, but we're not
developing for that, for better or for worse.

-y


------------------------------

Date: Mon, 27 Apr 1998 22:16:28 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: seong@cse.bridgeport.edu
Subject: Re: How do you make delay program?
Message-Id: <35453BFB.4D27@juicepigs.com>

Seong Y. Kim wrote:
> 
> This would delay my program for a while
> 
> for ($a=0; $a<100000;$a++){;}
> 
> Does anyone know how to make delay without running loops?
> Is there any delay modules or subroutines like delay(10000) in C
> language?


When looking for a funtion in perl, it usually helps to search
perlfunc.html which was included with your perl distribution. In the
case of "delay" I turned up 2 functions in less than 10 seconds. Which
is a lot less time consuming than posting to c.l.p.m and waiting for a
sarcastic reply.

If you installed the standard port of perl for win32 without changing
any paths you can find perlfunc.html at
file://c:/perl/html/lib/pod/perlfunc.html . Once you load that page, do
cntl-f to search it.

HTH


-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


------------------------------

Date: 28 Apr 1998 02:16:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How do you make delay program?
Message-Id: <6i3e6i$f2r$3@comdyn.comdyn.com.au>

[How does this question relate to perl modules?, newsgroup removed]

In article <3545336F.5A50@cse.bridgeport.edu>,
	"Seong Y. Kim" <seong@cse.bridgeport.edu> writes:
> This would delay my program for a while
> 
> for ($a=0; $a<100000;$a++){;}
> 
> Does anyone know how to make delay without running loops?
> Is there any delay modules or subroutines like delay(10000) in C
> language?

Have you ever thought of reading some of the perl documentation, or
even getting a good book?

# perldoc perl
# perldoc perldata
# perldoc perlsyn
# perldoc perlfunc

Are all mandatory reading. They are the base of Perl. The last one of
these has your answer.

# perldoc -f sleep

Also, perlfaq8 has something more to say about the next question you
will probably ask:

# perldoc perlfaq8
/How can I sleep() or alarm() for under a second?

Please read. Know where the documentation is. Know how to use it. It
will make your life so much easier. Get a good book
(http://www.perl.com/)

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


------------------------------

Date: Mon, 27 Apr 1998 22:55:25 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: How to edit a file most efficiently?
Message-Id: <35454523.2EF4F9B9@coos.dartmouth.edu>

Yong Huang wrote:
> 
> But this opens two files and does a rename. I suspect this won't be very
> efficient. Is there a better way? Thanks for any advice.

Use the -i command line switch, or, equivalently, the $^I variable, to do
in-place editing.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: 27 Apr 1998 18:42:23 -0700
From: eggert@twinsun.com (Paul Eggert)
Subject: Re: How to get times in different timezones?
Message-Id: <6i3c5v$prl$1@tattoo.twinsun.com>

mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:

>Note that on most systems, localtime remembers the TZ value on its first
>call, and doesn't look at the environment variable again (an optimisation).

That used to be true long ago, but POSIX.1 requires that localtime not
cache TZ, and these days most implementations obey POSIX.1 in that respect.


------------------------------

Date: Mon, 27 Apr 1998 22:28:51 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: http Reg Exp
Message-Id: <35453EE8.48A5EF7D@coos.dartmouth.edu>

Martien Verbruggen wrote:
> 
> In article <1d83bnv.l44l1a12bskbtN@slip-32-100-246-191.ny.us.ibm.net>,
>         kpreid@ibm.net (Kevin Reid) writes:
> > 
> > $msg =~ s!(ftp|https?)://([^\s]*[^\s>,])!<a href="$1://$2">$1://$2<\/a>!gsi;
> >                                ^^^^^^^^
> >                                difference here
> 
> You;d also need to exclude characters like '.;:!?' And other
> punctuation characters to satisfy the original problem.

True.  Extend the character class as necessary.

> > As someone else pointed out, commas and >s are legal in a URL, but they are
> > not likely to occur at the end of the URL.
> 
> Maybe not, but what about this URL with a ','  and some '.'s in the middle

I think he was already aware of that possibility....

> http://www.somewhere.com/cgi-bin/bla?important_valu=aa..bb,,cc
> 
> Your regexp would change the URL value to
> 
> http://www.somewhere.com/cgi-bin/bla?important_valu=aa..bb
> 
> discarding the ',,cc'

Not the results I get.

  DB<1> $url = 'http://www.somewhere.com/cgi-bin/bla?important_valu=aa..bb,,cc '

  DB<2> $url =~ s!(ftp|https?)://([^\s]*[^\s>,])!<a href="$1://$2">$1://$2<\/a>!gsi;

  DB<3> x $url
0  '<a
href="http://www.somewhere.com/cgi-bin/bla?important_valu=aa..bb,,cc">http://www.somewhere.com/cgi-bin/bla?important_valu=aa..bb,,cc</a> '
  DB<4>

As you can see, the ',,cc' is included in the URL.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: 28 Apr 1998 02:28:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: http Reg Exp
Message-Id: <6i3et4$f2r$4@comdyn.comdyn.com.au>

In article <6i3cu0$jmp$4@client3.news.psi.net>,
	abigail@fnx.com (Abigail) writes:
> Martien Verbruggen (mgjv@comdyn.com.au) wrote on MDCC September MCMXCIII
> in <URL: news:6i3598$ec7$1@comdyn.comdyn.com.au>:
> ++ 
> ++ Really, you can't do it reliably.
> 
> Bullshit.

tsk. tsk.

> RFC translates easily into a regex.
> See <URL:http://cthulhu.mandrake.net/%7Eabigail/Perl/url2.pl>

Indeed, The RFC can be translated into a regex, but that still doesn't
make the original problem possible;  Extract URLs from some plain text
format, where the URLs do not stand out in a clear way. In particular,
they might be surrounded by punctuation characters which could be part
of the URL, or couldn't.

If you hadn't conveniently snipped the examples I put in my post, you
would have known what I meant. How do you extract the following URLs?

URL1: http://myserver.com/dir/file.
URL2: http://myserver.com/dir/file

(note the minimal difference?)

>From the following text:

I have two URLs in this, which will look the same, but are different,
because of punctuation, and they are: http://myserver.com/dir/file.
and http://myserver.com/dir/file.

That was the original question. All I said was that you cannot
RELIABLY extract these two URLs from this text.

I concur; this is a bit of a contrived example, but doubtless you will
understand what I mean.

Back to you.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


------------------------------

Date: 28 Apr 1998 02:09:58 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Need help with pattern matching...
Message-Id: <6i3dpm$f2r$1@comdyn.comdyn.com.au>

In article <Pine.GSO.3.96.980427205810.22093A-100000@gagarin.cs.buffalo.edu>,
	Bryan T Hoch <bth@cs.buffalo.edu> writes:
> I need to manipulate an input string a little bit, but I am unsure how to
> do so.
> I have a variable $string which contains a series of inputs from a file
> that was read in.
> The $string contains a bunch of lines (each line is terminated by a ; and
> a \n) and each line has its variables seperated by commas.
> Here is a sample of what $string contains:
> 
> cs113,intro into comp,1,NSM225,(none),cs513;
> cs114,oop,16,NSM225,(mac),cs514;
> 
> What I want to do is read each line seperately (one at a time) into a
> subroutine that will check to see what the 4th value is (in the case of
> the first line it would check to see if it matched "NSM225"). Then I want
> to do the next line and keep going until the end of the $string is
> reached.

Maybe You shouldn't read it in from the file this way, but with $/ set
to ";\n".

while (<IN>)
{
	chomp;
	my @in = split /,/;
}

Or, if you must have them in a variable, called $string:

#!/usr/local/bin/perl -w
use strict;

undef $/;
my $string = <DATA>;

foreach (split /;\n/, $string)
{
    my $return = check_sub ($_);
	# Do something depending on return here
}

sub check_sub
{
    my $line = shift;
    my @fields = split /,/, $line;

	# Check for the fourth field here (index 3)
	# return something sensible
    # print join( ':', @fields ), "\n";
}

__DATA__
cs113,intro into comp,1,NSM225,(none),cs513;
cs114,oop,16,NSM225,(mac),cs514;


Of course, there are other ways to do this (grep, map) but this is
probably easiest to parse for you.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


------------------------------

Date: Mon, 27 Apr 1998 22:08:32 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: QRe: == vs. eq
Message-Id: <35453A24.FC967A05@coos.dartmouth.edu>

Greg Bacon wrote:
> 
> Real users use Real Tools.  While it's perhaps ``unfair'' to make the
> generalization Tom did, it is a very good heuristic.  If you don't
> believe me, tally the number of clueless posts (FAQs, horridly wrong
> answers, etc.) generated with different newsreaders (as determined by
> the son-of-1036 denounced X-Newsreader: header).  Sit on EFnet's #perl
> channel and count the number of stupid questions from people who use
> mIRC.  Do this, and you will understand the prejudices that Tom (and
> most of the rest of the clpmisc regular answerers) holds.

We've already had this ridiculous discussion.  As I demonstrated last time, to
date no one has shown any statistics which demonstrate a correlation between
Newsreader and intelligence apparent in the post.

Yes, a lot of unintelligent posts are made from web browsers.  Perhaps that is
because so many posts are made from web browsers in general.  Until I see a
conclusive set of statistics, I refuse to accept this foolish stereotype.

Note my headers: my newsreader is Netscape Collabra.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: Mon, 27 Apr 1998 22:03:25 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Question on sorting
Message-Id: <354538F0.AA66BED7@coos.dartmouth.edu>

Brad Baxter wrote:
> 
> Now I am curious.  The two "Use of uninitialized ..." messages above
> make me wonder how perl is interpreting the first quoted string:
> 
> "$one::$two::$tre\n";

"${one::}${two::}$tre\n";

Perl interpolates in order, from left to right.  First, the dollar sign,
indicating a scalar variable.  Then the identifier, beginning with 'o', a word
character, which means the name includes all the following word characters. 
Then a double colon, the package delimiter, so that becomes part of the
identifier.  Then a dollar sign, which is not a valid identifier character, so
the identifier ends with the double colon.  The value of ${one::} is
interpolated, found to be undefined, and a warning is output.  Same for ${two::}.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: Mon, 27 Apr 1998 18:59:16 -0700
From: Derek Blandford <blan0416@uidaho.edu>
To: Built Environment Engineering Group <sales@beegroup.co.uk>
Subject: Re: Radio buttons and check boxes
Message-Id: <354537F4.B58B1A02@uidaho.edu>

> Can someone send me a couple of specimen lines in a perl script that
> will read a collection of radio buttons and check boxes and relay
> whether they are selected.
>
> --
> WordsPlus of Chobham (Surrey, UK)

 Not too sure if this question is for this group...but anyways:

&ReadParse(*input);                # Find a cgi-lib or use one of the Perl
modules
$radio_button = $input{radio_button_name};
$check_box = $input{check_box_name};

(assuming $radio_button and $check_box haven't been previously assigned to.)

if $radio_button or $check_box have values, they've been assigned to.

Perhaps you should visit one of the quadzillion Perl cgi tutorials out
there...

Jason



------------------------------

Date: Mon, 27 Apr 1998 20:40:05 -0500
From: ssd.nospam@ticnet.com (Sean Dowd)
Subject: Re: REQ: Win32 POP3 client
Message-Id: <ssd.nospam-2704982040060001@03dallasin21.ticnet.com>

In article <3544a18f.6735615@nntp.best.ix.netcom.com>,
jmrubin@ix.netcom.com (Joel Rubin) wrote:

> I'd like to see an example of a POP3 client, written in Perl, which
> takes mail from mail.mars.edu port 110, user john, pass abcde, and
> dumps anything which has "cyberpromo.*" anywhere in the header and
> puts all the other email in mail.txt.
> 
> It can work with either of the two free Perl 5 interpreters written
> for Win32.

Trivial.


#!/usr/bin/perl
use Mail::POP3Client;
$pop = new Mail::POP3Client( 'john', 'abcde', 'mail.mars.edu') ||
   die $pop->Message();
open( MAIL, '>>mail.txt' ) || die 'open mail.txt';

OUTER: for ( $i = 1; $i < $pop->Count(); $i++ )
{
   foreach( $pop->Head( $i ) ) {
      /cyberpromo\./ && do {
         $pop->delete( $i );
         last OUTER;
      };
   foreach( $pop->HeadAndBody( $i ) {
      print MAIL $_, "\n";
   }   
   print MAIL "\n";
}
$pop->Close();
close MAIL;


------------------------------

Date: Mon, 27 Apr 1998 22:20:29 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: RFI:  Counting repeated substrings within a string
Message-Id: <35453CF1.146A5334@coos.dartmouth.edu>

Abigail wrote:
> 
> Ronald J Kimball (rjk@coos.dartmouth.edu) wrote on MDCXCIX September
> MCMXCIII in <URL: news:3542CDC3.834331EE@coos.dartmouth.edu>:
> ++
> ++ for ($pos=0; $pos <= length($_) - 4; ++$pos) {
> ++   for ($len=4; $len <= length($_) - $pos; ++$len) {
> ++     $substr = substr($_, $pos, $len);
> ++     next if exists $freq{$substr};
> ++     $freq{$substr} = () = /\Q$substr/g;
> ++   }
> ++ }
> 
> That would require a pretty big machine for any non trivial text.
> 
> If the length of the text is a few kilobytes, the number of subpatterns
> will be counted in millions. Perl isn't the most suitable language for
> the above algorithm.

Well, I did ask the poster how many characters long he wanted the substrings
to be.  :-)

Also, I realized that the method that deja-news@school-net.com used to set the
hash values makes a lot more sense.  Guess I was trying to be too clever.

$minlen = 4;
$maxlen = 6;
for ($pos=0; $pos <= length($_) - $minlen; ++$pos) {
  for ($len=$minlen;
       ($len <= $maxlen) and ($pos+$len <= length $_);
       ++$len) {
    $substr = substr($_, $pos, $len);
    $freq{$substr}++;
  }
}

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

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 2436
**************************************

home help back first fref pref prev next nref lref last post