[11481] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5081 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 7 14:07:31 1999

Date: Sun, 7 Mar 99 11:00:17 -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           Sun, 7 Mar 1999     Volume: 8 Number: 5081

Today's topics:
    Re: 127/8 -> 127.0.0.0/8 (Tad McClellan)
    Re: append 3 huge log files (Mark P.)
        appending to beginning of file (Mark P.)
    Re: appending to beginning of file <tchrist@mox.perl.com>
    Re: appending to beginning of file (Mark P.)
    Re: appending to beginning of file <tchrist@mox.perl.com>
    Re: appending to beginning of file (Mark P.)
        Debunking Speed Myths <tchrist@mox.perl.com>
        FAQ 2.13: Perl on the Net: FTP and WWW Access   <perlfaq-suggestions@perl.com>
    Re: input from file or from buffer (Bart Lateur)
    Re: manipulate secure web site via script? <jamesht@idt.net>
        Need advice (Alex Iatskovski)
    Re: Newbie can't use fetchrow_hashref with DBI - HELP! (Jamie)
    Re: problem with CGI::append() on win95??? <rick.delaney@home.com>
    Re: searching filenames (Bart Lateur)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Sun, 7 Mar 1999 06:41:10 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: 127/8 -> 127.0.0.0/8
Message-Id: <mkotb7.cj.ln@magna.metronet.com>

Igor Vinokurov (igor@rtsnet.ru) wrote:

: Anyone can suggest module/function to expand ip address
: in form "127/8" to "127.0.0.0/8"?


   $ip_address =~ s/^(\d+)/$1.0.0.0/;


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 07 Mar 1999 18:13:36 GMT
From: mag@imchat.com (Mark P.)
Subject: Re: append 3 huge log files
Message-Id: <36e2c191.1205354227@news.ionet.net>

or to make a new file;

  opendir(COP, "$datadir") || die $!;
@filenames = grep (/\.txt$/i,readdir(COP));
closedir(COP);

	   open(DATA, ">>$datadir/faq.txt") || die $!;
	
 foreach $file (@filenames)
     {
      open(FILE, "<$datadir/$file") || die $!;
	print DATA <FILE>;
	print DATA "\n";
close(FILE);
}
	

close(DATA);


On Sun, 07 Mar 1999 06:38:50 GMT, vnguyen2891@my-dejanews.com wrote:

>Hello guys,
>
>I got 3 huge log files which I want to append them all into one file ( put 3
>files into 1 file). Do you have any suggestion to do it? Please give me
>detailed suggestion.
>
>Thanks in advance
>Van Nguyen
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    



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

Date: Sun, 07 Mar 1999 18:08:31 GMT
From: mag@imchat.com (Mark P.)
Subject: appending to beginning of file
Message-Id: <36e2bfcf.1204904440@news.ionet.net>

I'm trying to append to the beginning of a file. I have read and
trying to apply perl faq 5's guidance, however, I can't get it to
work. I can get it to print to the browser fine but when it prints to
the file, it appends to the end.

	   open(DATA, ">>$file") or die "can't open $file: $!";
    local($^I, @ARGV) = ('$file', glob("*.c"));
    while (<>) {
        if ($. == 1) {
            print DATA "whatever\n";
        }
         close ARGV;              # Reset $.
    }
close(DATA);

	Perl faq 5 isn't very clear on this and the code they post
doesn't append to a file at all. Any help?



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

Date: 7 Mar 1999 11:12:04 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: appending to beginning of file
Message-Id: <36e2c174@csnews>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    mag@imchat.com (Mark P.) writes:
:I'm trying to append to the beginning of a file. 

You can't do that.  The very words make sense.  Append means after.
You mean insert.  You can't insert.  You have only open, close, read,
write, and seek.  That's all you get.  Period. Those are your fundamental
file operations.  Everything else is composed of these simple operations.

Do this:

    $ cat newbits oldfile > newfile	&&
      mv  oldfile oldfile.original      &&
      mv  newfile oldfile

