[28540] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9904 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 29 21:06:02 2006

Date: Sun, 29 Oct 2006 18:05:06 -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           Sun, 29 Oct 2006     Volume: 10 Number: 9904

Today's topics:
    Re: can someone unban me from freenode irc? #perl ? <bik.mido@tiscalinet.it>
    Re: file convesrions jmcnamara@cpan.org
    Re: file convesrions <m@remove.this.part.rtij.nl>
        How do I do full access logging including HTTP headers? <no@spam.com>
    Re: How do I do full access logging including HTTP head <no@email.com>
    Re: How do I do full access logging including HTTP head <jurgenex@hotmail.com>
    Re: How do I do full access logging including HTTP head <no@spam.com>
        Looking for a lightweight GUI editor on Windows j.m.sedgwick@gmail.com
    Re: Looking for a lightweight GUI editor on Windows <DJStunks@gmail.com>
    Re: Looking for a lightweight GUI editor on Windows jussij@zeusedit.com
    Re: Looking for a lightweight GUI editor on Windows <benmorrow@tiscali.co.uk>
    Re: Naive threading performance questions xhoster@gmail.com
        parsing command line args <badarisj@gmail.com>
    Re: parsing command line args <benmorrow@tiscali.co.uk>
    Re: parsing command line args <tadmc@augustmail.com>
    Re: parsing command line args <badarisj@gmail.com>
    Re: Store multi-dimensions array for use in latter form anno4000@radom.zrz.tu-berlin.de
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 29 Oct 2006 14:59:07 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: can someone unban me from freenode irc? #perl ?
Message-Id: <mgc9k25314131elarufntm8rs49tdkcoi8@4ax.com>

On 28 Oct 2006 17:01:12 -0700, "gavino" <bootiack@yahoo.com> wrote:

>Uri Guttman wrote:
[snip 43 lines of mostly irrelvant quotes, .sig included]

>so I guess your a commy

So I guess you'RE a moron.

BTW: I doubt so, but are you willing to explain how one's feeling like
banning a trolling moron could ever have to do with his/her political
views?!?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 29 Oct 2006 04:51:55 -0800
From: jmcnamara@cpan.org
Subject: Re: file convesrions
Message-Id: <1162126315.108740.277410@k70g2000cwa.googlegroups.com>

Jack wrote:
>                there is a file with extension dat  (ie *.dat) in my
> unix environment and i wanted to change this to .xls format i mean i
> have to transfer this file to an excel sheet and then i need to send
> this file as an attachment to an email address and all this should be
> done in perl

As pointed out above you can create a Excel file with Perl using
Spreadsheet::WriteExcel:

    http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel/

You didn't say what format the .dat file was but in the distro there
are serveral example programs that will hel get you started. For
example to convert from csv or tab-separated files to Excel:


http://search.cpan.org/src/JMCNAMARA/Spreadsheet-WriteExcel-2.17/examples/csv2xls.pl

http://search.cpan.org/src/JMCNAMARA/Spreadsheet-WriteExcel-2.17/examples/tab2xls.pl

Or how to create and email an Excel file (using Mail::Sender in this
case but there are many other modules):


http://search.cpan.org/src/JMCNAMARA/Spreadsheet-WriteExcel-2.17/examples/sendmail.pl

John.
--



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

Date: Sun, 29 Oct 2006 20:51:04 +0100
From: Martijn Lievaart <m@remove.this.part.rtij.nl>
Subject: Re: file convesrions
Message-Id: <pan.2006.10.29.19.51.04.52077@remove.this.part.rtij.nl>

On Fri, 27 Oct 2006 12:37:47 -0700, Jack wrote:

> Hello all
> 
>        I have a question!!
>                there is a file with extension dat  (ie *.dat) in my
> unix environment and i wanted to change this to .xls format i mean i

I recently accomplished this by writng the file as html, but giving it a
xls extention. Dirty, but it works.

> have to transfer this file to an excel sheet and then i need to send
> this file as an attachment to an email address and all this should be
> done in perl....please reply me soon

Quickest way is to uuencode it and pipe that to a mailer (f.i. mail). No
perl needed.

M4
-- 
Redundancy is a great way to introduce more single points of failure.



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

Date: Sun, 29 Oct 2006 21:56:28 GMT
From: "Nu" <no@spam.com>
Subject: How do I do full access logging including HTTP headers?
Message-Id: <gs91h.147139$QZ1.117804@bgtnsc04-news.ops.worldnet.att.net>

My webhost has sucky logging.  So I'm looking for a perl or PHP script that
can do full logging of all the HTTP headers for each hit.  I websearched for
hours and came up with nothing.





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

Date: Sun, 29 Oct 2006 22:02:36 +0000
From: Brian Wakem <no@email.com>
Subject: Re: How do I do full access logging including HTTP headers?
Message-Id: <4qkmnsFn8ecdU2@individual.net>

