[28555] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9919 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 2 03:06:07 2006

Date: Thu, 2 Nov 2006 00:05:07 -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, 2 Nov 2006     Volume: 10 Number: 9919

Today's topics:
    Re: Abysmal performance of Net::SFTP (and I have GMP &  <sisyphus1@nomail.afraid.org>
        ajax looks crappy <bootiack@yahoo.com>
        empty leading field from split() <DJStunks@gmail.com>
    Re: empty leading field from split() <DJStunks@gmail.com>
    Re: how do i update one section of a page leaving rest? <bootiack@yahoo.com>
    Re: how do i update one section of a page leaving rest? <bootiack@yahoo.com>
    Re: How to capture repeated subpatterns? <tadmc@augustmail.com>
    Re: How to capture repeated subpatterns? <rvtol+news@isolution.nl>
    Re: Need to retain the order of array of hash reference <kalyanrajsista@gmail.com>
    Re: Need to retain the order of array of hash reference <kalyanrajsista@gmail.com>
        new CPAN modules on Thu Nov  2 2006 (Randal Schwartz)
    Re: Perl equivalent to unix script <dmercer@mn.rr.com>
        question about output <yngzhou@gmail.com>
    Re: question about output <yngzhou@gmail.com>
    Re: reg exact string matching <tadmc@augustmail.com>
    Re: reg exact string matching (reading news)
    Re: Regular Expression Question Why Doesn't this Match? <tadmc@augustmail.com>
    Re: Regular Expression Question Why Doesn't this Match? <tadmc@augustmail.com>
        SQLPlus with Perl <natlee75@yahoo.com>
        Thank you jim for #perl on freenode (im banned at home) <bootiack@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 2 Nov 2006 13:48:49 +1100
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Abysmal performance of Net::SFTP (and I have GMP & Pari)
Message-Id: <45495db1$0$11974$afc38c87@news.optusnet.com.au>


<usenet@DavidFilmer.com> wrote in message
news:1162432420.105832.200020@m7g2000cwm.googlegroups.com...
 .
 .
>> To check that's *not* the case I would rename Math/BigInt.pm to
> > (eg) Math/BigInt_hide.pm, re-run the script and see if performance
improves.
>

> I tried your suggestion and the test program blew up with:
>
>    Can't locate Math/BigInt.pm in @INC ... Crypt/DH.pm line 6
>

Same culprit as last time.

>
> Line 6 of Crypt::DH (version 0.06) says:
>    use Math::BigInt lib => "GMP,Pari";
>

Yes ... that's what it says alright .... but I sort of expected it should
be:

use Math::BigInt lib => "GMP","Pari";

I could be wrong about that.

You have Math::BigInt::GMP, so just change the above line to:

use Math::BigInt lib => "GMP";

I'm assuming that Math::BigInt::GMP is fully functional ... ??

Cheers,
Rob




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

Date: 1 Nov 2006 22:53:05 -0800
From: "gavino" <bootiack@yahoo.com>
Subject: ajax looks crappy
Message-Id: <1162450385.211093.31670@i42g2000cwa.googlegroups.com>

yep



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

Date: 1 Nov 2006 21:03:12 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: empty leading field from split()
Message-Id: <1162443786.842164.248770@b28g2000cwb.googlegroups.com>

I whipped this up for someone looking for a parser for the DATA listed.

It works well, but I can't figure out why the split() produces an empty
leading field...  I ran it through re qw{ debug } but I couldn't pick
it up.

Can anyone shine some light on this for me?

TIA,
-jp

  #!/usr/bin/perl

  use strict;
  use warnings;

  my $text = do {local $/; <DATA>};

  my %hash;
  (undef, %hash) = split m{^ (.+?) \s* : \s* }xm, $text;

  s/\s+/ /g and s/\s+$//g for values %hash;		# repair whitespace

  use Data::Dumper;
  $Data::Dumper::Sortkeys = 1;
  print Dumper \%hash;

  __DATA__
  keyword1: blahblah
  asdfas
  keyword2: blah blah blah
  more blah blah blah
  keyword3: and so on
  and on to in the end
  three lines total



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

Date: 1 Nov 2006 21:08:10 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: empty leading field from split()
Message-Id: <1162444090.529558.318740@m73g2000cwd.googlegroups.com>

DJ Stunks wrote:
> I can't figure out why the split() produces an empty leading field

oh man.

of course.  as soon as I post, I realize.  because it's a split and
there's no data before the first separator the first data field is
undef.......

sorry for the interruption, I should have thought for another half hour
before asking.

my bad.
-jp



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

Date: 1 Nov 2006 20:56:43 -0800
From: "gavino" <bootiack@yahoo.com>
Subject: Re: how do i update one section of a page leaving rest?
Message-Id: <1162443402.871781.19640@i42g2000cwa.googlegroups.com>

Today I got aolserver installed.



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

Date: 1 Nov 2006 22:44:23 -0800
From: "gavino" <bootiack@yahoo.com>
Subject: Re: how do i update one section of a page leaving rest?
Message-Id: <1162449862.926165.230990@b28g2000cwb.googlegroups.com>


J=FCrgen Exner wrote:
> gavino wrote:
> > How Do i updae one section of  a page leaving the rest?
>
> You could open that page in your favourite editor, delete the section you
> don't like, and type in the new content.
>
> jue

lol
thanks dude
The idea is to make cool web apps that are fast
A statik site wouldn't do well.
Remember to vote republican.



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

Date: Wed, 1 Nov 2006 20:10:42 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to capture repeated subpatterns?
Message-Id: <slrnekikt2.l61.tadmc@tadmc30.august.net>

Martin Larsen <martin+spamfree+larsen@bigfoot.com> wrote:

> In fact, it is a matter of extracting parameters from an expression. So
> let me try again, this time with some html code.


HTML does not have expressions, perhaps because it is not a 
programming language?


> Here is an image declaration:
>
><img src="mypic.jpg" class="myclass" alt="description" title="some text">
>
> I need to match the full expression and also to capture the individual
> attributes.
>
> The declation shown could be matched by

[snip]

> Fine, but what if the html code had yet another attribute, like:

[snip]

Or what if it had exactly the same attributes, as in:

  <img src='mypic.jpg' class='myclass' alt='description' title='some text'>

Or what if it is not an image tag at all?

   <!--
   <img src="mypic.jpg" class="myclass" alt="description" title="some text">
   -->

Then it will match when it shouldn't.


> Then the expression wouldn't match anymore. Of course I could just add a
> bunch of the subpatterns to the expression,

[snip]

> But as you see, it is certainly not elegant.


Using a regular expression to parse an arbitrary context free
language, such as HTML, is almost always a mistake that will result
in fragile and perhaps incorrect implementations.

It is only feasible if you can place many restrictions on what
your HTML data can contain.


> Instead I need to extract ALL the parameters individually.


Consider doing a proper parse using a module that knows how
to parse HTML.


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


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

Date: Thu, 2 Nov 2006 08:42:49 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: How to capture repeated subpatterns?
Message-Id: <eicb64.1f8.1@news.isolution.nl>

Martin Larsen schreef:
> Thanks for your responses, but you both misunderstand what I aim at.
>
> I simplified the expression to make it more clear, but I realize that
>   it does the opposite by confusing you into thinking that all I need
> is to capture all the words.
>
> That is not the case at all.
>
> In fact, it is a matter of extracting parameters from an expression.
> So let me try again, this time with some html code.
>
> Here is an image declaration:
>
> <img src="mypic.jpg" class="myclass" alt="description" title="some
> text">
>
> I need to match the full expression and also to capture the individual
> attributes.
>
> The declation shown could be matched by
>
> <img *(\w+="[^"]*")? *(\w+="[^"]*")? *(\w+="[^"]*")? *(\w+="[^"]*")?>
>
> That gives:
>
> submatch 1 = src="mypic.jpg"
> submatch 2 = class="myclass"
> submatch 3 = alt="description"
> submatch 4 = title="some text"
>
> Fine, but what if the html code had yet another attribute, like:
>
> <img src="mypic.jpg" class="myclass" alt="description" title="some
> text" border="0">
>
> Then the expression wouldn't match anymore. Of course I could just
> add a bunch of the subpatterns to the expression, because since I
> have made them optional the regex will match even if there are less
> attributes than subpatterns.
>
> For example, this would match up to 8 attributes:
> <img *(\w+="[^"]*")? *(\w+="[^"]*")? *(\w+="[^"]*")? *(\w+="[^"]*")?
> *(\w+="[^"]*")? *(\w+="[^"]*")? *(\w+="[^"]*")? *(\w+="[^"]*")?>
>
> But as you see, it is certainly not elegant.
>
> Well, then ... if it was just a matter of matching an arbitrary number
> of attributes, the regex would simply be:
>
> <img(?: *(\w+="[^"]*"))+>
>
> But the only submatch would then be border="0". Only the last submatch
> is captured.
>
> Instead I need to extract ALL the parameters individually, so the
> million dollar question is:
>
> Is it possible to define a regex using repeated subpatterns in such a
> way that all subpatterns can be captured individually?
>
> The real usage is a little more complicated than matching html
> attributes, and yes: I could use a parser etc!
>
> But I would really like to know if my quest is possible!

That's a lot of words for such a simple question. The real answer is:
use a parser. And since you write you could, you should.

Read the following aloud, with a good pause at each comma:
To match both the full text, and to capture repeated subpatterns, by
using regular expressions, just use two regular expressions, with the
second depending on the (success of the) first:


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

  my $re_val  = qr/"[^"]*"|'[^']*'/ ;
  my $re_attr = qr/\w+(?:=${re_val})?/ ;
#  print "re_attr:{${re_attr}}\n\n" ;

  my $html = join '', <DATA> ;
  print "html:{$html}\n" ;

  if ($html =~ m/^\s*<(\w+)([^>]*)>/)
  {
    my $tag   = $1 ;
    my @attrs = ($2 =~ m/\s+(${re_attr})/g) ;

    print "tag:{$tag}\n" ;
    print "{$_}\n" for @attrs ;
  }

__DATA__
<img src="mypic.jpg" class="myclass" alt="description"
title="some text" border="0" one='test' two>

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: 1 Nov 2006 21:09:15 -0800
From: "alwaysonnet" <kalyanrajsista@gmail.com>
Subject: Re: Need to retain the order of array of hash references.
Message-Id: <1162444155.700539.226030@e3g2000cwe.googlegroups.com>

May be i'm weak in conveying my requirement... here we go...

> If 'A/C No' values are unique, then you can do a simple sort on 'A/C
> No'. There is no need to retain the order, because the order of the
> sorted array is completely determined by the values of 'A/C No'.
> Unfortunately, your sample output below is NOT sorted by 'A/C No'.
>
>
If 'A/C No' values are unique, then you can do a simple sort on 'A/C
No'. There is no need to retain the order, because the order of the
sorted array is completely determined by the values of 'A/C No'.
Unfortunately, your sample output below is NOT sorted by 'A/C No'.

'A/C No' is unique for all the records, but the records must be
displayed in contiguous order of prefund,receipt and payment.

For Ex-  If there are 3 - Prefund , 4- Receipt and 2- Payment records,
then all the records must be displayed as

Prefund
Prefund
Prefund
Receipt
Receipt
Receipt
Receipt
Payment
Payment

So ,sorting with 'A/C No' will effect the order of "Type" which I dont
want. that's why i declared an hash of type_order.

> If two or more records have the same 'Type', 'Status', and 'ZCurrency'
> values and different 'A/C No' values, then sorting them by 'A/C No' can
> definitely affect their order in the final result.
>

I agree with you that if two records with same "Type",'Status' and
'ZCurrency' then sorting them with A/C No will definitely effect their
result.

> >
> > 2) if current record matches with previous record, i'm pushing to
> > another array and sorting them with the "A/C No". Because, both the
> > records will have same "Type","Status" and "ZCurrency".
>
> Are records with the same 'Type', 'Status', and 'ZCurrency' values
> always continguous in your set of records?
>