--tom
-- 
    "Since when did you hear people talk about writing LISP or BASIC *scripts*?
     JCL and shell make command *scripts*; perl and LISP make *programs*."  --me


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

Date: Sun, 07 Mar 1999 18:31:22 GMT
From: mag@imchat.com (Mark P.)
Subject: Re: appending to beginning of file
Message-Id: <36e2c520.1206265468@news.ionet.net>

Hmmm, that won't allow NT systems to use the program, how about if I
reverse the output when viewing?

	open(BRAVO, "$link_file");
	   if ($display == 1)    { @johnny = reverse(<BRAVO>); }
	close(BRAVO);
print "@johnny";

Will that work?

On 7 Mar 1999 11:12:04 -0700, Tom Christiansen <tchrist@mox.perl.com>
wrote:

> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, 
>    mag@imchat.com (Mark P.) writes:
>:I'm trying to append to the beginning of a file. 
>
>You can't do that.  The very words make sense.  Append means after.
>You mean insert.  You can't insert.  You have only open, close, read,
>write, and seek.  That's all you get.  Period. Those are your fundamental
>file operations.  Everything else is composed of these simple operations.
>
>Do this:
>
>    $ cat newbits oldfile > newfile	&&
>      mv  oldfile oldfile.original      &&
>      mv  newfile oldfile
>
>--tom
>-- 
>    "Since when did you hear people talk about writing LISP or BASIC *scripts*?
>     JCL and shell make command *scripts*; perl and LISP make *programs*."  --me



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

Date: 7 Mar 1999 11:37:59 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: appending to beginning of file
Message-Id: <36e2c787@csnews>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, mag@imchat.com (Mark P.) writes:
:Hmmm, that won't allow NT systems to use the program, 

That is *not* a tolerable excuse. :-)

Get your Perl Power Tools!  Get them today!  Stop being a Prisoner
of Bill!  Seize your own destiny!  Empower yourself!  Emancipate yourself!
Get your Perl Power Tools!

    http://language.perl.com/ppt/

--tom
-- 
	    Blood and flood are not like food,
	    Nor is mould like should and would.


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

Date: Sun, 07 Mar 1999 18:46:28 GMT
From: mag@imchat.com (Mark P.)
Subject: Re: appending to beginning of file
Message-Id: <36e2c8bd.1207190498@news.ionet.net>

>:Hmmm, that won't allow NT systems to use the program, 

>That is *not* a tolerable excuse. :-)

	I wish I didn't have to consider NT when programming but it is
a fact of life nowadays. <G>


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

Date: 7 Mar 1999 10:12:05 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Debunking Speed Myths
Message-Id: <7buchj$ov2$1@nntp.Stanford.EDU>

