[28339] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9703 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 8 11:05:53 2006

Date: Fri, 8 Sep 2006 08:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 8 Sep 2006     Volume: 10 Number: 9703

Today's topics:
    Re: A Sort Optimization Technique: decorate-sort-dedeco <xah@xahlee.org>
    Re: beginners question <rvtol+news@isolution.nl>
        converting vba to perl without win32::ole <darthmullet67@hotmail.com>
    Re: CPAN 'shell' interface stopped working? <brian.d.foy@gmail.com>
    Re: CPAN 'shell' interface stopped working? <thepoet_nospam@arcor.de>
        Decode data of different charsets into UTF8 (Perl inter <skg@mail.inf.fh-brs.de>
    Re: Decode data of different charsets into UTF8 (Perl i <bik.mido@tiscalinet.it>
    Re: Help using a proxy <Shani718@gmail.com>
    Re: Help using a proxy <scobloke2@infotop.co.uk>
    Re: Help using a proxy <Shani718@gmail.com>
    Re: Memory Limitations for Perl Programs? <shirsch@adelphia.net>
        need to clear cookies in IE using perl Win 32 IE automa vish.chitnis@gmail.com
    Re: Non-uniform split <mumia.w.18.spam+nospam.usenet@earthlink.net>
    Re: Numerical sort (Schwartzian xform) <tadmc@augustmail.com>
        PAR and pp <Jakanapes@aol.com>
    Re: Pattern Matching and skipping <mattjones@hotmail.co.uk>
    Re: Pattern Matching and skipping <tadmc@augustmail.com>
    Re: Pattern Matching and skipping <mattjones@hotmail.co.uk>
        rename file?  open url?  (newbie) aotemp@hotmail.com
    Re: rename file? open url? (newbie) <mritty@gmail.com>
        User authentication for a website <sujay.tukai@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 8 Sep 2006 03:56:12 -0700
From: "Xah Lee" <xah@xahlee.org>
Subject: Re: A Sort Optimization Technique: decorate-sort-dedecorate
Message-Id: <1157712972.925924.290800@m79g2000cwm.googlegroups.com>

i just want to make it known that i think most if not all of the
replies in this thread are of not much technical value. They are either
wrong and or misleading, and the perl module mentioned about sorting or
the Java language aspect on sorting, as they are discussed or
represented, are rather stupid.

I may or may not write a detailed account later. If you have specific
questions, or want to know specific reasons of my claims, please don't
hesitate to email. (privately if you deem it proper)

  Xah
  xah@xahlee.org
=E2=88=91 http://xahlee.org/

xahlee@gmail.com wrote:
> Last year, i've posted a tutorial and commentary about Python and
> Perl's sort function. (http://xahlee.org/perl-python/sort_list.html)
>
> In that article, i discussed a technique known among juvenile Perlers
> as the Schwartzian Transform, which also manifests in Python as its
> =E2=80=9Ckey=E2=80=9D optional parameter.
>
> Here, i give a more detailed account on why and how of this construct.
>=2E..
> This post is archived at:
> http://xahlee.org/perl-python/sort_list.html
>
> I would be interested in comments about how Common Lisp, Scheme, and
> Haskell deal with the decorate-sort-dedecorate technique. In
> particular, does it manifest in the language itself? If not, how does
> one usually do it in the code? (note: please reply to approprate groups
> if it is of no general interest. Thanks) (am also interested on how
> Perl6 or Python3000 does this, if there are major changes to their sort
> function)
>=20
> Thanks.
>=20
>   Xah
>   xah@xahlee.org
> =E2=88=91 http://xahlee.org/



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

Date: Fri, 8 Sep 2006 16:21:05 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: beginners question
Message-Id: <eds5fq.mo.1@news.isolution.nl>

Alpha schreef:
> Okay guys, there's a bit of misunderstanding in my part here. What I
> really want is to match a string like this:
> $str = "whatever Test bla bhlah 123123!!@#!@# Test whoever 123aojiaso
> Test i don't want to see this part in the end";
>
> the result will be "whatever Test bla bhlah 123123!!@#!@# Test whoever
> 123aojiaso "
>
> so the regexp will strip off the last "Test" and whatever that comes
> after that, on a string that doesn't have a pattern except that "Test"
> will appear at least once in the document.
>
> If it only appears once, like here
> $str = "whatever bla bla bla bla bla Test 123combination of strings
> and !@#!@#",
> it will give me
> "whatever bla bla bla bla bla";
>
> in weird situation:
> $str = "Test whatever 12345";
> it will just return empty string
> and on $str = "Test Test Test whatever 12345";
> it will return "Test Test ".
>
> hope that makes it clear now, and thanks for the help ;)

First the keyword was 'String', now the keyword is 'Test'.

Q1: How are you defining the keyword?

Q2: Do you or don't you need to preserve the whitespace just before the
last occurence of the keyword?
(your messy examples show both)

-- 
Affijn, Ruud

"Gewoon is een tijger."




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

Date: 8 Sep 2006 06:34:23 -0700
From: "matt" <darthmullet67@hotmail.com>
Subject: converting vba to perl without win32::ole
Message-Id: <1157722462.930896.258990@h48g2000cwc.googlegroups.com>

I am currently trying to convert a vba macro to perl. The vba macros
are basically find and replaces on txt files. The problem is that there
are roughly 25000 find and replaces and they are setup to run in a
sequential order, meaning that they search for a string and if the
string is found then it will find and replace from that point on until
EOF. Once it reaches the EOF it will then reset to the start of the txt
file and continues on to the next find and replace. How can I
accomplish this type of parsing with perl. I am trying to get the vba
code out of microsoft word so I do not want to use the win32::ole for
this conversion. Here is a snippet of the VBA and converted perl code.
Thanks for any help in advance.

<SNIP>
 VBA code:

 Set variable = New variable_Class
    If variable.FindText("<R [,;)]") = True Then
        Selection.Collapse wdCollapseEnd
        If variable.FindText("<R [,;)]") = True Then
            Selection.Collapse wdCollapseEnd
            If variable.FindText("<R [,;)]") = True Then
                Selection.Collapse wdCollapseEnd
                If variable.FindText("[0-9]{1,} [0-9]{1,} [0-9]") =
True Then
                    Selection.HomeKey wdStory
                    variable.FindandReplace "(^13+pg,[0-9]{1,}^13)(+l)
", " \2\1"
                    Call Subroutine
                End If
            End If
        End If
    End If


 Perl converted code:

  if ($_=~/<R [,;)]/){
      #Selection.Collapse wdCollapseEnd  <==not sure how to convert
this to perl
      if ($_=~/<R [,;)]/){
        #Selection.Collapse wdCollapseEnd  <==not sure how to convert
this to perl
        if ($_=~/<R [,;)]/){
          #Selection.Collapse wdCollapseEnd  <==not sure how to convert
this to perl
          if ($_=~/[0-9]{1,} [0-9]{1,} [0-9]/){
            #Selection.HomeKey wdStory  <==not sure how to convert this
to perl
            $_=~s/(\n\+pg,[0-9]{1,}\n)(\+l)/ $2$1/g;
            &Subroutine;
          }
        }
      }
  }



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