Yes, if records are having same "Type","Status" and "ZCurrency" , they
are always contiguous but their "A/C No" are not in sorted order.

so , my concern is to sort the contigous records having same
"Type","Status" and "ZCurrency" with their "A/C No"'s

> It looks like you want to sort by: 1) 'Type', 2) 'Status', 3)
> 'ZCurrency', and 4) 'A/C No'. Is that correct? Try this (untested):
>
> @sorted = sort { $a->{'Type'} cmp $b->{'Type'} ||
>                  $a->{'Status'} cmp $b->{'Status'} ||
>                  $a->{'ZCurrency'} cmp $b->{'ZCurrency'} ||
>                  $a->{'A/C No'} cmp $b->{'A/C No'} } @records;
>
> You can help us help you by writing a complete, short-as-possible,
> working program that demonstrates the problem you are having. In your
> case, I would recommend testing with fewer and shorter data records
> until you get the sort part working. Something link:
>
> @records = (
>   { a => 1, b => 1, c => 1, d => 1 },
>   { a => 1, b => 1, c => 1, d => 2 },
>   { a => 1, b => 1, c => 1, d => 3 },
> 
> (you get the picture, I hope).
> 
> Good luck.

Thanks,
Raj



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

Date: 1 Nov 2006 21:12:57 -0800
From: "alwaysonnet" <kalyanrajsista@gmail.com>
Subject: Re: Need to retain the order of array of hash references.
Message-Id: <1162444377.798899.136130@m7g2000cwm.googlegroups.com>

May be i'm weak in conveying my requirement... here we go...


> If 'A/C No' values are unique, then you can do a simple sort on 'A/C
> No'. There is no need to retain the order, because the order of the
> sorted array is completely determined by the values of 'A/C No'.
> Unfortunately, your sample output below is NOT sorted by 'A/C No'.

'A/C No' is unique for all the records, but the records must be
displayed in contiguous order of prefund,receipt and payment.

For Ex-  If there are 3 - Prefund , 4- Receipt and 2- Payment records,
then all the records must be displayed as

Prefund
Prefund
Prefund
Receipt
Receipt
Receipt
Receipt
Payment
Payment

So ,sorting with 'A/C No' will effect the order of "Type" which I dont
want. that's why i declared an hash of type_order.

> If two or more records have the same 'Type', 'Status', and 'ZCurrency'
> values and different 'A/C No' values, then sorting them by 'A/C No' can
> definitely affect their order in the final result.

I agree with you that if two records with same "Type",'Status' and
'ZCurrency' then sorting them with A/C No will definitely effect their
result.

> > 2) if current record matches with previous record, i'm pushing to
> > another array and sorting them with the "A/C No". Because, both the
> > records will have same "Type","Status" and "ZCurrency".