Nu wrote:

> My webhost has sucky logging.  So I'm looking for a perl or PHP script
> that
> can do full logging of all the HTTP headers for each hit.  I websearched
> for hours and came up with nothing.


This should get you started:

print "$_ -> $ENV{$_}\n" foreach keys %ENV;


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


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

Date: Sun, 29 Oct 2006 23:04:29 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How do I do full access logging including HTTP headers?
Message-Id: <1sa1h.3050$pU3.2711@trndny08>

Nu wrote:
> My webhost has sucky logging.  So I'm looking for a perl or PHP
> script that can do full logging of all the HTTP headers for each hit.
> I websearched for hours and came up with nothing.

Doesn't surprise me that you didn't find anything.
Logging can only be done by the tool, that is performing the action. In this 
case the web server is performing the action (= responding to HTTP 
requests), therefore the web server must log its own action. There is no way 
for an external tool to guess what the web server is or isn't doing.

jue 




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

Date: Sun, 29 Oct 2006 23:25:48 GMT
From: "Nu" <no@spam.com>
Subject: Re: How do I do full access logging including HTTP headers?
Message-Id: <0Ma1h.147559$QZ1.32193@bgtnsc04-news.ops.worldnet.att.net>

Thanks, any idea how to use .htaccess how to make it run whenever .htaccess
is called up?


"Brian Wakem" <no@email.com> wrote in message
news:4qkmnsFn8ecdU2@individual.net...
> Nu wrote:
>
> > My webhost has sucky logging.  So I'm looking for a perl or PHP script
> > that
> > can do full logging of all the HTTP headers for each hit.  I websearched
> > for hours and came up with nothing.
>
>
> This should get you started:
>
> print "$_ -> $ENV{$_}\n" foreach keys %ENV;
>
>
> -- 
> Brian Wakem
> Email: http://homepage.ntlworld.com/b.wakem/myemail.png




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

Date: 29 Oct 2006 02:47:49 -0800
From: j.m.sedgwick@gmail.com
Subject: Looking for a lightweight GUI editor on Windows
Message-Id: <1162118869.436355.140060@m73g2000cwd.googlegroups.com>

Hi,