The new book from legendary authors Brian Kernighan and Rob Pike, _The
Practice_of_Programming_ (http://cm.bell-labs.com/cm/cs/tpop/index.html)
discusses Perl a bit.  One of the interesting points is some timings.
They wrote a Markov chain program in various langauges, and tested it
on various platforms.  Here are some results (pp 80-81).

    PLATFORM      250mhz Irix    400mhx pII M/S   line count
    C               0.36 sec        0.30 sec          150
    Java            4.9             9.2               105
    C++/STL/deque   2.6            11.2                70
    C++/STL/list    1.7             1.5                70
    Awk             2.2             2.1                20
    Perl            1.8             1.0                18

The code is in the book, including analyses of what's going on.

Although it is only one program in one particular domain -- and arguably
one in which Perl seems a natural -- it nonetheless would appear to
demostrate that in at least this case, there's a lot of mythology out
there to debunk.  Notice how poorly Java stands up.  The bad C++ numbers
they attribute to a broken Windows implementation of the STL.

Here are some Perl or near-Perl related quotes:

    p 80: Nevertheless, scripting languages are often a good choice
    for experimental programming, for making prototypes, and even for
    production use if run-time is not a major issue.

    p 83: If our goal had been just to write a personal version of the
    Marov chain algorithm for fun, we would almost surely have written
    it in Awk or Perl -- though not with as much polishing as the ones
    we showed here -- and let it go at that.

    p 163: Perl also comes with an extensive test suite that is meant
    to verify its correctness after compilation and installation on a
    new system, and includes modules such as MakeMaker and TestHarness
    that aid in the construction  of tests for Perl extensions.

--tom
-- 
Down that path lies madness.  On the other hand, the road to hell is
paved with melting snowballs. --Larry Wall in <1992Jul2.222039.26476@netlabs.com>


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

Date: 7 Mar 1999 11:12:27 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 2.13: Perl on the Net: FTP and WWW Access  
Message-Id: <36e2c18b@csnews>

(This excerpt from perlfaq2 - Obtaining and Learning about Perl 
    ($Revision: 1.30 $, $Date: 1998/12/29 19:43:32 $)
part of the standard set of documentation included with every 
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq2.html
if your negligent system adminstrator has been remiss in his duties.)

  Perl on the Net: FTP and WWW Access

    To get the best (and possibly cheapest) performance, pick a site
    from the list below and use it to grab the complete list of
    mirror sites. From there you can find the quickest site for you.
    Remember, the following list is *not* the complete list of CPAN
    mirrors.

      http://www.perl.com/CPAN-local
      http://www.perl.com/CPAN      (redirects to an ftp mirror)
      http://www.perl.org/CPAN
      ftp://ftp.funet.fi/pub/languages/perl/CPAN/
      http://www.cs.ruu.nl/pub/PERL/CPAN/
      ftp://ftp.cs.colorado.edu/pub/perl/CPAN/

-- 
Lispers are among the best grads of the Sweep-It-Under-Someone-Else's-Carpet
School of Simulated Simplicity.  [Was that sufficiently incendiary?  :-)]
        --Larry Wall in <1992Jan10.201804.11926@netlabs.com


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

Date: Sun, 07 Mar 1999 18:56:57 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: input from file or from buffer
Message-Id: <36e4ca3e.1448976@news.skynet.be>