Date: Fri, 08 Sep 2006 10:17:23 -0400
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: CPAN 'shell' interface stopped working?
Message-Id: <080920061017237228%brian.d.foy@gmail.com>

In article <edp98f$r4t$1@gemini.csx.cam.ac.uk>, David Squire
<David.Squire@no.spam.from.here.au> wrote:


> >   alias cpan='perl -MCPAN -e "shell"'
> 
> ... why not try typing 'cpan'? It's almost certainly already there :)

Furthermore, if you want to install modules, just tell 'cpan' on the
command line:

    % cpan Module::Name Some::Other::Module ...

-- 
Posted via a free Usenet account from http://www.teranews.com



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

Date: Fri, 08 Sep 2006 16:43:25 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: CPAN 'shell' interface stopped working?
Message-Id: <4501818d$0$26950$9b4e6d93@newsspool4.arcor-online.net>

brian d foy wrote:
> In article <edp98f$r4t$1@gemini.csx.cam.ac.uk>, David Squire
> <David.Squire@no.spam.from.here.au> wrote:
> 
>>>   alias cpan='perl -MCPAN -e "shell"'
>> ... why not try typing 'cpan'? It's almost certainly already there :)
> 
> Furthermore, if you want to install modules, just tell 'cpan' on the
> command line:
> 
>     % cpan Module::Name Some::Other::Module ...
> 

