[7814] in Perl-Users-Digest
Perl-Users Digest, Issue: 1439 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 9 02:07:36 1997
Date: Mon, 8 Dec 97 23:00:21 -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 Mon, 8 Dec 1997 Volume: 8 Number: 1439
Today's topics:
"sed-like" File operations <sean@fastinternet.net.au>
Anyone done any utmp/wtmp stuff with Perl? <apollock@bit.net.au>
Re: Basic beginner quesition <rootbeer@teleport.com>
Re: can perl do multi-threaded programming? <sriram@weblogic.com>
Re: Copying a file: How to (brian d foy)
Re: Copying a file: How to (Martien Verbruggen)
Re: Copying a file: How to (Martien Verbruggen)
DDE support in Perl? <stuart.hungerford@pobox.com>
Help with a regex (Scott Anguish)
Re: help! crypt for win32 (Danny Aldham)
Re: HOW do you send EMAIL to a POP3 mail server <ebohlman@netcom.com>
Re: HOW do you send EMAIL to a POP3 mail server <rra@stanford.edu>
Re: HOW do you send EMAIL to a POP3 mail server (Danny Aldham)
Re: HOW do you send EMAIL to a POP3 mail server <rootbeer@teleport.com>
Re: Need to open/close an Excel97 workbook <sriram@weblogic.com>
Re: opendir DIR, '/' (Andrew M. Langmead)
Re: opendir DIR, '/' (Martien Verbruggen)
Re: Parsing a fiel delimited with the "|" pipe characte <rootbeer@teleport.com>
Re: PerlShop "invalid transmission" <witsend@ix.netcom.com>
Re: Regular Expressions <usenet-tag@qz.little-neck.ny.us>
Re: Sorting huge array (Andrew M. Langmead)
Re: Telnet and Perl (Michael Fuhr)
Re: unix command in perl (brian d foy)
Re: unix command in perl (Martien Verbruggen)
Re: Why is this innocent undef () taking all day? <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 9 Dec 1997 15:54:13 +1200
From: "sean" <sean@fastinternet.net.au>
Subject: "sed-like" File operations
Message-Id: <66imhr$iau$1@loomi.telstra.net>
Hi.
I would like to be able to add a username to /etc/group. using perl
The problem that I am am having is that (this is my first perl script and I
have sed on the brain)
how do i insert a username at the EOL midway through a file ?
open() and close() are the only things I have come accros but seem to only
work for appending to the end of file.
eg
dialup:x:666:*,$username,$username2
Thanks,
Sean,
Perl Novice.
------------------------------
Date: Tue, 9 Dec 1997 15:14:08 +1000
From: "Andrew Pollock" <apollock@bit.net.au>
Subject: Anyone done any utmp/wtmp stuff with Perl?
Message-Id: <66ik7a$r6c$1@hermes.bit.net.au>
I'm about to wade through CPAN, but I thought I'd ask here first...
I need a Perl script to make utmp/wtmp entries (it's a login replacement).
I've run the h2ph script on all the relevant header files, but it still
doesn't work:
Number found where operator expected at (eval 37) line 1, near ") 0"
(Missing operator before 0?)
Number found where operator expected at (eval 85) line 1, near ") 0"
(Missing operator before 0?)
String found where operator expected at (eval 92) line 1, near "'unsigned
long'
'int'"
(Missing operator before 'int'?)
String found where operator expected at (eval 150) line 1, near
"&__PATH_ETC_INE
T"/hosts.equiv""
(Missing operator before "/hosts.equiv"?)
String found where operator expected at (eval 167) line 1, near
"&__PATH_ETC_INE
T"/syslog.conf""
(Missing operator before "/syslog.conf"?)
is what I get when running a bare script with just require "utmp.ph" in it.
Any suggestions would be appreciated.
Andrew
--
----
Andrew Pollock Programmer/System Administrator
apollock@bit.net.au http://staff.bit.net.au/apollock
Brisbane Internet Technology Pty Ltd.
------------------------------
Date: Mon, 8 Dec 1997 20:13:00 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: JJ <jones-joe@usa.net>
Subject: Re: Basic beginner quesition
Message-Id: <Pine.GSO.3.96.971208200805.23202A-100000@user2.teleport.com>
On Mon, 8 Dec 1997, JJ wrote:
> 1. What is the best way to learn perl in windows, but to use these
> scripts for cgi purposes?
What's best in which sense? If you want to understand it most completely,
try porting it yourself. :-) But for most people, you probably should get
a good book, take a good class, or both.
http://www.perltraining.com/
> 2. Do I have to load them on server every time to make them work?
Just as with any other software, once you've installed perl, it should
remain available for you for the indefinite future. Of course, you should
periodically install a newer version.
> 3. I've installed perl, on my computer but to make the scripts run I
> have to keep them in the same directory? (I've already done everything
> to my path statement but it dos'nt help)
The release notes which should have come with your copy of perl should be
helpful. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Mon, 08 Dec 1997 21:36:08 -0800
From: Sriram Srinivasan <sriram@weblogic.com>
Subject: Re: can perl do multi-threaded programming?
Message-Id: <348CD8C8.E5D7EF11@weblogic.com>
>
> The select call does not solve the problem of being able to save and
> restore your state, but threads do. If I use select, then every time
> I
> want to do some I/O, I must save my state, return back to the select
> loop, read the next character (or whatever), and restore myself when
> selected again!!! Select() is a pathetic "solution". (Unless of
> course
> we have a save-state/restore-state facility (coroutines), in which
> case
> select is a fine solution.
Having programmed the last six months or so in java, I find myself
missing select terribly. The JDK unfortunately doesn't have
select, so one is forced to either allocate a thread to listen on
every socket or poll every socket, both of which are fairly painful
solutions.
To get back to the other argument (fork vs. threads), I prefer
multiple threads over multiple processes, unless I absolutely want
a different protected address space. The only time I have needed this
in recent years is while doing transaction coordination, which
one doesn't want clobbered by bugs in one's code.
OTOH, I have not worked on machines like Tandem, where processes
map well to processors, inter-process messaging (using pathsend)
is exceedingly fast and where threads don't take advantage of the
hardwre.
________________________________________________________________________
Principal Engineer WebLogic, San Francisco www.weblogic.com
"Advanced Perl Programming" : http://www.ora.com/catalog/advperl/
------------------------------
Date: Tue, 09 Dec 1997 00:30:14 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Copying a file: How to
Message-Id: <comdog-ya02408000R0912970030140001@news.panix.com>
In article <01bd044e$a55ae680$d28cd4cf@derek>, "Sarah" <sarah@useeme.com> wrote:
>Doesn't the link command do this to? I just used it recently in a program
>and it seems to be working fine. Is this bad?
try editing the "copy" then look at the original. notice any
changes?
link() creates a hard link, as documented in the ln man page.
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 9 Dec 1997 05:53:46 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Copying a file: How to
Message-Id: <66imda$b2e$1@comdyn.comdyn.com.au>
In article <01bd044e$a55ae680$d28cd4cf@derek>,
"Sarah" <sarah@useeme.com> writes:
> Doesn't the link command do this to? I just used it recently in a program
> and it seems to be working fine. Is this bad?
link() creates a link, which is not a copy. A hard link basically is
another reference to the same file (bunch of bits on disk) in another
place. This means that if you alter the contents of one of the two,
the content of the other also changes.
If you use an OS that doesn't support links, like DOSish OS's, then
the implementation of the link() function probably depends on your
version of perl. It might be that some perl porters decided that
instead of a hard link, they would make a copy. I don't have too much
experience with the DOSish perls.
But, to answer the original question (copying brian d foy's answer):
Use File::Copy. That should be portable, comes with perl, it's
optimised, debugged etc.. etc.. Don't run obfuscated pieces of code
that claim to do the same thing, not even if they look very cool :)
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd. | clothes.
NSW, Australia |
------------------------------
Date: 9 Dec 1997 05:58:26 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Copying a file: How to
Message-Id: <66imm2$b2e$2@comdyn.comdyn.com.au>
In article <66h4u3$n6$4@info.uah.edu>,
gbacon@adtran.com (Greg Bacon) writes:
> #! /usr/bin/perl
> my $f='file';
> my $d='/path/to/destination';
> my @c;push@c,(aa..dd)[67];push @c,$f,$d;
> my$g=qq:my\$s='';foreach(my\$i=0;\$i<\@c;
> \$i++){\$s.="\$c[\$i] ";} \$s;:;my$p=eval
> $g;eval'system'.' "'.$p.'";';
>
> Note that this isn't portable to DOS systems because the code inside
> $gen_prog is taking references to variables, and DOS isn't yet capable
> of supporting this at the operating system level. I think there may
> be patches available at Microsoft's website. Ask your tech support
> representative.
Cute :)
but.. you forgot the -w flag! that would have told you to use
push @c,('aa'..'dd')[67]
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Tue, 9 Dec 1997 16:18:21 +1100
From: "Stuart Hungerford" <stuart.hungerford@pobox.com>
Subject: DDE support in Perl?
Message-Id: <66ikt3$ct1@hercules.its.csiro.au>
Hi,
I'm exploring Perl under Windows NT and was wondering
if anyone has implemented support for DDE in Perl?
(This is for an application that doesn't support OLE
automation).
--
Stu
-----------------------------------------------------------------------
Stuart.Hungerford@cmis.csiro.au Voice : +61 2 62167061
CSIRO Mathematical and Information Sciences Fax : +61 2 62167111
Canberra, AUSTRALIA GPO Box 664, Canberra, ACT 2601
------------------------------
Date: 9 Dec 1997 05:49:21 GMT
From: sanguish@digifix.com (Scott Anguish)
Subject: Help with a regex
Message-Id: <66im51$6qb$1@news.digifix.com>
I'm attempting to breakdown different file entries...
Filename.1.0.PIs.tgz
Filename.1.3.W.tgz
Filename.PI.tgz
Flex.files.2.0.tgz
The parts are
filename,version (optional), keyletters some combination of PIWMs
(optional) followed by a known file extension..
I seem to have no problem breaking out the common situation when they
are all present, but I'm having problems with the optional
situations...
($filename,$version,$archs)=$a=~/^(.*)\.(\d+\.*\d+)\.([PIWMs]*)\.tgz$/
;
How can I make the regex still work even in the cases where the
version number is missing, or the keyletters are missing?
Or am I going to have to go to a more complex check?
Thanks
Scott
--
Scott Anguish <sanguish@digifix.com>
NEXTSTEP/OpenStep Information <URL:http://www.stepwise.com>
------------------------------
Date: 8 Dec 1997 20:11:56 -0800
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: help! crypt for win32
Message-Id: <66igec$pdi$1@lennon.postino.com>
X-Newsreader: TIN [version 1.2 PL2]
Jerry LeVan (levan@eagle.eku.edu) wrote:
: I would be interested in a Perl version. (The algorithm in the
: Java version is fairly complicated...)
I would hope that the algorithm in Java, Perl, C or whatever
would be exactly the same.
--
Danny Aldham SCO Ace , MCSE , JAPH , DAD
I wak'd, she fled, and day brought back my night. jm
------------------------------
Date: Tue, 9 Dec 1997 04:07:09 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: HOW do you send EMAIL to a POP3 mail server
Message-Id: <ebohlmanEKwM3y.9FI@netcom.com>
Guy Doucet <gdoucet@ait.acl.ca> wrote:
: I found a sendsmtp.pl script by jmerrill that sends e-mails to an SMTP
: server using RFC821. Does anyone know how to send it to a POP3 server,
: or does anyone know what RFC is used for POP3.
POP3 servers are read-only interfaces to mailboxes. You don't send mail
to them; you send it to the SMTP server on the appropriate system, which
takes care of putting it in the right mailbox where it can later be
picked up, possibly through a POP3 server on the same network.
------------------------------
Date: 08 Dec 1997 21:14:09 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: HOW do you send EMAIL to a POP3 mail server
Message-Id: <m367ozqese.fsf@windlord.Stanford.EDU>
Eric Bohlman <ebohlman@netcom.com> writes:
> Guy Doucet <gdoucet@ait.acl.ca> wrote:
>> I found a sendsmtp.pl script by jmerrill that sends e-mails to an SMTP
>> server using RFC821. Does anyone know how to send it to a POP3 server,
>> or does anyone know what RFC is used for POP3.
> POP3 servers are read-only interfaces to mailboxes. You don't send mail
> to them; you send it to the SMTP server on the appropriate system, which
> takes care of putting it in the right mailbox where it can later be
> picked up, possibly through a POP3 server on the same network.
Some POP servers have an XTND XMIT command that can be used to send mail.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 8 Dec 1997 20:14:50 -0800
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: HOW do you send EMAIL to a POP3 mail server
Message-Id: <66igjq$phn$1@lennon.postino.com>
X-Newsreader: TIN [version 1.2 PL2]
Guy Doucet (gdoucet@ait.acl.ca) wrote:
: I found a sendsmtp.pl script by jmerrill that sends e-mails to an SMTP
: server using RFC821. Does anyone know how to send it to a POP3 server,
: or does anyone know what RFC is used for POP3.
: I NEED HELP !!!
POP is used only to pull mail off of a server, to read mail.
SMTP is used to send mail.
--
Danny Aldham SCO Ace , MCSE , JAPH , DAD
I wak'd, she fled, and day brought back my night. jm
------------------------------
Date: Mon, 8 Dec 1997 22:12:00 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Guy Doucet <gdoucet@ait.acl.ca>
Subject: Re: HOW do you send EMAIL to a POP3 mail server
Message-Id: <Pine.GSO.3.96.971208220936.12198C-100000@user2.teleport.com>
On Tue, 9 Dec 1997, Guy Doucet wrote:
> Does anyone know how to send it to a POP3 server,
> or does anyone know what RFC is used for POP3.
Sure. Lots of people know. And most of the people who like to answer
questions about mail servers and protocols hang around in newsgroups with
the word 'mail' in their name. :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Mon, 08 Dec 1997 21:48:00 -0800
From: Sriram Srinivasan <sriram@weblogic.com>
To: cacace@ibm.net
Subject: Re: Need to open/close an Excel97 workbook
Message-Id: <348CDB90.6D994D80@weblogic.com>
On 2 Dec 97 01:35:31 GMT, "AL" <cacace@ibm.net> wrote:
<<I need to open Excel97 using a filename that I specify, put some data
in some cells (this part I can do), and then save and quit without
predjudice. In other words I don't want Excel to ask me whether I
want to replace the existing file or not. Also, I can't seem to get
the OLE module to accept filenames like "file1.xls." It seems the
'dot' is causing it some grief.
>>
I don't know a good solution, but this is what I do. I unlink
the file before I invoke SaveAs. Works for me. Try this:
#
# Package Excel simply provides a wrapper around the excel automaton
# and ensures that Excel is told to quit at close of program.
#
package Excel;
use Win32::OLE;
use Cwd;
sub new {
my $s = {};
if ($s->{Ex} = Win32::OLE->new('Excel.Application')) {
return bless $s, shift;
}
return undef;
}
sub DESTROY {
my $s = shift;
if (exists $s->{Ex}) {
$s->{Ex}->Quit; # All this muck just to ensure this ...
return undef;
}
}
sub AUTOLOAD {
my $s = shift;
$AUTOLOAD =~ s/^.*:://;
$s->{Ex}->$AUTOLOAD(@_);
}
# Create a new OLE automaton
$ex = Excel->new() || die "Could not launch Excel as an OLE
application\n";
# Create a new workbook
$ex->Workbooks->Add || die "Could not create a new workbook\n";
# A new worksheet within the workbook
$exs = $ex->Workbooks(1)->Worksheets('Sheet1');
my $outputFile = 'foo.xls';
# Modify the file
$exs->Cells(1,1)->{Value} = 'Test';
unlink $outputFile;
# Save in cwd(). Otherwise the bally thing saves in the Personal
directory.
$ex->Workbooks(1)->SaveAs(cwd() . "\\" . $outputFile);
- Sriram
________________________________________________________________________
Principal Engineer WebLogic, San Francisco www.weblogic.com
"Advanced Perl Programming" : http://www.ora.com/catalog/advperl/
------------------------------
Date: Tue, 9 Dec 1997 04:49:12 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: opendir DIR, '/'
Message-Id: <EKwo20.Cts@world.std.com>
Worik Macky Stanton <w.stanton@auckland.ac.nz> writes:
>opendir DIR, '/'
>does not work on win95
>It does on linux.
When using the Activeware port of perl, I've noticed that using 'c:/',
or '/' wouldn't work with opendir(), but 'c:/.' did.
--
Andrew Langmead
------------------------------
Date: 9 Dec 1997 06:00:59 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: opendir DIR, '/'
Message-Id: <66imqr$b2e$3@comdyn.comdyn.com.au>
In article <EKwo20.Cts@world.std.com>,
aml@world.std.com (Andrew M. Langmead) writes:
> When using the Activeware port of perl, I've noticed that using 'c:/',
> or '/' wouldn't work with opendir(), but 'c:/.' did.
Just as a matter of interest: Does '/.' work as well? Maybe someone
with a DOS/win32 version of perl could test a few of these, and supply
this as a FAQ to the win32 FAQ maintainers?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd. | clothes.
NSW, Australia |
------------------------------
Date: Mon, 8 Dec 1997 20:21:42 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Evan Smithgall <esmithga@lucent.com>
Subject: Re: Parsing a fiel delimited with the "|" pipe character
Message-Id: <Pine.GSO.3.96.971208201453.23202B-100000@user2.teleport.com>
On Mon, 8 Dec 1997, Evan Smithgall wrote:
> open (INPUT, $inputfile);
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
> # get the number of fields in the file
> @fields = split (/\|/, $line1);
> $numfields = $#fields;
$numfields will now be set to one less than the number of fields found in
the first line of the file. If that's what you want, you should change the
misleading comment.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Mon, 08 Dec 1997 20:43:24 -0800
From: Dave Godwin <witsend@ix.netcom.com>
Subject: Re: PerlShop "invalid transmission"
Message-Id: <348CCC6C.FA0@ix.netcom.com>
Dave,
Now that you've provided a valid URL (the last two you sent me
did not work, and don't match this one), I can't enter your store.
Instead of getting the message you give in this email, I just get an
"Invalid Transmission Error #!" fault message, which indicates that
your internal script path variable are not set correctly.
Please contact me again by direct email. Give me all of the
information needed to Telnet into your server. I can most likely find
and repair the problem once I am in, just as I have done for a number
of other Perlshop based sites.
In all cases, the problems have been with the initial
configuration. After that, this is a simple script to use.
Dave Godwin
Owner and Tech Guy
Snapdragon Gifts
Dave Reed wrote:
>
> In article <348589c1.209504801@woody.wcnet.org>, jzawodn@wcnet.org (Jeremy
> D. Zawodny) wrote:
>
> > I'm not sure how many people on this group have *any* idea what
> > PerlShop.cgi is. I've done a fair amount of CGI hacking in Perl, and
> > I've never run across it.
>
> It's a shopping cart system offered as "adverware" -- free if you carry
> their logo and link. Several stores are operating on the web.
>
> > So, I'm forced to make some assumptions.
> >
> > (1) You've read the docs and they didn't help.
>
> Yes. The docs are very limited and did not help.
>
> > (2) You contacted the script's author/maintainer and that didn't help.
>
> Yes. No response. (None promised, since it's free.)
>
> > (3) You've read the CGI FAQs and they didn't help.
>
> Yes.
>
> > (4) You've searched the web and usenet for references to
> > "PerlShop.cgi" to see if anyone else has published material related to
> > it, and that hasn't helped.
>
> Yes.
>
> > (5) You have nowhere else to turn.
>
> Yes.
>
> > I spent the 30 seconds worth of effort needed to search AltaVista and
> > found: http://elaine.teleport.com/support/webweave/cgi/perlshop.html
> >
> > The documentation appears to be semi-complete, and there is
> > information about contacting the author. Have you?
>
> That site merely repeats the author's brief Manual. Yes. No response.
>
> > You don't seem to have posted enough code to make the problem easily
> > solvable. I have no idea what it in most of those variables or what is
> > supposed to be.
> >
> > Have you tried sticking in some debugging code to see what is
> > happening?
> >
> Here's more detail:
>
> I've set up PerlShop at
>
> http://www.webshowplace.com/cgi-bin/vr?antiq/perlshop.cgi
>
> with entry page at
>
> http://www.webshowplace.com/AntiqBooks/home.htm
>
> but I keep getting the error message
>
> "Cannot open tokens/572592245 for writing"
>
> with a different random number each time.
>
> Apparently the error message is being invoked by this:
>
> if ($token_exists == 0) {
> srand(time() ^ ($$ + ($$ << 15)));
> $rand_len = '9' x ($id_length - 3);
>
> do {
> $unique_id = &zero_fill(abs($$),3) .
> &zero_fill(int(rand($rand_len)),$id_length - 3);
> $token_file_name = "$token_directory/$unique_id";
> }
> until (! (-e $token_file_name)); ### Now check if really unique
> (i.e. does it already exist?)
>
> ### Create a random token to use with SHA signature
> $token = int(rand(1000000));
>
> open(token_file, ">$token_file_name") || &err_trap("Cannot open
> $token_file_name for writing\n");
>
> But I can't discover what I'm doing wrong.
>
> (I've set permissions 777 on the /tokens directory.)
>
> Any help would be appreciated. Thanks!
>
> (I'm totally new to Perl and CGI and apologize if I have introduced this
> question inappropriately or in an inappropriate forum.)
>
> -Dave davereed@abaweb.com
------------------------------
Date: 9 Dec 1997 00:31:17 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Regular Expressions
Message-Id: <eli$9712081901@qz.little-neck.ny.us>
Mark Morgan <mak@magic.dircon.co.uk> wrote:
> David Siebert wrote:
> > I have the Camal but but this section is notvery clear. I need to convert \n
> > and \c\n to <BR> any suggestions?
> Not sure why you're trying to do this, but the following should work:
> $var=~s/\c?\n/<BR>/g;
I don't think that does anything like what you thought it would.
:r! perl -we '$_="\c\n"; @a=unpack "C*",$_; $"=", ";print "@a\n";'
28, 110
Which corresponds to <ctrl-\><n>.
:r! perl -we '$_="\c?\n"; @a=unpack "C*",$_; $"=", ";print "@a\n";'
127, 10
Which corresponds to <del><ctrl-j>.
David's specs are a bit vague. Apparently he meant \r\n....
Elijah
------
\c for <cr> is not a bad guess
------------------------------
Date: Tue, 9 Dec 1997 05:22:49 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Sorting huge array
Message-Id: <EKwpM2.4zz@world.std.com>
Pontus.Berglund@se.adsanker.com (Pontus Berglund) writes:
>The problem is that the logs I'm analyzing are about 36 MB in total,
>so the hash gets freakin' huge. Is there a better way to do this?
If the problem is the size of the array, I'm not sure that there is
much you can do. If you want the number of hits and bytes read from
all the files, then you need to keep a list of all the files in
memory.
If the problem is the time it takes for the program to run, there are
a couple of things that I can think of to do.
The first is to store the results of previous runs (and the length of
the file when you stopped reading) in a separate file. Then when you
run the program again on the same logfile, you only have to read the
data that has been collected since the last run.
Also, since you only want the top ten files, you might be better of
going through the list and comparing each element with a separate list
of "top ten candidates". When the current element is larger any of the
elements in your new list, knock off the smallest item and insert the
new item. Then the sorting doesn't have to decide if file 11 is
greater or less then file 12.
--
Andrew Langmead
------------------------------
Date: 8 Dec 1997 21:03:55 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Telnet and Perl
Message-Id: <66ifvb$bhl@flatland.dimensional.com>
"Eric Phillips" <e.phillips@mindspring.com> writes:
> Is it possible to use the Telnet prog on my Linux server so that I can read
> the query of a "whois" search? If so, please let me know how. Thanks!
You might want to look at the Net::Whois module, available at
the Comprehensive Perl Archive Network (CPAN):
http://www.perl.com/CPAN/modules/by-module/Net/
Hope this helps.
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Tue, 09 Dec 1997 00:22:45 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: unix command in perl
Message-Id: <comdog-ya02408000R0912970022450001@news.panix.com>
In article <348CBC86.1CF8CD6@nycport.com>, hedon <hedon@nycport.com> wrote:
> I have one terse ,nevertheless,
> important question .
> How can a unix command be
> executed in perl script ???
see the perlipc man pages as a starting point.
> I knew one way , however ,this
> ,from no appearent reason, doesn't
> work for me .
if you had included a snippet of your code, we might have been able to
point out why it wasn't working.
> Any response will be appreciated
*Any*? ;)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 9 Dec 1997 06:04:34 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: unix command in perl
Message-Id: <66in1i$b2e$4@comdyn.comdyn.com.au>
In article <348CBC86.1CF8CD6@nycport.com>,
hedon <hedon@nycport.com> writes:
> I have one terse ,nevertheless,
> important question .
> How can a unix command be
> executed in perl script ???
There are many possible answers to this, depending on what it is you
really want. Supposing that you just want to execute some program from
perl, have a look at the system() function:
perldoc -f system
should do it. There are some references there to other ways of doing
almost the same thing.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd. | clothes.
NSW, Australia |
------------------------------
Date: Mon, 8 Dec 1997 22:08:52 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Terrence Brannon <brannon@surf.usc.edu>
Subject: Re: Why is this innocent undef () taking all day?
Message-Id: <Pine.GSO.3.96.971208214939.12198B-100000@user2.teleport.com>
On 8 Dec 1997, Terrence Brannon wrote:
> Subject: Why is this innocent undef () taking all day?
>
>
> sub undef_gmax {
>
> my ($P,$S,$g,@tmp);
>
> $g=$Persync::traversing_gmax;
>
> print "gmax: $g", $/;
> for $P (sort bynumber keys %{ $Persync::vmary{$g}}) {
> print "P: $P", $/;
> for $S ( sort bynumber keys %{ $Persync::vmary{$g}{$P} } ) {
> print "S: $S", $/;
> undef @{$Persync::vmary{$g}{$P}{$S}}; ### <---- SLOW LINE
> }
> }
> }
Are you certain that it's the undef that is slow? If you're judging from
the pacing of the output from the print statements, you may need to use $|
to turn off buffered output.
Nevertheless, that undef may indeed take some time. It is freeing not only
all of the elements of that list, but it may be freeing other memory, too,
if there were references among the elements. But hey, if you're merely
releasing memory, why are you doing a potentially time-consuming sort -
twice?
> Perhaps I should have done
> @{$Persync::vmary{$g}{$P}{$S}} = (); ### FASTER?
Possibly, but maybe not in the way that you think. That should be faster
when it comes time to add elements back in to the hash, though, so I'd
recommend it.
You could replace that big loop with this one. I think it would be faster.
(And it might actually accomplish the same thing. :-)
for $ref (values %{ $Persync::vmary{$g} }) {
# Each $ref is a $Persync::vmary{$g}{$P}
for $key (keys %$ref) {
@{$ref->{$key}} = ();
}
}
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
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 1439
**************************************