[cc'ed]
In comp.lang.perl.misc, Daniel Grisinger wrote:

>Bingo, this is the sort of problem that tie() is perfect for.  I
>posted an article earlier this week that implemented a simple tied
>filehandle class, check Deja News for it (the subject was something
>like Tie::File::URL, it was changed from an earlier subject line).

It was still on my news server. Thanks, I'll study it.

This is a bit of a general problem with the Perl documentation: the
step-in level is a bit too high for newbies, even experienced newbies. A
working example is all I need to get things rolling. And I'm sure I'm
not alone who feels that way.

In a way, I do expect tied handles to be slower still, than my initial
idea (because of a function call per file access). But if I take a
normal handle for the plain file (up to over a megabyte), and a tied
handle for the arrays (a few k), there shouldn't be any speed problem at
all. I'm still curious about the benchmarks, though.

	Bart.


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

Date: Sun, 07 Mar 1999 11:20:19 -0500
From: jamesht <jamesht@idt.net>
To: HORNE@PSFC.MIT.EDU
Subject: Re: manipulate secure web site via script?
Message-Id: <36E2A743.1A057D96@idt.net>

Hello,

It sounds like you're logging in on your local machine, then trying to
access the account from another machine - the server running the script. The
problem with this is that if the trading site is at all interested in
security, they would be checking the ip address of the remote machine before
doing business with them. You'll have to make all of the requests from one
machine.

Once that's out of the way, just see how things go.

hth

James



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

Date: Sun, 07 Mar 1999 17:03:20 GMT
From: 74642.3600@NOSPAM.compuserve.com (Alex Iatskovski)
Subject: Need advice
Message-Id: <36e6b144.10289315@news.brainlink.com>

Well, I need an advice. I have perl CGI program that can be executed only
by authorized users. It is located in secure directory secured by HTTP
Basic Authentication (. htpaccess), Unix platform of course. But I'd like
to get information who exactly is executing this script in moment of
execution. Is there any solution that can allow me to get user information
(username and password or at least username only) into the variables when
authorized user is executed this script?  I do not want to use cookies
system or make authorization through the script itself. Else, the log file
is not a solution because I need user information exactly in a moment of
script execution for future processing. Any help will be greatly
appreciated. 

--Regards, Alex.



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

Date: Sun, 07 Mar 1999 17:54:47 GMT
From: Jamie@worldweb.demon.co.uk (Jamie)
Subject: Re: Newbie can't use fetchrow_hashref with DBI - HELP!
Message-Id: <36e2bd4f.252444@news.demon.co.uk>

On Sun, 07 Mar 1999 16:39:58 GMT, sgrantz@visi.com (Steve Grantz)
wrote:

>Jamie (Jamie@worldweb.demon.co.uk) wrote:
>: I hope someone can help me! I'm new to Perl, this being my first
>: attempt at writing
>
>: My problem is that when running this script, I get an error:
>: 
>: Can't locate object method "fetchrow_hashref" via package "DBI::db" at
>
>: 	if ($stHandle) {
>: 		$stHandle->execute; #($first, $last);
>: 
>: 		while($dbHandle->fetchrow_hashref){
>
>This is because the fetchrow methods belong to the Statement Handle
>class, not the Database Handle class.
>
>Hope this helps,
>Steve
>
>-- 
>More of Steve Grantz's Blather at               2 * McQ != McQ
>http://www.visi.com/~sgrantz         		0.5 * McQ == McQ


It helps in an almost embarassing way!!!

Thanks, Steve.

Jamie.


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

Date: Sun, 07 Mar 1999 17:39:19 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: problem with CGI::append() on win95???
Message-Id: <36E2BA8C.3ECE01C1@home.com>

Dan Baker wrote:
> 
> > > append(-name=>;'VarName',-values=>['word1','word2','word3']) ;
> 
> well, I've tried it lots of different ways... this is how it is
> documented.

Did you try removing the extraneous semi-colon?  Your documentation has
a typo.  You should learn some basic Perl syntax before jumping in and
using fancy modules.  And remember that Perl modules must still conform
to basic Perl syntax.

perldoc perlsyn

This will tell you that semi-colons *end* statements.

perldoc perlop

This will tell you that => is basically a synonym for comma.

perldoc perlsub

This will tell you that subroutines can take a list of arguments. 
CGI::append is a subroutine.

perdoc perdata

This will tell you all about lists, scalars, arrays and hashes.  It
shows how lists can be constructed of comma separated scalars. 
Comma-semi-colon is not a valid operator.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sun, 07 Mar 1999 18:38:05 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: searching filenames
Message-Id: <36e2c5bc.294892@news.skynet.be>

Sheila  Eugenio wrote:

>I am planning to create a script that will search a directory of filenames
>through a 4-field form. The filenames are named this way: 
>	FT19990405.txt where FT,QC,RM,RL=area
>			      	           1999=year
>			                           04=week
>			                           05=report#
>
>How can I make a comparison in such a way that when a user fails to fill up
>one or more fields, it will look for all possible combinations? I have the
>ff codes: 

[irrelevant parts snipped]:
>$search = "${area}${year}${week}";
>while (defined($file=readdir(ENGG))) {
>		$new = substr($file, 0, 8);
>		if ($search=~/$new/) {
 ...

You'd better reverse that. In other words: make the form data into a
pattern, and search for that through the filenames. It could even be
faster, since you can now use the //o option.

Let's see:

	my $area = $form{area} || '..';
	my $year = substr( "....$form{year)", -4);
	my $week = $form{week}?sprintf{'%02d',$form{week}):'..';
	my $report = $form{report}?sprintf{'%02d',$form{report}):'..';

	opendir (ENGG, "f:/engg/reports/")
		or die "Can't open directory";
	while (defined($file=readdir(ENGG))) {
		if ($file =~/^$area$year$week$report/o) {
			print <<EOT;
<a HREF="http://home/engg_rep/$file">$area$year$week$report</a><br>
EOT
		}
	}	

	Bart.


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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