Which is also documented in "perldoc cpan" :)

-Chris


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

Date: 8 Sep 2006 05:36:19 -0700
From: "ska" <skg@mail.inf.fh-brs.de>
Subject: Decode data of different charsets into UTF8 (Perl internal format)
Message-Id: <1157718979.268283.318760@p79g2000cwp.googlegroups.com>

Hello,

I have the problem that I have different sources of text, which may be:

a) read from a DB (I don't want to trust the database's own idea about
the encoding, as I'm not sure who or what placed the data there),
b) read from file,
c) path specs of files,
d) read from STDIN (filtering).
well, that's it currently. I seek a solution, I can plug into several
modules, not just one.

The text may be in CP437, Latin1, UTF8 or Unicode16 (latter except for
the files). There is no way for me to get the charset from the
"context".

I'm using perl v5.8.4, I see that there is some trouble before v5.8.1
so I suppose I should make sure all machines use a current perl
variant.

I found this thread:
http://groups.google.de/group/comp.lang.perl.misc/browse_thread/thread/6aac916312c57af0/d0f53402e2a91b08?lnk=gst&q=detect+charset&rnum=4#d0f53402e2a91b08
"character encodings" from 2003-11-30.

The solution was there

> 1. open the file in :raw mode.
> 2. read a largeish chunk into a $scalar.
> 3. turn the utf8 flag on with Encode::_utf8_on($scalar);.
> 4. check if the data is valid with Encode::is_utf8($scalar, 1);.
> 5. If it is, reopen the file with :utf8. If it ain't, assume latin2
>    and reopen with :encoding(latin2).

OK, for files that does its job, I guess; however, I wonder if I can
omit to re-open the file in case the script runs as filter? I haven't
found no "ungetc" except FileHandle::Unget.
For text from a DB or path, one could use Encode::decode().

#!/usr/bin/perl

use strict;
use warnings; use diagnostics;

use Devel::Peek qw(Dump);

use encoding 'Latin1';
#use encoding 'cp437';
my $cp437chars = '\x84\x94\x81\x8e\x9a\x99\xe1'; # German umlauts and
Eszett
#use encoding 'Latin1';

use Encode qw();

$/ = undef;	# slurp

#print STDERR "cp437chars = "; Dump($cp437chars);

foreach my $file (@ARGV) {
	if(open(IN, '<', $file)) {
		my @lines = <IN>;
		close IN or warn "Failed reading $file: $!\n";

		my $charset = 'Latin1';

		my $line = join('', @lines);

#		print STDERR "$file: "; Dump($line);

		if(Encode::is_utf8($line, 1)) {
			$charset = 'utf8';
		} elsif($line =~ s/^(?:\xfe\xff)?(\0[^\0])/$1/) {
			$charset = 'ucs-2be';
		} elsif($line =~ s/^(?:\xff\xfe)?([^\0]\0)/$1/) {
			$charset = 'ucs-2le';
		} else {
			my $remainder = $line;
			if($remainder =~ /[^\x01-\x7f]/
			 && (my $s = Encode::decode('utf8', $remainder, Encode::FB_QUIET))
			 && !$remainder) {
			 	$charset = 'utf8-decode';
#use encoding 'cp437';
			} elsif($line =~ /[$cp437chars]/) {
#use encoding 'Latin1';
				$charset = 'cp437';
			}
		}

		if($charset eq 'utf8-decode') {
			Encode::_utf8_on($line);
			die unless Encode::is_utf8($line, 1);
		} elsif($charset ne 'Latin1' && $charset ne 'utf8') {
			my $s = Encode::decode($charset, $line, Encode::FB_QUIET);
			die "Invalid encoding $file/$charset/$line" if $line;
			$line = $s;
		}
#		print STDERR "$file: "; Dump($line);
		$line =~ s/\n+$//;
		print "$file: $charset -- $line\n";
		die "\\0 in line\n" if $line =~ /\0/;
	} else {
		warn "$file: $!\n";
	}
}



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