> Are records with the same 'Type', 'Status', and 'ZCurrency' values
> always continguous in your set of records?

Yes, if records are having same "Type","Status" and "ZCurrency" , they
are always contiguous but their "A/C No" are not in sorted order.

so , my concern is to sort the contigous records having same
"Type","Status" and "ZCurrency" with their "A/C No"'s

> It looks like you want to sort by: 1) 'Type', 2) 'Status', 3)
> 'ZCurrency', and 4) 'A/C No'. Is that correct? Try this (untested):

> @sorted = sort { $a->{'Type'} cmp $b->{'Type'} ||
>                  $a->{'Status'} cmp $b->{'Status'} ||
>                  $a->{'ZCurrency'} cmp $b->{'ZCurrency'} ||
>                  $a->{'A/C No'} cmp $b->{'A/C No'} } @records;


> You can help us help you by writing a complete, short-as-possible,
> working program that demonstrates the problem you are having. In your
> case, I would recommend testing with fewer and shorter data records
> until you get the sort part working. Something link:


> @records = (
>   { a => 1, b => 1, c => 1, d => 1 },
>   { a => 1, b => 1, c => 1, d => 2 },
>   { a => 1, b => 1, c => 1, d => 3 },


> (you get the picture, I hope). 


> Good luck. 

Thanks, 
Raj



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

Date: Thu, 2 Nov 2006 05:42:09 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Nov  2 2006
Message-Id: <J83969.1Cq9@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

AcePerl-1.91
http://search.cpan.org/~lds/AcePerl-1.91/
----
BSD-Process-0.01
http://search.cpan.org/~dland/BSD-Process-0.01/
Retrieve information about running processes
----
Catalyst-Plugin-FormValidator-Simple-0.11
http://search.cpan.org/~lyokato/Catalyst-Plugin-FormValidator-Simple-0.11/
Validator for Catalyst with FormValidator::Simple
----
Chart-Math-Axis-1.00
http://search.cpan.org/~adamk/Chart-Math-Axis-1.00/
Implements an algorithm to find good values for chart axis
----
Class-Accessor-Classy-v0.1.1
http://search.cpan.org/~ewilhelm/Class-Accessor-Classy-v0.1.1/
accessors with minimal inheritance
----
Class-DBI-Loader-Informix-0.03
http://search.cpan.org/~jstowe/Class-DBI-Loader-Informix-0.03/
Class::DBI::Loader Informix Implementation.
----
Class-DBI-Loader-Informix-1.4
http://search.cpan.org/~jstowe/Class-DBI-Loader-Informix-1.4/
Class::DBI::Loader Informix Implementation.
----
Compress-Raw-Bzip2-2.001
http://search.cpan.org/~pmqs/Compress-Raw-Bzip2-2.001/
Low-Level Interface to bzip2 compression library
----
Compress-Raw-Zlib-2.001
http://search.cpan.org/~pmqs/Compress-Raw-Zlib-2.001/
Low-Level Interface to zlib compression library
----
Compress-Zlib-2.001
http://search.cpan.org/~pmqs/Compress-Zlib-2.001/
Interface to zlib compression library
----
Coro-2.1
http://search.cpan.org/~mlehmann/Coro-2.1/
coroutine process abstraction
----
DBIx-Wrapper-VerySimple-0.05
http://search.cpan.org/~matisse/DBIx-Wrapper-VerySimple-0.05/
Simplify use of DBI
----
Data-Compare-0.14
http://search.cpan.org/~dcantrell/Data-Compare-0.14/
compare perl data structures
----
Event-1.08
http://search.cpan.org/~jprit/Event-1.08/
Event loop processing
----
FreeMind-Convert-0.01
http://search.cpan.org/~takeo/FreeMind-Convert-0.01/
FreeMind .mm File Convert to wiki Format
----
Geo-Spline-0.02
http://search.cpan.org/~mrdvt/Geo-Spline-0.02/
Calculate geographic locations between GPS fixes.
----
HTML-TagParser-0.14
http://search.cpan.org/~kawasaki/HTML-TagParser-0.14/
Yet another HTML tag parser by pure Perl implementation
----
IO-Compress-Base-2.001
http://search.cpan.org/~pmqs/IO-Compress-Base-2.001/
Base Class for IO::Compress modules
----
IO-Compress-Bzip2-2.001
http://search.cpan.org/~pmqs/IO-Compress-Bzip2-2.001/
Write bzip2 files/buffers
----
IO-Compress-Lzf-2.001
http://search.cpan.org/~pmqs/IO-Compress-Lzf-2.001/
Write lzf files/buffers
----
IO-Compress-Lzop-2.001
http://search.cpan.org/~pmqs/IO-Compress-Lzop-2.001/
Write lzop files/buffers
----
IO-Compress-Zlib-2.001
http://search.cpan.org/~pmqs/IO-Compress-Zlib-2.001/
----
Net-FTP-Simple-0.0006
http://search.cpan.org/~wilco/Net-FTP-Simple-0.0006/
Simplified interface to a few common FTP tasks with Net::FTP.
----
Object-InsideOut-2.18
http://search.cpan.org/~jdhedden/Object-InsideOut-2.18/
Comprehensive inside-out object support module
----
POE-Component-IKC-0.1902
http://search.cpan.org/~gwyn/POE-Component-IKC-0.1902/
POE Inter-Kernel Communication
----
Params-Util-0.22
http://search.cpan.org/~adamk/Params-Util-0.22/
Simple, compact and correct param-checking functions
----
Plagger-0.7.15
http://search.cpan.org/~miyagawa/Plagger-0.7.15/
Pluggable RSS/Atom Aggregator
----
RPM-Make-Simple-0.03
http://search.cpan.org/~steveha/RPM-Make-Simple-0.03/
simple interface to RPM::Make
----
Regexp-Assemble-0.27
http://search.cpan.org/~dland/Regexp-Assemble-0.27/
Assemble multiple Regular Expressions into a single RE
----
SVN-Notify-Config-0.0902
http://search.cpan.org/~jpeacock/SVN-Notify-Config-0.0902/
Config-driven Subversion notification
----
SVN-Notify-Mirror-0.03402
http://search.cpan.org/~jpeacock/SVN-Notify-Mirror-0.03402/
Keep a mirrored working copy of a repository path
----
Security-CVSS-0.01
http://search.cpan.org/~jdennis/Security-CVSS-0.01/
Calculate CVSS values (Common Vulnerability Scoring System)
----
Sledge-Engine-0.01
http://search.cpan.org/~ikebe/Sledge-Engine-0.01/
run Sledge based application (EXPERIMENTAL).
----
Sledge-Plugin-CreateConfig-0.01
http://search.cpan.org/~tokuhirom/Sledge-Plugin-CreateConfig-0.01/
auto generate the create_config method
----
Sledge-Plugin-SNMP-0.01a
http://search.cpan.org/~tsunoda/Sledge-Plugin-SNMP-0.01a/
Object oriented interface to SNMP
----
Sledge-Utils-0.02
http://search.cpan.org/~tokuhirom/Sledge-Utils-0.02/
utility functions for Sledge
----
Syntax-Highlight-Engine-Kate-0.02
http://search.cpan.org/~hanje/Syntax-Highlight-Engine-Kate-0.02/
a port to Perl of the syntax highlight engine of the Kate texteditor.
----
Template-Process-0.0003
http://search.cpan.org/~ferreira/Template-Process-0.0003/
Process TT2 templates against data files
----
Template-Process-0.0004
http://search.cpan.org/~ferreira/Template-Process-0.0004/
Process TT2 templates against data files
----
Test-Run-0.0101
http://search.cpan.org/~shlomif/Test-Run-0.0101/
----
UML-Class-Simple-0.04
http://search.cpan.org/~agent/UML-Class-Simple-0.04/
Render simple UML class diagrams, by loading the code
----
Wx-Perl-VirtualTreeCtrl-1.017
http://search.cpan.org/~bbc/Wx-Perl-VirtualTreeCtrl-1.017/
Build a tree control on demand
----
cpan-script-1.53
http://search.cpan.org/~bdfoy/cpan-script-1.53/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Thu, 02 Nov 2006 05:43:11 GMT
From: "Dan Mercer" <dmercer@mn.rr.com>
Subject: Re: Perl equivalent to unix script
Message-Id: <Pzf2h.50378$F7.6389@tornado.rdc-kc.rr.com>


<usenet@DavidFilmer.com> wrote in message news:1162234813.014276.223590@e64g2000cwd.googlegroups.com...
: Mike wrote:
:
: > cat tempfile1 | sort > newfile2;
:
: That's rather convoluted even for UNIX scripting.  Why not:
:
:    sort tempfile1 > newfile2;

Even that's too convoluted - why not just

    sort -o file file

Sort already uses temporary files - multiple,  depending on
size of the data - one reason you have to be cognizant of your
file system.  You can specify a tempdir where the files will
be built (it defaults to the current dir).  And the sort program
will be miles faster than perl.  Unless the data you are sorting
is too complex for sort,  stick with sort and RTFM.

Dan Mercer

:
: You cannot do this as a pure-Perl approach (ie, no shell redirects,
: etc) any more simply.  You could do something like this:
:
: #!/usr/bin/perl
:    use strict; use warnings;
:
:    open (my $in,  '<', '/tmp/tempfile1') or die "oops - $!\n";
:    open (my $out, '>', '/tmp/newfile2')  or die "oops - $!\n";
:
:    print $out sort(<$in>);
:
:    close $in;
:    close $out;
:
:    unlink $in;
:
: __END__
:
: --
: The best way to get a good answer is to ask a good question.
: David Filmer (http://DavidFilmer.com)
:




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

Date: 1 Nov 2006 20:48:20 -0800
From: "opmn" <yngzhou@gmail.com>
Subject: question about output
Message-Id: <1162442900.167616.102950@h54g2000cwb.googlegroups.com>

The output of my program is messed up.

This is the code for output:
-------------------------------
printf("%5d  Q0  %15s  %5d  %.10f  Exp\n", $query_id,
$docidmap{$docid}, $rank, $scores{$docid});
 ------------------------------

The output is expected to have 6 columns. But actually, I got only last
3. I did debugging and here is what I get:
 ------------------------------
  DB<13> printf("%5d", $query_id);
  152
  DB<14> printf("%5d Q0", $query_id);
  152 Q0
  DB<15> printf("%5d Q0 %15s", $query_id, $docidmap{$docid});
  152 Q0   DOE1-62-0080
  DB<16> printf("%5d Q0 %15s %5d", $query_id, $docidmap{$docid},
$rank);
     1Q0   DOE1-62-0080
-------------------------------

Here the value of $rank is 1. It's so weird that when $rank is added to
the output, it begins from the beginning of the line. Anyone tell me
why is this happening and how can I avoid it?

Thanks for any tip!



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

Date: 1 Nov 2006 21:27:06 -0800
From: "opmn" <yngzhou@gmail.com>
Subject: Re: question about output
Message-Id: <1162445226.542917.317740@b28g2000cwb.googlegroups.com>

Problem solved... some stupid bug... never mind...



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

Date: Wed, 1 Nov 2006 20:13:45 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: reg exact string matching
Message-Id: <slrnekil2p.l61.tadmc@tadmc30.august.net>

sivga <arvindkannan1@gmail.com> wrote:

> i need to match pid-[0-9*]-[0-9*] and not anything like pid-3-1-1 or
> pid-3 ,pid-3-1-1-1 etc


Your pattern would match

   pid-*-*

is that what you want it to match?

Asterisks are not metacharacters when used inside of a character class.


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


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

Date: Thu, 02 Nov 2006 06:47:21 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: reg exact string matching
Message-Id: <Zvg2h.1320$l25.722@newsread4.news.pas.earthlink.net>

On 11/01/2006 06:04 PM, sivga wrote:
> Hi
> 
> how do i match a string exactly for eg
> 
> $stringid is pid-3-1
> 
> i need to match pid-[0-9*]-[0-9*] and not anything like pid-3-1-1 or
> pid-3 ,pid-3-1-1-1 etc
> 
> allowed possibilities are
> 
> pid-any no of digits-any no of digits
> 
> this is the code i have but does not seem to work
> 
> if ($stringid eq 'pid-[0-9*]-[0-9*]' ) {
>                         print " pid  is correct ...... \n";
> 
>               }else {
>                         print " pid does not exist  \n";
>                         exit 1;
>                      }
> 

Learn Perl. Start the perldoc utility and tell it to show you the "perl" 
introduction document this way:

Start->Run->"perldoc perl"

You need to look at the perlrequick document:

Start->Run->"perldoc perlrequick"

And also look at "perlintro":

Start->Run->"perldoc perlintro"

Good luck.


-- 
paduille.4060.mumia.w@earthlink.net


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

Date: Wed, 1 Nov 2006 20:18:03 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regular Expression Question Why Doesn't this Match?
Message-Id: <slrnekilar.l61.tadmc@tadmc30.august.net>

jm <needin4mation@gmail.com> wrote:
>
> Christian Winter wrote:
>> jm wrote:
>> > /([\w\s\.\'\-]*)
>> >
>> > does not match this:
>> >
>> >     My Fictional Co.
>> >
>> > But it does match
>> >
>> >     Product by abc company
>> >
>> > I don't understand why it matches the second one, but not the first.


I don't understand how it could fail to match the first...


>> Give a short, working examples that
>> illustrates what exactly you are trying to accomplish,
>> and what goes wrong. Then people will be able to aid in
>> solving your problem.


If you do that for the case that you claims "does not match" that
expression, then we can help figure it out.

If you don't, we can't.


> I forgot to put the / in my example above, but it is the complete
> expression.  I am trying ot match a URL 


Then aren't there some angle brackets or something else in the
pattern that you are actually using?


> for url rewriting.  One of the
> products has the format like My Fictional Co. but it won't match it.


Yes it will.

Your pattern above will match every possible string!

Show real code along with real data in order to receive real help.


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


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

Date: Wed, 1 Nov 2006 20:22:45 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regular Expression Question Why Doesn't this Match?
Message-Id: <slrnekiljl.l61.tadmc@tadmc30.august.net>

jm <needin4mation@gmail.com> wrote:
>
> Dr.Ruud wrote:
>> jm schreef:
>>
>> > /([\w\s\.\'\-]*)
>>
>> thaT iS brokeN.
>>
>>
>> > does not match this:
>> >
>> >     My Fictional Co.
>>
>> witH thE missinG enD-slasH addeD, it doeS:
>>
>> echo 'My Fictional Co.' |
>>   perl -nwle '/([\w\s.\x27-]*)/ and print qq{<$1>}'
>>
>> This prints:
>> <My Fictional Co.>
>>
>> --
> Another URL that doesn't match has the format:
>
> A.B.C.D.  Just won't match it.


It works for me:

---------------------------
#!/usr/bin/perl
use warnings;
use strict;

$_ = 'A.B.C.D.';
print "matched\n" if /([\w\s\.\'\-]*)/;
---------------------------


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


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

Date: 1 Nov 2006 21:49:27 -0800
From: "The alMIGHTY N" <natlee75@yahoo.com>
Subject: SQLPlus with Perl
Message-Id: <1162446567.598483.288770@h54g2000cwb.googlegroups.com>

Hi all,

I've been assigned a project involving SQLplus calls to an Oracle
database within Perl code. I have examples of how to perform insert and
update statements that don't return anything back to the code, but I
now need to perform a select statement to check values in the database.

How would I go about executing SQLplus calls and assigning the results
to a Perl string or array?

Thanks for any help.

Please e-mail me at nlee@solbright.com if possible.

Thanks again!

Nathaniel



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

Date: 1 Nov 2006 21:21:33 -0800
From: "gavino" <bootiack@yahoo.com>
Subject: Thank you jim for #perl on freenode (im banned at home) for helping me get aolserver going
Message-Id: <1162444893.636993.33640@m73g2000cwd.googlegroups.com>

jim u the man!



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

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


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