I have been recently forced to switch back to windows, and I am trying
to find a nice lightweight editor. Things like jedit, emacs, notepad++,
ultraedit, etc. bug me because of all the extras. I'm looking for a
non-modal one, so gvim isn't an option. If it's any help, some editors
that I love are gedit (default GNOME), kwrite (KDE), and Geany. Geany
is supposed to run on windows, but I'm encountering an annoying bug in
which geany is unable to switch directories (says an obviously existing
directory doesn't exist) when I use the built in shortcut for running a
perl script. I can't find any help because geany doesn't have a huge
fanbase. Hopefully someone can recommend something, because I've spent
hours trying out various editors I don't like. Perhaps KWrite or gedit
can be run on cygwin or something?

Thanks in Advance,
J. Sedgwick



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

Date: 29 Oct 2006 13:42:16 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Looking for a lightweight GUI editor on Windows
Message-Id: <1162158136.835775.69790@h48g2000cwc.googlegroups.com>


j.m.sedgwick@gmail.com wrote:
> Hi,
>
> I have been recently forced to switch back to windows, and I am trying
> to find a nice lightweight editor. Things like jedit, emacs, notepad++,
> ultraedit, etc. bug me because of all the extras. I'm looking for a
> non-modal one, so gvim isn't an option. If it's any help, some editors
> that I love are gedit (default GNOME), kwrite (KDE), and Geany. Geany
> is supposed to run on windows, but I'm encountering an annoying bug in
> which geany is unable to switch directories (says an obviously existing
> directory doesn't exist) when I use the built in shortcut for running a
> perl script. I can't find any help because geany doesn't have a huge
> fanbase. Hopefully someone can recommend something, because I've spent
> hours trying out various editors I don't like. Perhaps KWrite or gedit
> can be run on cygwin or something?

I use Textpad usually - a native Win32 app.  I think you can use it
free with a nag, but I'm not sure.  I wouldn't say it's the greatest,
but it seems ok and does syntax highlighting.

-jp



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

Date: 29 Oct 2006 14:46:59 -0800
From: jussij@zeusedit.com
Subject: Re: Looking for a lightweight GUI editor on Windows
Message-Id: <1162162019.050082.271730@h48g2000cwc.googlegroups.com>

j.m.sedgwick@gmail.com wrote:

> I have been recently forced to switch back to windows, and I
> am trying to find a nice lightweight editor. Things like jedit,
> emacs, notepad++, ultraedit, etc. bug me because of all the
> extras.

FWIW the Zeus for Windows IDE is probably not what I would
call lightweight, but as it is highly configurable so you should
be able to turn off or hide features you don't need.

   http://www.zeusedit.com
   Note: Zeus is shareware (45 day trial).

Zeus does have things like Perl syntax highlighting, code folding etc

Jussi Jumppanen
Author: Zeus for Windows



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

Date: Mon, 30 Oct 2006 00:12:26 +0000
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Looking for a lightweight GUI editor on Windows
Message-Id: <aksf14-9ds.ln1@osiris.mauzo.dyndns.org>


Quoth j.m.sedgwick@gmail.com:
> 
> I have been recently forced to switch back to windows, and I am trying
> to find a nice lightweight editor. Things like jedit, emacs, notepad++,
> ultraedit, etc. bug me because of all the extras. I'm looking for a
> non-modal one, so gvim isn't an option.

You could try evim (invoke Vim as gvim -y, or more permanently put

    source $VIMRUNTIME/evim.vim
    
in your .vimrc), which sets Vim up as a point-and-click-ish editor.

Ben

-- 
Raise your hand if you're invulnerable.
                                                  [benmorrow@tiscali.co.uk]


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

Date: 30 Oct 2006 00:42:20 GMT
From: xhoster@gmail.com
Subject: Re: Naive threading performance questions
Message-Id: <20061029194237.210$at@newsreader.com>

"Worky Workerson" <worky.workerson@gmail.com> wrote:
>
> And here is my code.  I've factored out the line processing so that it
> would show up in the dprofpp.  Again, sorry if there are any hand-copy
> errors ....

I had assumed you were using Text::CSV_XS to parse lines rather than
printing them.  You might want to try printing them in Perl, you never
know, it might be faster.

>
> #!/usr/bin/perl
>
> use strict; use warnings;
> use IO::File; use Text::CSV_XS;
>
> my @valid_columns = qw/ keya keyb keyc keyd keye keyf keyg keybig
> keyanother /;
> my %valid_columns = map {$_ => 1} @valid_columns;
>
> my $output_csv = Text::CSV_XS->new({eol=>"\n", 'binary' => 1});
> $output_csv->print(*STDOUT, process_line($_)) while (<>);
>
> sub process_line {
>   my ($line) = @_;
>   my ($ip_range, $rest) = split /\s+/, $line, 2;
>   chomp($rest);
>
>   my %ip_details = (ip_range => $ip_range);
>
>   # split on ':', then split each element on '=' and stick in hash
>   map { my ($k, $v) = split /=/; $ip_details{$k} = $v } split(/:/,
> $rest);
>
>   # fix up column with random bad bytes
>   $ip_details{keya} = s/[^\x20-\x7e]//g;
>
>   my @cols = map { $ip_details{$_} } @valid_columns;
>   return \@cols;
> }

I made a few changes that sped it up, but not by much:

  my ($ip_range, $rest) = split /\s+/, $line, 2;
  chomp($rest);

## This will give the same answer as the your map way for "well-formed"
## data.  For malformed data, it will give a different, but probably
##  equally meaningless, answer
  my %ip_details = (split /[=:]/, $rest);


# I don't see what the point of this is, as you never use the ip_range key.
  $ip_details{ip_range} = $ip_range;


## This takes a surprising amount of time, but I don't know what you can
##   do about it.
  # fix up column with random bad bytes
  $ip_details{keya} = s/[^\x20-\x7e]//g;



## Use a hash slice rather than map:

  return [@ip_details{@valid_columns}];



>
> and the top of the dprofpp looks like:
>
> %Time ExclSec CumulS #Calls sec/call Csec/c Name
>  81.7   10.38 10.386 214000   0.0000 0.0000  main::process_line
>  10.7   1.362  1.838 214000   0.0000 0.0000 Text::CSV_XS::print
>  3.75   0.476  0.476 214000   0.0000 0.0000 IO::Handle::print
>  ... other stuff is <1s
>
> Greatly appreciate all your help.

I'm somewhat skeptical about DProf in this instance.  My own profiling
seems to show that CSV_XS::print is using about 33% of the time in the
my modified version of your code.  In my experience, DProf does tend to
give inaccurate answers when fast subs are called a huge number of times.

I get about 44,000 lines per second.  Anyway, I don't see any obvious
inefficiencies.  Maybe parallelization is the better route afterall.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 29 Oct 2006 16:03:30 -0800
From: "badarisj@gmail.com" <badarisj@gmail.com>
Subject: parsing command line args
Message-Id: <1162166610.885029.88820@e3g2000cwe.googlegroups.com>

folks,

when i give a command-line of:
   /tmp/test.pl -arg1 -arg2 -arg3 'value with spaces'
to unix-shell, my perl script has access to the command-line arguments
in the following neat array:

   0  ARRAY(0x12b06c)
   0  '-arg1'
   1  '-arg2'
   2  '-arg3'
   3  'value with spaces'

now if i have a string for the command-line:

   $cmd_str = "/tmp/test.pl -arg1 -arg2 -arg3 'value with spaces'" ;

any ideas on parsing the $cmd_str into a @ARGV array i have shown
above?

thanks,
-badari



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

Date: Mon, 30 Oct 2006 00:18:31 +0000
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: parsing command line args
Message-Id: <nvsf14-9ds.ln1@osiris.mauzo.dyndns.org>


Quoth "badarisj@gmail.com" <badarisj@gmail.com>:
> folks,
> 
> when i give a command-line of:
>    /tmp/test.pl -arg1 -arg2 -arg3 'value with spaces'
> to unix-shell, my perl script has access to the command-line arguments
> in the following neat array:
> 
>    0  ARRAY(0x12b06c)

I'm not quite sure what you intended to mean by this line: for a start,
@ARGV certainly doesn't have two 'element 0's.

>    0  '-arg1'
>    1  '-arg2'
>    2  '-arg3'
>    3  'value with spaces'
> 
> now if i have a string for the command-line:
> 
>    $cmd_str = "/tmp/test.pl -arg1 -arg2 -arg3 'value with spaces'" ;
> 
> any ideas on parsing the $cmd_str into a @ARGV array i have shown
> above?

The Text::ParseWords module will do this for you. I was fairly sure this
was in the FAQ, but a couple of reasonable searches didn't find it, so
I'm not terribly surprised you didn't either :).

Ben

-- 
"If a book is worth reading when you are six,         * benmorrow@tiscali.co.uk
it is worth reading when you are sixty."  [C.S.Lewis]


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

Date: Sun, 29 Oct 2006 19:36:49 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: parsing command line args
Message-Id: <slrnekalph.6v5.tadmc@tadmc30.august.net>

Ben Morrow <benmorrow@tiscali.co.uk> wrote:
>
> Quoth "badarisj@gmail.com" <badarisj@gmail.com>:
>> folks,
>> 
>> when i give a command-line of:
>>    /tmp/test.pl -arg1 -arg2 -arg3 'value with spaces'
>> to unix-shell, my perl script has access to the command-line arguments
>> in the following neat array:
>> 
>>    0  ARRAY(0x12b06c)
>
> I'm not quite sure what you intended to mean by this line: for a start,
> @ARGV certainly doesn't have two 'element 0's.


That's what caused me to not attempt an answer when I saw it.


> The Text::ParseWords module will do this for you. I was fairly sure this
> was in the FAQ, but a couple of reasonable searches didn't find it, 


perldoc -q split

How can I split a [character] delimited string except when inside [character]?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 29 Oct 2006 17:49:33 -0800
From: "badarisj@gmail.com" <badarisj@gmail.com>
Subject: Re: parsing command line args
Message-Id: <1162172973.656306.320990@m73g2000cwd.googlegroups.com>


Ben Morrow wrote:
> Quoth "badarisj@gmail.com" <badarisj@gmail.com>:
> > folks,
> >
> > when i give a command-line of:
> >    /tmp/test.pl -arg1 -arg2 -arg3 'value with spaces'
> > to unix-shell, my perl script has access to the command-line arguments
> > in the following neat array:
> >
> >    0  ARRAY(0x12b06c)
>
> I'm not quite sure what you intended to mean by this line: for a start,
> @ARGV certainly doesn't have two 'element 0's.

hi ben,

that was ouput from my perl debugger. sorry for confusing you.

>
> >    0  '-arg1'
> >    1  '-arg2'
> >    2  '-arg3'
> >    3  'value with spaces'
> >
> > now if i have a string for the command-line:
> >
> >    $cmd_str = "/tmp/test.pl -arg1 -arg2 -arg3 'value with spaces'" ;
> >
> > any ideas on parsing the $cmd_str into a @ARGV array i have shown
> > above?
>
> The Text::ParseWords module will do this for you. I was fairly sure this
> was in the FAQ, but a couple of reasonable searches didn't find it, so
> I'm not terribly surprised you didn't either :).

perfect. just tested it and it works. The Text::ParseWords module
has the routine 'shellwords' which mentions that it emulates
parsing of the command-line by many unix shells ( which is exactly
what i was looking for).

thanks,
-badari

>
> Ben
>
> --
> "If a book is worth reading when you are six,         * benmorrow@tiscali.co.uk
> it is worth reading when you are sixty."  [C.S.Lewis]



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

Date: 29 Oct 2006 22:56:59 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Store multi-dimensions array for use in latter form?
Message-Id: <4qkptrFnf41nU1@news.dfncis.de>

shareparadise@gmail.com <shareparadise@gmail.com> wrote in comp.lang.perl.misc:
> @anno4000: I prefer not to store to file, but I'll definetely check it
> out right now.

What makes you think you have to?  Storable gives you strings if you
want.

Anno


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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