Date: 8 Sep 2006 15:10:53 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Decode data of different charsets into UTF8 (Perl internal format)
Message-Id: <goq2g2pqdm4b90g9hahkfbd99uj77menru@4ax.com>

On 8 Sep 2006 05:36:19 -0700, "ska" <skg@mail.inf.fh-brs.de> wrote:

>The text may be in CP437, Latin1, UTF8 or Unicode16 (latter except for
>the files). There is no way for me to get the charset from the
>"context".

I think you may want to give a peek into piconv and Encode::Supported.

>OK, for files that does its job, I guess; however, I wonder if I can
>omit to re-open the file in case the script runs as filter? I haven't
>found no "ungetc" except FileHandle::Unget.

You may try to do a seek() followed by a binmode() call. Not really
sure how reliable that would be.


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: 8 Sep 2006 06:48:43 -0700
From: "Shan" <Shani718@gmail.com>
Subject: Re: Help using a proxy
Message-Id: <1157723322.987498.169450@i42g2000cwa.googlegroups.com>

I tried doing

$ua->proxy(['http','gopher','ftp','ssl'], 'localhost:8118');

But this does not work. I get a message saying

501 Protocol scheme 'localhost' is not supported


I don't knwo what to do. Will someone please help me with the code?



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

Date: Fri, 08 Sep 2006 15:06:31 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Help using a proxy
Message-Id: <lL2dnZlza9h35ZzYRVnyiQ@bt.com>

Shan wrote:
> I tried doing
> 
> $ua->proxy(['http','gopher','ftp','ssl'], 'localhost:8118');
> 
> But this does not work. I get a message saying
> 
> 501 Protocol scheme 'localhost' is not supported

Well clearly it was expecting the name of a network protocol, you know, 
telnet, gopher, that kind of thing.

> 
> 
> I don't knwo what to do. 

I just read the documentation, the answer is there.
     perldoc lwp::useragent

> Will someone please help me with the code?
> 

If you read the above, you will get to a bit where it says

     $ua->proxy(...)
         Set/retrieve proxy URL for a scheme:

          $ua->proxy(['http', 'ftp'], 'XXXXXXXproxy.sn.no:8001/');

where I have replaced the answer with XXXXXXX so that you may experience 
the joy of perldoc for yourself :-)


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

Date: 8 Sep 2006 07:38:12 -0700
From: "Shan" <Shani718@gmail.com>
Subject: Re: Help using a proxy
Message-Id: <1157726292.708002.103940@i3g2000cwc.googlegroups.com>

I did read perldoc lwp::useragent

$ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');

I still can't get it to work.



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

Date: Fri, 08 Sep 2006 09:15:18 -0400
From: "Steven N. Hirsch" <shirsch@adelphia.net>
Subject: Re: Memory Limitations for Perl Programs?
Message-Id: <HuudnURxefV08ZzYnZ2dnUVZ_qmdnZ2d@adelphia.com>

Christian Winter wrote:
> Chris Hamel wrote:

