[22196] in Perl-Users-Digest
Perl-Users Digest, Issue: 4417 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 17 00:05:40 2003
Date: Thu, 16 Jan 2003 21:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 16 Jan 2003 Volume: 10 Number: 4417
Today's topics:
comments make code run faster? <mdudley@execonn.com>
Re: comments make code run faster? <mdudley@execonn.com>
Re: comments make code run faster? <abigail@abigail.nl>
Re: Equivalent of /g for unpack? <goldbb2@earthlink.net>
Re: find2perl on windows doesn't work correctly <raffles2@att.net>
Re: HTML::Table conflict? noone@annon.com
Re: most popular unix scripting language (Cameron Laird)
Re: most popular unix scripting language (Tony L. Svanstrom)
Re: most popular unix scripting language <nobody@jonz.net>
Re: most popular unix scripting language <goldbb2@earthlink.net>
Re: most popular unix scripting language (Walter Roberson)
newbie: How do use -e command line option ? --confused <namde@sympatico.ca>
Re: newbie: How do use -e command line option ? --confu (Tony L. Svanstrom)
Re: newbie: How do use -e command line option ? --confu <wksmith@optonline.net>
Re: Outputting a binary file to the browser (Ben Morrow)
Re: perl cgi redirect to variables instead of displayin (Entfred)
Re: perl cgi redirect to variables instead of displayin (Tad McClellan)
Re: perl hashes seems to slow down <goldbb2@earthlink.net>
Re: Perl Module for "compressing" text (f u cn rd ths.. (Jay Tilton)
Re: Perl Module for "compressing" text (f u cn rd ths.. <GPatnude@adelphia.net>
Processing Files (Surajsub)
Re: Processing Files <bwalton@rochester.rr.com>
Re: Processing Files (Tad McClellan)
Re: Question about high performance spidering in perl <comdog@panix.com>
Re: Recreating a MIME::Lite object (Ben Morrow)
Re: Recreating a MIME::Lite object <goldbb2@earthlink.net>
simple Q, external variables <darkage@freeshellzzzz.org>
Re: simple Q, external variables <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 16 Jan 2003 18:29:21 -0500
From: Marshall Dudley <mdudley@execonn.com>
Subject: comments make code run faster?
Message-Id: <3E274051.59A7B47E@execonn.com>
I have some code I have been trying to speed up. On thing I did was
write a script that reads in the original source code and strips out all
the spaces and tabs at the beginning of each line for formatting, and
eliminates all comment lines with a # at the beginning of the line after
the spaces and tabs have been removed.
This works fine, the original source is 107K and after removing the
whitespace and comments the file is 44K.
The compilation time is a couple of tenths of a second faster with the
code stripped of these items, and the code produces identical results.
The only thing odd is that the run time of the stripped code take twice
as long as that of the original bloated code. The bloated code runs in
4 seconds, and the stripped code takes about 9 seconds.
Anyone have any idea why the run time would be different for the same
code except for the comments and leading whitespace being removed?
Thanks,
Marshall
------------------------------
Date: Thu, 16 Jan 2003 19:21:06 -0500
From: Marshall Dudley <mdudley@execonn.com>
Subject: Re: comments make code run faster?
Message-Id: <3E274C72.8C4D98DC@execonn.com>
Forget the previous message. I missed on other thing that the compression
script was doing, adding a -T to the first line. I did that since I wanted
to have taint checking on, and of course cannot test compile a script if the
-T is there, so I was leaving it out of the original, and letting the
compression script put it in.
So, I guess the right question is why does the taint checking load the cpu
so much. Doubling the compile/run time seems a bit excessive for just
checking system opeartions to see if they violate the taint rules.
Thanks,
Marshall
Marshall Dudley wrote:
> I have some code I have been trying to speed up. On thing I did was
> write a script that reads in the original source code and strips out all
> the spaces and tabs at the beginning of each line for formatting, and
> eliminates all comment lines with a # at the beginning of the line after
> the spaces and tabs have been removed.
>
> This works fine, the original source is 107K and after removing the
> whitespace and comments the file is 44K.
>
> The compilation time is a couple of tenths of a second faster with the
> code stripped of these items, and the code produces identical results.
> The only thing odd is that the run time of the stripped code take twice
> as long as that of the original bloated code. The bloated code runs in
> 4 seconds, and the stripped code takes about 9 seconds.
>
> Anyone have any idea why the run time would be different for the same
> code except for the comments and leading whitespace being removed?
>
> Thanks,
>
> Marshall
------------------------------
Date: 17 Jan 2003 01:04:48 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: comments make code run faster?
Message-Id: <slrnb2elqq.l2m.abigail@alexandra.abigail.nl>
Marshall Dudley (mdudley@execonn.com) wrote on MMMCDXXVI September
MCMXCIII in <URL:news:3E274C72.8C4D98DC@execonn.com>:
%% Forget the previous message. I missed on other thing that the compression
%% script was doing, adding a -T to the first line. I did that since I wanted
%% to have taint checking on, and of course cannot test compile a script if the
%% -T is there, so I was leaving it out of the original, and letting the
%% compression script put it in.
You can test compile a script using -T:
perl -Twc program.pl
%% So, I guess the right question is why does the taint checking load the cpu
%% so much. Doubling the compile/run time seems a bit excessive for just
%% checking system opeartions to see if they violate the taint rules.
But in order for system operations to be able to check "taint rules",
some bookkeeping must be performed. Under -T, all data is being tagged,
and whenever data flows from one variable to another, it has to be tagged
as well.
However, I find it hard to believe compile and run time are doubled.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
Date: Thu, 16 Jan 2003 22:29:54 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Equivalent of /g for unpack?
Message-Id: <3E2778B2.CBAB130@earthlink.net>
jtd wrote:
>
> Is there a way of emulating the /g regexp modifier for unpack? I have
> a binary file where bit encodings depend on the result of the previous
> bits. A slightly messy hack is to take small substrings of the binary
> file (which fits in memory) and use unpack on that substring, but if
> there's an idiomatic way of doing this, I'd love to know.
Reading from a file, then performing substr() on the data sounds rather
innefficient.
You probably want something like this:
local $/ = \length pack $fmt;
while( <> ) {
my @struct = unpack $fmt, $_;
$fmt = ... format for next data structure to unpack ...;
$/ = \length pack $fmt;
}
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Fri, 17 Jan 2003 00:14:54 GMT
From: "Ron Ruble" <raffles2@att.net>
Subject: Re: find2perl on windows doesn't work correctly
Message-Id: <2WHV9.114295$hK4.9288895@bgtnsc05-news.ops.worldnet.att.net>
"Helgi Briem" <helgi@decode.is> wrote in message news:3e268a22.1063775688@news.cis.dfn.de...
> On Thu, 16 Jan 2003 00:15:53 -0500, "Yang Xiao"
> <yxiao@panix.com> wrote:
>
> >Hi all,
> >I'm trying to use find2perl to do the following
> >find2perl c:\ -size +10000 -exec dir {} \; >find.pl
>
> Don't use backslashes, even under Windows,
> there is no need.
The DIR command uses busted command line parsing.
Forward slashes screw it up. If you make sure to
enclose the path in double quotes though, DIR
can handle it.
Under most other commands, backslashes are
fine, as you say, even without the double quotes.
------------------------------
Date: 16 Jan 2003 19:46:40 -0700
From: noone@annon.com
Subject: Re: HTML::Table conflict?
Message-Id: <3e276e90@news.nucleus.com>
Anthony Peacock wrote:
[snip]
> Jurgen's advise is spot on. The first thing to look at is the server
> log file for error messages. Next, when you say 'it doesn't render' do
> you mean you get a blank browser window or do you get an error message?
> If the window is blank, look at the page source, this will often give
> you a clue as to which bit of the HTML document the browser barfed at.
The server logs show nothing out of the ordinary.
The webpage comes up blank, if I "view source" it's essentially HTML headers
with nothing in the body.
> If you manage to narrow this down, please post back your findings, in
> case there is a dependency in HTML::Table that I can fix.
The problem appears to be with the CGI server (Sambar V4.1). The work around
is to put HTML/Table.pm in the directory with the Perl script.
Why it doesn't work without this is a mystery:
perl -e "print join \"\n\", @INC" gives
C:/Program Files/Perl/lib
C:/Program Files/Perl/site/lib
.
and HTML/Table.pm *is indeed* in site/lib. So how and why the script picks up
Table.pm from site/lib when run from the command line, but NOT when executed
by the CGI server is a mystery -- espcially given that the server picks up
the other modules (DBI and CGI) without a problem.
I realize this posting is off topic, but I am responding to Anthony's
request about posting my findings. At this point I don't believe the problem
is Perl or Table.pm.
------------------------------
Date: Fri, 17 Jan 2003 00:42:25 -0000
From: claird@lairds.com (Cameron Laird)
Subject: Re: most popular unix scripting language
Message-Id: <v2ekbhldaj4mf0@corp.supernews.com>
In article <f51c02db.0301161617.3622cfaa@posting.google.com>,
dambalaMaster <dorli@hotmail.com> wrote:
>does anyone know which is the most popular unix scripting language?
>
>xp829
Yes. Several hundreds of thousands of people know, and,
between them, they only come up with about two dozen
different answers.
--
Cameron Laird <Cameron@Lairds.com>
Business: http://www.Phaseit.net
Personal: http://phaseit.net/claird/home.html
------------------------------
Date: Fri, 17 Jan 2003 01:10:43 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: most popular unix scripting language
Message-Id: <1fowrd4.17uarvm2og3v4N%tony@svanstrom.com>
> In article <f51c02db.0301161617.3622cfaa@posting.google.com>,
> dambalaMaster <dorli@hotmail.com> wrote:
> >does anyone know which is the most popular unix scripting language?
sh
--
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #
perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'
------------------------------
Date: 17 Jan 2003 01:50:57 GMT
From: Allodoxaphobia <nobody@jonz.net>
Subject: Re: most popular unix scripting language
Message-Id: <slrnb2eoc0.cl5.nobody@animas.frontier.net>
On Fri, 17 Jan 2003 01:10:43 GMT, Tony L. Svanstrom hath writ:
>> In article <f51c02db.0301161617.3622cfaa@posting.google.com>,
>> dambalaMaster <dorli@hotmail.com> wrote:
>
>> >does anyone know which is the most popular unix scripting language?
>
> sh
Or, one of it's derivatives.... <g>
Jonesy
--
| Marvin L Jones | jonz | W3DHJ | OS/2
| Gunnison, Colorado | @ | Jonesy | linux __
| 7,703' -- 2,345m | frontier.net | DM68mn SK
------------------------------
Date: Thu, 16 Jan 2003 22:24:21 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: most popular unix scripting language
Message-Id: <3E277765.D7AC5929@earthlink.net>
Allodoxaphobia wrote:
>
> On Fri, 17 Jan 2003 01:10:43 GMT, Tony L. Svanstrom hath writ:
> >> In article <f51c02db.0301161617.3622cfaa@posting.google.com>,
> >> dambalaMaster <dorli@hotmail.com> wrote:
> >
> >> >does anyone know which is the most popular unix scripting
> >> >language?
> >
> > sh
>
> Or, one of it's derivatives.... <g>
Do you count perl as a derivative of sh? <gg>
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: 17 Jan 2003 04:50:21 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: most popular unix scripting language
Message-Id: <b0822d$dri$1@canopus.cc.umanitoba.ca>
In article <1fowrd4.17uarvm2og3v4N%tony@svanstrom.com>,
Tony L. Svanstrom <tony@svanstrom.com> wrote:
:> In article <f51c02db.0301161617.3622cfaa@posting.google.com>,
:> dambalaMaster <dorli@hotmail.com> wrote:
:> >does anyone know which is the most popular unix scripting language?
:sh
Are you measuring by:
A) number of scripts written,
B) enthusiasm level of script authors, or
C) number of distinct script authors?
If you are measuring the number of different script authors, then
my understanding is that the answer is "csh".
I haven't seen very many serious csh scripts, and I can't imagine that
I would ever write a serious script in csh, but there have been
vast number of unix accounts with csh as their default shell, so
there have been large numbers of innocents drawn into it for simple
scripts.
--
Admit it -- you peeked ahead to find out how this message ends!
------------------------------
Date: Thu, 16 Jan 2003 20:30:24 -0500
From: Ed Mendonca <namde@sympatico.ca>
Subject: newbie: How do use -e command line option ? --confused
Message-Id: <I0JV9.9329$fK.1025457@news20.bellglobal.com>
Okay, I understand that -e is used to run perl commands (oneliners) on
the command line... now, I what I'd like to understand, is how to run
multiple commands on one command line.
lets say something to the effect of(psuedo code):
perl -e cat contents of a file;search for a certain word; delete that
word
Appreciate any help on this.
Cheers.
------------------------------
Date: Fri, 17 Jan 2003 01:51:47 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: newbie: How do use -e command line option ? --confused
Message-Id: <1fowt81.1l6bkaj1qvzapyN%tony@svanstrom.com>
Ed Mendonca <namde@sympatico.ca> wrote:
> Okay, I understand that -e is used to run perl commands (oneliners) on
> the command line... now, I what I'd like to understand, is how to run
> multiple commands on one command line.
perl -e 'print "a";' -e 'print "b"'
or
perl -e 'print "a"; print "b"'
--
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #
perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'
------------------------------
Date: Fri, 17 Jan 2003 02:25:12 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: newbie: How do use -e command line option ? --confused
Message-Id: <cQJV9.228094$FT6.36522932@news4.srv.hcvlny.cv.net>
"Ed Mendonca" <namde@sympatico.ca> wrote in message
news:I0JV9.9329$fK.1025457@news20.bellglobal.com...
> Okay, I understand that -e is used to run perl commands (oneliners) on
> the command line... now, I what I'd like to understand, is how to run
> multiple commands on one command line.
>
--snip--
Did you check perldoc perlrun? You should have found under the
description of the -e option:
"Multiple -e commands may be given to build up a multi-line script."
Bill
------------------------------
Date: Fri, 17 Jan 2003 01:54:13 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Outputting a binary file to the browser
Message-Id: <b07no5$sfs$1@wisteria.csv.warwick.ac.uk>
tassilo.parseval@post.rwth-aachen.de wrote:
>> tony@svanstrom.com (Tony L. Svanstrom) wrote in message news:<1fovhv9.1whhfybqkl0l2N%tony@svanstrom.com>...
>> print "Content-Type: ".$media_type. "\n";
>> print "Cache-Control: no-cache \n";
>> print "Content-Length: $length \n";
>> print "Content-Disposition: attachment; filename=".$file."\n";
>> binmode(FILE);
>> binmode(STDOUT);
>
>The header must be separated from the data with a newline. Therefore:
>
> print "Content-Disposition: attachment; filename=$file\n\n";
> ^^^^
> two of them!
Or indeed a here-doc, which is (imho) always better:
print <<HTTP;
Content-type: $media_type
Cache-control: no-cache
Content-length: $length
Content-disposition: attachment; filename=$file
HTTP
Note the blank line before HTTP.
Ben
------------------------------
Date: 16 Jan 2003 15:11:30 -0800
From: entfred@hotmail.com (Entfred)
Subject: Re: perl cgi redirect to variables instead of displaying HTML question
Message-Id: <d6e12cad.0301161511.3feb4a56@posting.google.com>
This is a POST request.
The search engine's terms of service allow this.
The second CGI program is invoked via a Form
submit command. The html is embedded in a perl program.
The perl is something like this:
print <<EOF ;
(some html with hidden fields)
<FORM ACTION="/cgi-bin/music_query.cgi" METHOD=POST>
(a submit button)
EOF
tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb2dfcg.ee8.tadmc@magna.augustmail.com>...
> Entfred <entfred@hotmail.com> wrote:
>
> > I have a CGI perl program which has a form.
> > The form accepts input parameters that are passed to
> > a search engine. The search engine is a CGI program
> > that queries a database.
> >
> > When my CGI program calls the search engine
>
>
> Is is supposed to be a GET or a POST request?
>
> I expect that the search engine's terms of service allow
> you to do what you plan to do?
>
>
> > via a form using
> > hidden fields,
>
>
> How, exactly, are you invoking this second CGI program?
>
>
> > Question - Is there any way for me to redirect the output of
> > the search engine results to variables inside my perl program
> > rather than the data going to the screen? This way, I could
> > manipulate the returned data from the search engine.
>
>
> The LWP::* modules are good for that sort of thing.
>
> Here's a program that does a CPAN search and returns the
> resulting HTML for further processing:
>
> ---------------------------------
> #!/usr/bin/perl
> use strict;
> use warnings;
> use LWP::Simple;
>
> my $url = 'http://search.cpan.org/search';
>
> my $searchterm = 'UserAgent'; # from CGI::param() in a real program
> # may need to URL encode it...
>
> my $result = get "$url?query=$searchterm";
>
> print $result; # here is the "further processing" :-)
> ---------------------------------
------------------------------
Date: Thu, 16 Jan 2003 18:20:03 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: perl cgi redirect to variables instead of displaying HTML question
Message-Id: <slrnb2ej1j.1ot.tadmc@magna.augustmail.com>
Entfred <entfred@hotmail.com> wrote:
> This is a POST request.
> The search engine's terms of service allow this.
use LWP::UserAgent;
[snip TOFU]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 16 Jan 2003 22:42:20 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: perl hashes seems to slow down
Message-Id: <3E277B9C.78A38283@earthlink.net>
nayeem wrote:
>
> fellow japhs,
> ive been using perl hashes for a recent project, but it seems for some
> reason it gives a speed issue when i am browsing through the hash.
> the hash is roughly the following structure :
>
> $rs = {'SUGGESTED_WORDS' => [
> {'NAME' => '...'},
> {'NAME' => '...'},
> {'NAME' => '...'},
> {'NAME' => '...'},
> ...
> ]
> };
>
> so its a hashref of a listref of a hashref. obviously this top hashref
> is much bigger and has other elements then 'suggested_words'. i am
> only quoting an extract from the hash.
>
> when i try to browse through the hash and say add one more field in
> the SUGGESTED_WORDS list eg using a code as below :
>
> =1= for (my $i=0;$i<scalar(@{$rs->{SUGGESTED_WORDS}});$i++) {
> =2= my $word = $rs->{SUGGESTED_WORDS}->[$i];
> =3= my $the_word = $rs->{SUGGESTED_WORDS}->[$i]->{WORD};
> =4= $word->{URL} = "abc";
> =5= }
>
> now questions:
> 1) if i change line =3= to be
> my $the_word = $word->{WORD}
> the system becomes extremely slow in making this simple assignment...
> anyone knows why this happens? is it a bug built-into perl? or am i
> missing something obvious?
Although I'm not sure why it slows down, I would suggest dropping line 4
entirely, since you never actually use $the_word.
> 2) if i change line =4= to be
> $rs->{SUGGESTED_WORDS}->[$i]->{URL} = "abc"
> the assignment never happens. again, anyone knows what reason lies
> behind this?
That sounds very strange. I can't imagine why the assignment would
fail.
> 3) i am a bit concerned about use of hashes in general. the
> application i am writing is very mission critical in that it requires
> very fast response time, if there is any way i can improve on the
> speed by replacing hash with something else or anything i would very
> much like to know more on that since i am using a very large hash that
> actually has a massive XML output in it.
You can increase the speed by replacing the hashes with arrays; the
drawback of course is that instead of descriptive keys such as 'NAME',
'URL', etc, you would use constant indices, 0, 1, etc., which aren't
going to be as clear to the reader. You *could* use constant.pm to get
named constants for those indices, to restore readability, but then
there's the fact that these named constants are actually subs, and their
names are only visible in the package where they're defined, unless you
import them.
> any comments/suggestions/ideas/criticisms would be most appreciated.
I would suggest:
foreach my $word ( @{$rs->{SUGGESTED_WORDS}} ) {
$word->{URL} = "abc";
}
A foreach loop is generally much faster than a C-style for(;;) loop.
In addition, I would suggest profiling your code, using Devel::DProf,
and finding out which parts actually *need* optomization, due to your
program spending lots of time in them, rather than guessing what needs
to be sped up.
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Fri, 17 Jan 2003 01:03:44 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Perl Module for "compressing" text (f u cn rd ths...)
Message-Id: <3e275651.157207168@news.erols.com>
Ethan Brown <ethan@draupnir.gso.saic.com> wrote:
: Does anyone know of a module to "compress" text, e.g.
: "If you can read this you can have a job as a perl programmer"
: =>
: "f u cn rd ths u cn hv a jb as a prl prgrmmr"
Have a look at Lingua::EN::Squeeze.
------------------------------
Date: Fri, 17 Jan 2003 01:34:52 GMT
From: "codeWarrior" <GPatnude@adelphia.net>
Subject: Re: Perl Module for "compressing" text (f u cn rd ths...)
Message-Id: <05JV9.85215$VA5.13344339@news1.news.adelphia.net>
"Jay Tilton" <tiltonj@erols.com> wrote in message
news:3e275651.157207168@news.erols.com...
> Ethan Brown <ethan@draupnir.gso.saic.com> wrote:
>
> : Does anyone know of a module to "compress" text, e.g.
> : "If you can read this you can have a job as a perl programmer"
> : =>
> : "f u cn rd ths u cn hv a jb as a prl prgrmmr"
>
> Have a look at Lingua::EN::Squeeze.
>
#! usr/bin/perl
print "Hello world... I will remove your vowels...\n\n";
$COMP = "\t\tIf you can read this you can have a job as a perl
programmer\n\n";
print $COMP;
$COMP =~ s/[aeiouy]//gisx;
print "$COMP";
exit(0);
------------------------------
Date: 16 Jan 2003 19:54:38 -0800
From: surajsub@netscape.net (Surajsub)
Subject: Processing Files
Message-Id: <cf4a8ef1.0301161954.20238b13@posting.google.com>
Hi ,
Need to process 2 files.
File 1 contains
username=x
username=y
..
...
..
File 2 contains
uniquid=01010MCA
uid=123
uniquid=01031MSS
uid=122
...
...
and so on.
I need to create a file which is finally in the format...of
username=x,uniquid=01010MCA,uid=123
username=y,uniquid=01031MSS,uid=122
Can anybody advise
TIA
S..
------------------------------
Date: Fri, 17 Jan 2003 04:24:41 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Processing Files
Message-Id: <3E278584.8020002@rochester.rr.com>
Surajsub wrote:
> Hi ,
> Need to process 2 files.
> File 1 contains
>
> username=x
> username=y
> ..
> ...
> ..
>
> File 2 contains
>
> uniquid=01010MCA
> uid=123
>
> uniquid=01031MSS
> uid=122
> ...
> ...
> and so on.
> I need to create a file which is finally in the format...of
> username=x,uniquid=01010MCA,uid=123
> username=y,uniquid=01031MSS,uid=122
...
> S..
Well, with the assumption that file 2 contains records in the same order
as file 1, and that each record in file 1 has three corresponding
records in file 2 (a "uniquid" record, a "uid" record, and a null
record), one could do:
use strict;
use warnings;
open IN1,"file1.txt" or die "Oops, couldn't open file1.txt, $!";
open IN2,"file2.txt" or die "Oops, couldn't open file2.txt, $!";
open OUT,">out.txt" or die "Oops, couldn't open out.txt for write, $!";
while(<IN1>){
chomp;
my($username,$uservalue)=split /=/;
my $line1=<IN2>;chomp $line1;
my $line2=<IN2>;chomp $line2;
my $line3=<IN2>;chomp $line3;
my ($uniquid,$uniquidvalue)=split /=/,$line1;
my ($uid,$uidvalue)=split /=/,$line2;
print OUT "$username=$uservalue,$uniquid=$uniquidvalue,".
"$uid=$uidvalue\n";
}
close IN1;
close IN2;
close OUT;
--
Bob Walton
------------------------------
Date: Thu, 16 Jan 2003 22:36:38 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Processing Files
Message-Id: <slrnb2f22m.29h.tadmc@magna.augustmail.com>
Surajsub <surajsub@netscape.net> wrote:
> Hi ,
> Need to process 2 files.
> File 1 contains
>
> username=x
> username=y
> ..
> ...
> ..
>
> File 2 contains
>
> uniquid=01010MCA
> uid=123
>
> uniquid=01031MSS
> uid=122
> ...
> ...
> and so on.
So file2 is guaranteed to have exactly 3 times as many lines as file1?
> I need to create a file which is finally in the format...of
> username=x,uniquid=01010MCA,uid=123
> username=y,uniquid=01031MSS,uid=122
>
> Can anybody advise
-------------------------------
#!/usr/bin/perl
use strict;
use warnings;
open F1, 'file1' or die "could not open 'file1' $!";
open F2, 'file2' or die "could not open 'file2' $!";
while ( <F1> ) {
chomp;
$_ .= ',' . <F2>;
chomp;
$_ .= ',' . <F2>;
<F2>; # discard blank line
print;
}
-------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 16 Jan 2003 22:23:14 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: Question about high performance spidering in perl
Message-Id: <160120032223147632%comdog@panix.com>
In article <x7ptqxdld1.fsf@mail.sysarch.com>, Uri Guttman
<uri@stemsystems.com> wrote:
> just some more info for you. the crawler we did in c took 3 full time
> people 6 months
> the perl crawler was based on stem and that made much of the previous
> crawler's infrastructure go away as stem provides the event loop,
> message passing and many other services. so this one took 1 person about
> 3 months to write.
of course, that's the version 2 effect :)
--
brian d foy, comdog@panix.com
------------------------------
Date: Fri, 17 Jan 2003 02:09:17 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Recreating a MIME::Lite object
Message-Id: <b07okd$srl$1@wisteria.csv.warwick.ac.uk>
Michael Budash <mbudash@sonic.net> wrote:
>In article <b0762d$llu9r$1@ID-172104.news.dfncis.de>,
> "Tintin" <me@privacy.net> wrote:
>
>> This might be a silly question, but here goes.
>>
>> I'm using MIME::Lite to send out emails with attachments, and now have a
>> requirement to create the mail and store it in a file for accessing at a
>> later date.
>>
>> So I store the mail using something similar to:
>>
>> my $msg = MIME::Lite->new(
>> From =>'me@myhost.com',
>> To =>'you@yourhost.com',
>> Cc =>'some@other.com, some@more.com',
>> Subject =>'Helloooooo, nurse!',
>> Type =>'image/gif',
>> Encoding =>'base64',
>> Path =>'hellonurse.gif'
>> );
>>
>> my $mail = $msg->as_string;
>>
>> open FILE, ">mail" or die "Can not write to mail $!\n";
>> print FILE $mail;
>> close FILE;
>>
>>
>> Now what I'd like to do is to somehow read in the contents of the file and
>> recreate the MIME::Lite object.
>>
>> I'm aware of the fh instance method, but that's only applicable for the
>> message body.
>>
>> Is this possible, or can someone suggest an alternative route to take?
>
>the Storable module appears to do what you want:
>
>#-------
>use Storable;
>use MIME::Lite;
>my $msg = MIME::Lite->new(
> From =>"me\@myhost.com",
> To =>"you\@yourhost.com",
> Cc =>"some\@other.com, some@more.com",
> Subject =>"Helloooooo, nurse!",
> Type =>"image/jpeg",
> Encoding =>"base64",
> Path =>"chk.jpg"
> );
>
>store $msg, 'file';
>my $msgcopy = retrieve('file');
Have you tries this? My perl segfaults when I try to retrieve a blessed ref,
and certainly doesn't bless it back into the right package.
Can I ask the OP: do you really need the MIME::Lite object back? Do you wish to
do more with the message than send it? If you don't, then you can just write it
out to a text file and then read it back in and use some other mailing module
(Mail::Sendmail?) to send the complete message.
I reckon the only other thing you can do (unless you investigate other
Storable-alikes and find one which will store blessed refs) is to read the
message back in using MIME::Tools, and deal with rebuilding the MIME::Lite
object if you have to... could get messy.
Ben
------------------------------
Date: Thu, 16 Jan 2003 23:01:08 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Recreating a MIME::Lite object
Message-Id: <3E278004.842C7B9@earthlink.net>
Ben Morrow wrote:
>
> Michael Budash <mbudash@sonic.net> wrote:
[snip]
> >store $msg, 'file';
> >my $msgcopy = retrieve('file');
>
> Have you tries this? My perl segfaults when I try to retrieve a
> blessed ref, and certainly doesn't bless it back into the right
> package.
What version of perl is your perl, and what version of Storable is it
running?
Storable should be perfectly happy storing and retrieving blessed
references, without segfaults.
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Fri, 17 Jan 2003 10:14:13 +1100
From: "^darkage" <darkage@freeshellzzzz.org>
Subject: simple Q, external variables
Message-Id: <b07ec6$j1a$1@perki.connect.com.au>
I haven't dont this one b4 so I not sure how it should look like but how do
you accept an external input. (ie. ./myscript.pl variablehere)
myscript.pl would contain
system('cp filename filename-$variablehere');
------------------------------
Date: Thu, 16 Jan 2003 23:26:42 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: simple Q, external variables
Message-Id: <ScHV9.16775$_T6.4564@nwrddc01.gnilink.net>
^darkage wrote:
> I haven't dont this one b4
Are you sure you didn't mean c5 or a3?
> so I not sure how it should look like but
> how do you accept an external input. (ie. ./myscript.pl
> variablehere)
See "perldoc perlvar"
You should pay particular attention to @ARGV
> myscript.pl would contain
> system('cp filename filename-$variablehere');
No need to fork a process and to exec an external program (which makes your
program non-portable, too).
Just use Perl's "File::Copy".
jue
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4417
***************************************