>> We have Perl (5.8.0) installed on an AIX server.  The server itself is
>> capable of handling 32-bit processes as large as about 2 GB, and we've
>> never found a ceiling for the 64-bit processes (only 32 GB on the
>> server, and we've run programs as large as 22 GB).  When I run programs
>> in Perl, however, they core dump once the process hits about 250 MB.

> I've hardly had any serious encounters with AIX, so I'm just pulling
> together the few crumbs that crossed my way: 256MB is, if I remember
> correctly, a standard page size and the usual limit for allocating
> memory in one take. Whether more can be used depends on the exact OS
> version, compile time settings and/or environment settings. AFAIR
> there is an explicit Large-Memory readme on the IBM site where this
> is all explained in detail.
> The Keywords for a search should be "-bmaxdata", "LARGE_PAGE_DATA" and
> "LDR_CNTRL".

This is absolutely what the original poster is running into.  I spend
most of my time in AIX and have long ago added the -bmaxdata flag to my
Perl builds.  If you are experienced with a hex/binary editor, it's
quite possible to update an existing perl binary manually.

The AIX large-memory docs (as Christian mentions) even provide a recipe
for doing this from the command line.  And, while it may not be an issue
in your case, keep in mind that increasing maxdata to 2GB reduces the
maximum size for memory-mapped files to 512MB.

Finally, a word of warning: This trick is absolutely _not_ required for
64-bit binaries and will cause problems if you try it!

Steve


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

Date: 8 Sep 2006 06:56:50 -0700
From: vish.chitnis@gmail.com
Subject: need to clear cookies in IE using perl Win 32 IE automation
Message-Id: <1157723810.475160.38940@m79g2000cwm.googlegroups.com>

hi there,

i am beginer in perl and i need to clear IE cookies and temporary
internet files before i call goto URl to access my application url. how
can i clear cookies and temp internet files?

thanks
vishwanath



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

Date: Fri, 08 Sep 2006 10:17:46 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: Non-uniform split
Message-Id: <erbMg.8613$bM.3771@newsread4.news.pas.earthlink.net>

On 09/07/2006 01:56 PM, thisismyidentity@gmail.com wrote:
> Hi all,
> I am writing a Perl script that should parse each line of a file (which 
> unfortunately I cant modify) and split the line. The main problem is 
> that every line (nearly 10000 lines) of the file is not uniform. So 
> there doesnt seem to be a pattern or a delimiter on which I can simply 
> split the line and could do it in a loop over all lines :(.
> Here is an example:
> ========================
> A         B         C         D         E
> d32    ab      ae99       WB      89
> d33    cd       e787      WC     78
> d34    ef                    WD
> d35    gh      ancjd      WT     100
> d36    ij                     WP
> ..
> ..
> ========================
> 
> My main intention is to extract the values in Column A, B,C..into an 
> array but since in some lines some values under a column may not be 
> present..I am unable to have a single regex on which i can split all 
> lines in a loop.  I tried the (obvious) \s+ regex for splitting but 
> since the columns that r empty have spaces, I get different results for 
> a particular column on different lines. I am especially interested in 
> two columns for which it is guaranteed that each line will be non-empty 
> (like A,B,D) but coz of other empty columns cant get them  on a 
> particular index of the array which is returned by split().
> 
> Please give suggestions for following:
> 
> What regex could I use which wud solve my problem?
> 
> Is there any other way apart from split by which i cud achieve this 
> (assuming that there is no single regex to spit on) ?
> 
> Any possible way (as far as I can loop..since no of lines is huge)
> 
> Thanks.
> Greg
> 

Greg, this is your lucky day, because, even though you didn't 
post any attempt of your own to solve this problem, people 
(including me) are falling over themselves to write this 
program for you. E.g.:

#!/usr/bin/perl

use strict;
use warnings;

my ($line, @line);
$line = <DATA>;

local $\ = "\n";
local $" = " | ";

while ($line = <DATA>) {
     @line = unpack('A7 A8 A11 A7 A*', $line);
     @line = map m/^\s*(.*?)\s*$/, @line;
     print "@line";
}


__DATA__
A         B         C         D         E
d32    ab      ae99       WB      89
d33    cd       e787      WC     78
d34    ef                    WD
d35    gh      ancjd      WT     100
d36    ij                     WP

------------end of program ---------------

OUTPUT:
d32 | ab | ae99 | WB | 89
d33 | cd | e787 | WC | 78
d34 | ef |  | WD |
d35 | gh | ancjd | WT | 100
d36 | ij |  | WP |
------------end of output----------------

I saw some of the other solutions, and all I could think was, 
"Wow, what a big program for such a small problem."





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

Date: Thu, 7 Sep 2006 22:59:43 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Numerical sort (Schwartzian xform)
Message-Id: <slrneg1qlf.gda.tadmc@magna.augustmail.com>

Jorge <awkster@yahoo.com> wrote:

> The good advice was suggesting I reduce my program to something that is
> managable for debugging -- 


Then your comment that it was good advice should have come after
quoted text containing that good advice.

Have you seen the Posting Guidelines that are posted here frequently?


> which I did and it helped greatly.


Have you seen the Posting Guidelines that are posted here frequently?

They suggest reducing the program too.



>> [ snip TOFU. Please stop doing that! ]


[ snip yet more TOFU. Please stop doing that before it is too late! ]


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


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

Date: 8 Sep 2006 07:08:21 -0700
From: "Jakanapes" <Jakanapes@aol.com>
Subject: PAR and pp
Message-Id: <1157724501.161826.116990@m79g2000cwm.googlegroups.com>

Hi all,

I'm a relative newbie to perl and I'm having some trouble creating a
standalone executable using PAR.

I'm using Activeperl 5.8.8.819 and tried using PAR .952, however from
the command line, I'm getting "'pp' is not recognized as an internal or
external command..."


On my previous machine, I had Activeperl 5.8.7 and PAR installed and
the pp command worked fine.



What might I be missing?



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

Date: 8 Sep 2006 05:44:00 -0700
From: "MattJ83" <mattjones@hotmail.co.uk>
Subject: Re: Pattern Matching and skipping
Message-Id: <1157719440.451665.304910@e3g2000cwe.googlegroups.com>


> while (<DATA>) {
>       if (/updates table/) {
>          print "MATCHED: $_";
>       }
>       elsif (/elapsed/) {
>          print "MATCHED: $_";
>       }
>       else {
>          print "NO MATCH: $_";
>       }
> }

I understand this but, when i am trying to do something similar for my
specific code im struggling.

      while (<$LOG>) {
       if (/updates table/) {
         my @lines = $_;
          foreach my $file (@lines) {
#            }else { next if !(/updates table/);
#            }

With the if, else statements they are blocking my declared variables
($file) so that the sql statement can't see them. Im getting an
explicit package error.

Surely, i have to find /updates table/ - put the results in array
@lines - allow $file to read this array and then place this $file in my
SQL statement. The curley brackets prevent this?



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

Date: Fri, 8 Sep 2006 08:29:35 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Pattern Matching and skipping
Message-Id: <slrneg2s1v.hop.tadmc@magna.augustmail.com>

MattJ83 <mattjones@hotmail.co.uk> wrote:
> 
>> while (<DATA>) {
>>       if (/updates table/) {
>>          print "MATCHED: $_";
>>       }
>>       elsif (/elapsed/) {
>>          print "MATCHED: $_";
>>       }
>>       else {
>>          print "NO MATCH: $_";
>>       }
>> }
> 
> I understand this but, when i am trying to do something similar for my
> specific code im struggling.


If you post a SHORT AND COMPLETE PROGRAM THAT WE CAN RUN, then
we can surely help you.

Try doing that for once.


>       while (<$LOG>) {
>        if (/updates table/) {
>          my @lines = $_;
           ^^^^^^^^^^^^^^^

Why do you include that last line of code?

What do you think it does for you?

(it does nothing of use to you, so why is it there?)


>           foreach my $file (@lines) {


Q: How many elements can there be in the @lines array?

A: One.

There is no need for a loop that is guaranteed to iterate only once.


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


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

Date: 8 Sep 2006 07:44:54 -0700
From: "MattJ83" <mattjones@hotmail.co.uk>
Subject: Re: Pattern Matching and skipping
Message-Id: <1157726694.431677.150340@d34g2000cwd.googlegroups.com>


> If you post a SHORT AND COMPLETE PROGRAM THAT WE CAN RUN, then
> we can surely help you.
>
> Try doing that for once.

ok, sorry.

#!/usr/central/bin/perl
use strict;
#use warnings;
use DBI;

my @filenames= </home/username/logs/*.log>;
foreach my $filename (@filenames) {
 open my $LOG, '<', $filename or die "can't open $filename: $!\n";

 while (<$LOG>) {
 if (/updates table/) {
  my $info = $_;
{
        while (<$LOG>) {
         if (/elapsed/) {
          my $elapsed1 = $_;
          {
                while (<$LOG>)  {
                 if (/conflicting|FASTSEARCH/) {
                  my $fast = $_;
                {
                        while (<$LOG>) {
                         if (/elapsed/) {
                          my $elapsed2 = $_;
                        {

close($LOG) ;

my $dbh = DBI ->connect("dbi:Oracle:SERVER", "DATABASE", "PASSWORD")
        or die "couldn't connect to database: $DBI::errstr\n";

$dbh->do("insert into LOGS values ('$filename',  '$info', '$elapsed1',
'$fast', '$elapsed2')")
       or die ("inserting data failure: $!\n");

$dbh->disconnect;
}}}}}}}}}}}}}
exit;

 .log
Text updates table text
text
text elapsed text
text
FASTSEARCH text text
text elapsed
text

If you make multiple copies of this log file and remove the word
FASTSEARCH from one of the logs - the log will not be placed into the
database.
>
>
> >       while (<$LOG>) {
> >        if (/updates table/) {
> >          my @lines = $_;
>            ^^^^^^^^^^^^^^^
>
> Why do you include that last line of code?
>
> What do you think it does for you?
>
> (it does nothing of use to you, so why is it there?)
>
>
> >           foreach my $file (@lines) {
> 

Yep - its been removed - i saw what you mean't! Thanks.



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

Date: 8 Sep 2006 07:53:58 -0700
From: aotemp@hotmail.com
Subject: rename file?  open url?  (newbie)
Message-Id: <1157727238.555006.67530@m79g2000cwm.googlegroups.com>

Hi!

Im working with perl, just a very very little bit, and Im looking for
help on how to do 2 tasks.

Im trying to rename, or copy and rename a file stored in my directory,
and Im trying to redirect my user to another url.

ANy advice is appreciated!



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

Date: 8 Sep 2006 08:04:07 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: rename file? open url? (newbie)
Message-Id: <1157727847.544463.183760@e3g2000cwe.googlegroups.com>

aotemp@hotmail.com wrote:
> Im working with perl, just a very very little bit, and Im looking for
> help on how to do 2 tasks.
>
> Im trying to rename, or copy and rename a file stored in my directory,

You have just asked a Self Answering Question.  Please type the
following at your command line:

perldoc -f rename

> and Im trying to redirect my user to another url.

This, however, is meaningless without context.  If you are writing a
CGI script, you should be using the CGI.pm module.  And if you are
using the CGI.pm module, you should have read the CGI.pm documentation
(Type at your command line: perldoc CGI).  And if you'd done that, you
would have searched for the word "redirect".    So make sure you do all
three of those things, and then let us know if you still have
questions.

> ANy advice is appreciated!

Familiarize yourself with the standard Perl documentation, the
`perldoc` program.  Familiarize yourself with the built-in Perl FAQ
(perldoc perlfaq).  And familiarize yourself with the Posting
Guidelines for this group, posted here twice a week.

Paul Lalli



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

Date: 8 Sep 2006 05:27:45 -0700
From: "sujay.tukai@gmail.com" <sujay.tukai@gmail.com>
Subject: User authentication for a website
Message-Id: <1157718465.877140.318880@m73g2000cwd.googlegroups.com>

I have an account in a website. Whenever i need to read my inbox from
that website. I have to login with my name and password.

I need a solution for this i.e.,
i need a perl program which

(1)uses the password and username to login
(2) read the inbox

the server has a https connection...and sorry to say no pop3 access is
there....
i tried lwp posting of username and password. it worked to a certain
extent. that is i got in.

but again for reading the inbox using the lwp get method i get this
message "Your session has expired, please login again!"

plz help me reg. the steps i should use????



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

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


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