[28973] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 217 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 12 14:09:51 2007

Date: Mon, 12 Mar 2007 11:09:09 -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           Mon, 12 Mar 2007     Volume: 11 Number: 217

Today's topics:
    Re: ${{ foo => bar, baz => faz }}{ baz } <uri@stemsystems.com>
    Re: ${{ foo => bar, baz => faz }}{ baz } <uri@stemsystems.com>
    Re: ${{ foo => bar, baz => faz }}{ baz } <bik.mido@tiscalinet.it>
    Re: Array Ref Error <zen13097@zen.co.uk>
        Convert hex to bin <Klaus.Sulzberger@de.bosch.com>
    Re: Convert hex to bin <abigail@abigail.be>
    Re: Convert hex to bin <bik.mido@tiscalinet.it>
    Re: Convert hex to bin <bik.mido@tiscalinet.it>
    Re: Convert hex to bin <paduille.4060.mumia.w+nospam@earthlink.net>
    Re: Convert hex to bin <bik.mido@tiscalinet.it>
        Daylight Savings using timelocal() and localtime() <Datamon@gmail.com>
    Re: Equivalent in Perl xhoster@gmail.com
    Re: Equivalent in Perl <pankaj_wolfhunter@yahoo.co.in>
    Re: Equivalent in Perl <tzz@lifelogs.com>
    Re: Equivalent in Perl xhoster@gmail.com
        Find Missing Column and Extra Column <sahoo.byomokesh@gmail.com>
    Re: Find Missing Column and Extra Column <scobloke2@infotop.co.uk>
    Re: Find Missing Column and Extra Column <bik.mido@tiscalinet.it>
        Flush buffer combined with mod_deflate doesn't seem to  <leifwessman@hotmail.com>
    Re: Flush buffer combined with mod_deflate doesn't seem xhoster@gmail.com
    Re: invoking system commands from a perl script (Jamie)
    Re: invoking system commands from a perl script <uri@stemsystems.com>
    Re: Non-blocking directory watching <mmundy1@gmail.com>
    Re: Non-blocking directory watching <mmundy1@gmail.com>
        passing passords to pgsql/pg_create/pg_dump programmati <filippo2991@virgilio.it>
    Re: passing passords to pgsql/pg_create/pg_dump program <glex_no-spam@qwest-spam-no.invalid>
        Recomended Frameworks and Modules for REST (aka ? the Platypus)
    Re: Recomended Frameworks and Modules for REST (Marc Espie)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 12 Mar 2007 09:35:53 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: ${{ foo => bar, baz => faz }}{ baz }
Message-Id: <x7k5xmv8ae.fsf@mail.sysarch.com>

>>>>> "BL" == Bo Lindbergh <blgl@stacken.kth.se> writes:

  BL> In article <x7ps7fwdtd.fsf@mail.sysarch.com>, Uri Guttman <uri@stemsystems.com> 
  BL> wrote:

  >> $href->{$foo,$bar}{qw( abc xyz )}
  >> 
  >> a reasonable guess would be a multilevel hash slice but that means
  >> multiple internal loops, plenty of calls to malloc and such.

  BL> No, a reasonable guess would be to do the same thing today's Perl does when
  BL> &$cref in the example below returns multiple values:

  BL>     $cref->($foo)->{qw(abc xyz)}

  BL> (For the lazy: the function is called in scalar context, i.e. if
  BL> it tries to return multiple values only the last one is used.)

and that is a function call and not a deep multilevel hash slice. apples
vs oranges.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Mon, 12 Mar 2007 09:39:02 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: ${{ foo => bar, baz => faz }}{ baz }
Message-Id: <x7fy8av855.fsf@mail.sysarch.com>

>>>>> "MD" == Michele Dondi <bik.mido@tiscalinet.it> writes:

  MD> On Sun, 11 Mar 2007 18:38:54 -0500, Uri Guttman <uri@stemsystems.com>
  MD> wrote:

  >> it might work ok at the shallow top level there, but when you get deeper
  >> is when it gets ugly and hard to manage. what does this return?
  >> 
  >> $href->{$foo,$bar}{qw( abc xyz )}

  MD> Well, what does this return?

  MD>        $aref->[$foo,$bar][1..3]

my question was more rhetorical than real. my point is that the
semantics of deep slicing aren't clear (they took a while to hammer out
in p6). and if you did want the deep multilevel slicing to work it would
need complex semantics and implementation to handle all the
variations. the jump from p4 to p5 and adding refs and top level slices
was pretty big. adding multilevel slices maybe was too much for larry to
worry about and code. in any case the point in moot since p5 will never
have it.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Mon, 12 Mar 2007 17:42:55 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: ${{ foo => bar, baz => faz }}{ baz }
Message-Id: <tg0bv2p8305jambfrbr276bee5sdmhslg2@4ax.com>

On Mon, 12 Mar 2007 09:39:02 -0500, Uri Guttman <uri@stemsystems.com>
wrote:

>  >> is when it gets ugly and hard to manage. what does this return?
>  >> 
>  >> $href->{$foo,$bar}{qw( abc xyz )}
>
>  MD> Well, what does this return?
>
>  MD>        $aref->[$foo,$bar][1..3]
>
>my question was more rhetorical than real. my point is that the

Mine too.

>semantics of deep slicing aren't clear (they took a while to hammer out
>in p6). and if you did want the deep multilevel slicing to work it would
>need complex semantics and implementation to handle all the

Mine, that it "shouldn't" be supported at all, just as with arrayrefs,
but thay top-level slicing would be more intuitive than the
pseudo-multidimensional interpretation. Of course we're discussing
even too much about these issues, since the situation is this and I
don't expect it to be changed. Only, I can't avoid asking myself why
that choice was made in the first place.


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: 12 Mar 2007 10:54:50 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: Array Ref Error
Message-Id: <45f5317a$0$2456$db0fefd9@news.zen.co.uk>


Unrelated to your question, but you have a problem passing parameters
to your subroutines.

On 9 Mar 2007 16:54:23 -0800, doni <doni.sekar@gmail.com> wrote:
>      chomp;
>      if (/rfrouted/i) {
>          route($_);
>      }
>      elsif (/gwd/i) {
>          gw_route($_);

Ok - you have a value in (the global variable) $_, which you pass to a
subroutine. So far, so good.

> 
>  ### GWD SUBROUTINE ###
>  sub gw_route {
>      my (@received_message) = @_;

The value you passed in is in the first element of @_.
You put this in @received_message.

>      @received_message = split;

You now ignore what you just put in @reecived message and overwrite
it, by splitting (the global variable) $_

>      if (/Got ROUTE_UPDATE/i) {

Again, you're matching against the global $_.


You probably want something more along these lines:

   sub gw_route {
       my ($message) = @_;

       my @received_message = split $message;

       if ($message =~ /Got ROUTE_UPDATE/i) {
        ... etc ...




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

Date: Mon, 12 Mar 2007 13:48:16 +0100
From: "Klaus Sulzberger" <Klaus.Sulzberger@de.bosch.com>
Subject: Convert hex to bin
Message-Id: <et3hku$oq7$1@news4.fe.internet.bosch.com>

Follwing function convert Hex to bin:

sub hex2bin
{
   my $str=unpack("B32",pack("N",hex$_[0]));
   $str=~s/^0+(?=\d)//;
   return($str);
}

The problem of the function is, that the result cuts the zeros.

For examples:

Hex: 7D
Function result:   1111101
Want to have:   01111101
(for 1 Byte)




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

Date: 12 Mar 2007 12:52:58 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Convert hex to bin
Message-Id: <slrnevaj8h.1af.abigail@alexandra.abigail.be>

Klaus Sulzberger (Klaus.Sulzberger@de.bosch.com) wrote on MMMMCMXLI
September MCMXCIII in <URL:news:et3hku$oq7$1@news4.fe.internet.bosch.com>:
:}  Follwing function convert Hex to bin:
:}  
:}  sub hex2bin
:}  {
:}     my $str=unpack("B32",pack("N",hex$_[0]));
:}     $str=~s/^0+(?=\d)//;
:}     return($str);
:}  }
:}  
:}  The problem of the function is, that the result cuts the zeros.

Well, don't do it then!

:}  For examples:
:}  
:}  Hex: 7D
:}  Function result:   1111101
:}  Want to have:   01111101
:}  (for 1 Byte)


Is your posting the Perl equivalent of the joke of the man going to
the doctor saying "my head hurts when I bang it against the wall"?


Abigail
-- 
#!/opt/perl/bin/perl -w
$\ = $"; $SIG {TERM} = sub {print and exit};
kill 15 => fork for qw /Just another Perl Hacker/;


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

Date: Mon, 12 Mar 2007 15:09:00 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Convert hex to bin
Message-Id: <rlnav29u4q2o4s65csd1och969vfi3qpk6@4ax.com>

On 12 Mar 2007 12:52:58 GMT, Abigail <abigail@abigail.be> wrote:

>Is your posting the Perl equivalent of the joke of the man going to
>the doctor saying "my head hurts when I bang it against the wall"?

I think he found the function ready made, and hardly grasps what it
does. In which case he should have said so. This is not a helpdesk
anyway. ++ for the fun!


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: Mon, 12 Mar 2007 15:11:34 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Convert hex to bin
Message-Id: <5onav2d8u5k9co3vsg6745ukbsk3spa698@4ax.com>

On Mon, 12 Mar 2007 13:48:16 +0100, "Klaus Sulzberger"
<Klaus.Sulzberger@de.bosch.com> wrote:

>sub hex2bin
>{
>   my $str=unpack("B32",pack("N",hex$_[0]));
>   $str=~s/^0+(?=\d)//;
>   return($str);
>}
>
>The problem of the function is, that the result cuts the zeros.

Putting '#' (without quotes) in front of one of those lines will do
what you want. Since the lines are three, you may find the right one
by trial. Incidentally, once you have done so you may avoid the $str
variable altogether, and the sub may consist of a single statement.
This is left as an exercise, of course.


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: Mon, 12 Mar 2007 14:56:23 GMT
From: "Mumia W." <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: Convert hex to bin
Message-Id: <rSdJh.126567$_73.118125@newsread2.news.pas.earthlink.net>

On 03/12/2007 07:48 AM, Klaus Sulzberger wrote:
> Follwing function convert Hex to bin:
> 
> sub hex2bin
> {
>    my $str=unpack("B32",pack("N",hex$_[0]));
>    $str=~s/^0+(?=\d)//;
>    return($str);
> }
> 
> The problem of the function is, that the result cuts the zeros.
> 
> For examples:
> 
> Hex: 7D
> Function result:   1111101
> Want to have:   01111101
> (for 1 Byte)
> 
> 
     sub hex2bin {
         unpack 'B8', pack 'H2', $_[0];
     }

The "perldoc -f pack" command describes the format strings.





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

Date: Mon, 12 Mar 2007 17:44:06 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Convert hex to bin
Message-Id: <op0bv2dnjr2tfudte5d01bcp7203vk2sl0@4ax.com>

On Mon, 12 Mar 2007 14:56:23 GMT, "Mumia W."
<paduille.4060.mumia.w+nospam@earthlink.net> wrote:

>     sub hex2bin {
>         unpack 'B8', pack 'H2', $_[0];
>     }
>
>The "perldoc -f pack" command describes the format strings.

Naaah, you spoon-fed him at last!  :-)


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: 12 Mar 2007 10:53:51 -0700
From: "Datamon" <Datamon@gmail.com>
Subject: Daylight Savings using timelocal() and localtime()
Message-Id: <1173722031.073632.53830@30g2000cwc.googlegroups.com>

When I run the script below on a windoze 2000 desktop with the latest
ms dst patch, I get:

D>dstest.pl 060301
060301 IS NOT in DLS
# which is correct

D>dstest.pl 060401
060401 IS in DLS
# which is WRONG (060402 was the start of DLS last year, so 060401 was
prior to DLS).

It looks like msoft changed the 'first Sunday in April' (old rule) to
'second Sunday in March' (new rule) for ALL years...

I have a solution if anyone is interested.

(file saved as dstest.pl)
#!/usr/bin/perl -w

use strict;
use Time::Local;

my ($stdate, $indls);

$stdate = shift;
if ( ! defined $stdate ) {
	print "Enter a date string as YYMMDD: ";
	$stdate = <>;
}
chomp ( $stdate );
$indls = InDls ( $stdate );
printf "%s %s in DLS\n", $stdate, $indls ? "IS" : "IS NOT";

exit;

#------------------------------------------------------------------------------
# This routine determines if NOON on YYMMDD is in DLS
# I suspect it uses an ms function or dll as it's functionality
changed
# after implementing the recent ms DLS patch...
sub InDls {
    my ( $yymmdd ) = @_;
    die "$yymmdd is an invalid date!\n" if ( length ( $yymmdd ) !=
6 );
    my ($yy, $mm, $dd) = unpack ( "a2 a2 a2", $yymmdd );
    my @ts = ( 0, 0, 12, $dd, $mm-1, $yy );
    my $nt = timelocal ( @ts );     # convert to seconds since epoch
    @ts = localtime ( $nt );        # convert back to components
    return ( $ts[8] );              # return 'Is DST' (9th element)
}  # InDls



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

Date: 12 Mar 2007 15:14:30 GMT
From: xhoster@gmail.com
Subject: Re: Equivalent in Perl
Message-Id: <20070312111431.544$5V@newsreader.com>

"pankaj_wolfhunter@yahoo.co.in" <pankaj_wolfhunter@yahoo.co.in> wrote:
> Greetings,
>
>                 Whats the equivalent for the following code in perl:
>
> sqlplus -s orauser/orapass@oadb << eof > output_file.txt
> some oracle queries
> exit;
> eof;
>
> I did this using  "system" command.

That *is* the equivalent in Perl.

> We've been told to do this using DBI or some other method?

Was that a statement or a question?  Why were you told this?
If you were told this for a reason, that reason matters.

> I tried with DBI but the problem is I dont know how to redirect the
> oracle output to
> to a file (outout_file.txt) instead of console.

You use DBI when you want the data to come into Perl (from where you can
wrangle and format and print to your heart's content--just like you can
with any other data in Perl).  If you just want it sent to a file exactly
the way sqlplus does it, then just use system and sqlplus.

Xho

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


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

Date: 12 Mar 2007 08:58:09 -0700
From: "pankaj_wolfhunter@yahoo.co.in" <pankaj_wolfhunter@yahoo.co.in>
Subject: Re: Equivalent in Perl
Message-Id: <1173715089.776431.39370@v33g2000cwv.googlegroups.com>

On Mar 12, 8:14 pm, xhos...@gmail.com wrote:
> "pankaj_wolfhun...@yahoo.co.in" <pankaj_wolfhun...@yahoo.co.in> wrote:
> > Greetings,
>
> >                 Whats the equivalent for the following code in perl:
>
> > sqlplus -s orauser/orapass@oadb << eof > output_file.txt
> > some oracle queries
> > exit;
> > eof;
>
> > I did this using  "system" command.
>
> That *is* the equivalent in Perl.
>
> > We've been told to do this using DBI or some other method?
>
> Was that a statement or a question?  Why were you told this?
> If you were told this for a reason, that reason matters.
>
> > I tried with DBI but the problem is I dont know how to redirect the
> > oracle output to
> > to a file (outout_file.txt) instead of console.
>
> You use DBI when you want the data to come into Perl (from where you can
> wrangle and format and print to your heart's content--just like you can
> with any other data in Perl).  If you just want it sent to a file exactly
> the way sqlplus does it, then just use system and sqlplus.
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> Usenet Newsgroup Service                        $9.95/Month 30GB

Thanks Xho.
> Was that a statement or a question

That was a statement.

Still if we need to convert the above code using DBI, how'll that be.
Actually I tried myself but couldnt get through.




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

Date: Mon, 12 Mar 2007 13:28:11 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Equivalent in Perl
Message-Id: <g69zm6is76c.fsf@dhcp-65-162.kendall.corp.akamai.com>

On 12 Mar 2007 02:42:50 -0700 "pankaj_wolfhunter@yahoo.co.in" <pankaj_wolfhunter@yahoo.co.in> wrote: 

pwci>                 Whats the equivalent for the following code in perl:

pwci> sqlplus -s orauser/orapass@oadb << eof > output_file.txt
pwci> some oracle queries
pwci> exit;
pwci> eof;

pwci> I did this using  "system" command.
pwci> We've been told to do this using DBI or some other method?

pwci> I tried with DBI but the problem is I dont know how to redirect
pwci> the oracle output to to a file (outout_file.txt) instead of
pwci> console.

You are confusing DBI with something else.  DBI lets you make SQL
queries inside Perl, `sqlplus' is never involved.  You need to rewrite
your queries to do the right thing inside Perl, essentially.  Either
learn DBI programming from one of the many online tutorials, or hire
someone who understands the topic.

Ted


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

Date: 12 Mar 2007 18:01:24 GMT
From: xhoster@gmail.com
Subject: Re: Equivalent in Perl
Message-Id: <20070312140126.622$Zz@newsreader.com>

"pankaj_wolfhunter@yahoo.co.in" <pankaj_wolfhunter@yahoo.co.in> wrote:
> >
> > > sqlplus -s orauser/orapass@oadb << eof > output_file.txt
> > > some oracle queries
> > > exit;
> > > eof;
> >
>
> Still if we need to convert the above code using DBI, how'll that be.
> Actually I tried myself but couldnt get through.

I would start by reading the DBI docs, or maybe a book about using DBI.
Surely you don't expect us to read the DBI docs to you, or just retype the
docs into usenet, right?

What did you try and what problems did you encounter?

Did you establish a connection?  If so, did you prepare and execute a
query? If so, did you get the results?  If so, do you know how to use join
and print? If so, then what is left to be done?

Xho

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


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

Date: 12 Mar 2007 03:31:29 -0700
From: "Rahul" <sahoo.byomokesh@gmail.com>
Subject: Find Missing Column and Extra Column
Message-Id: <1173695489.128290.85490@64g2000cwx.googlegroups.com>

Hi All,

This XML file is 2 errors. My table is 3 columns. One is extra column
and another is missing one columne. How i will find those error
through perl script.

XML file
------------
<table>
<tgroup cols="3">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<colspec colnum="3" colname="col3"/>
<tbody>
<row>
<entry valign="top" align="left"><p>nada</p></entry>
<entry valign="top" align="left"><p>nothing</p></entry>
<entry valign="top" align="left"><p>nada.</p></entry>
<entry valign="top" align="left"><p></p></entry>  <!-- One Row Extra
Here -->
</row>
<row>
<entry valign="top" align="left" namest="col1"
nameend="col2"><p>centra</p></entry>
<!-- One row is missing here -->
</row>
</tbody>
</tgroup>
</table>

Thanks for any help.
Byomokesh



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

Date: Mon, 12 Mar 2007 12:27:02 +0000
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Find Missing Column and Extra Column
Message-Id: <45f54719$0$2445$db0fefd9@news.zen.co.uk>

Rahul wrote:
> Hi All,
> 
> This XML file is 2 errors. My table is 3 columns. One is extra column
> and another is missing one columne. How i will find those error
> through perl script.

I'd use XML::SAX and count the columns.

If you need to validate against a DTD/XSD/RelaxNG schema then you might 
want to search CPAN for something suitable.

> 
> XML file
> ------------
> <table>
> <tgroup cols="3">
> <colspec colnum="1" colname="col1"/>
> <colspec colnum="2" colname="col2"/>
> <colspec colnum="3" colname="col3"/>
> <tbody>
> <row>
> <entry valign="top" align="left"><p>nada</p></entry>
> <entry valign="top" align="left"><p>nothing</p></entry>
> <entry valign="top" align="left"><p>nada.</p></entry>
> <entry valign="top" align="left"><p></p></entry>  <!-- One Row Extra
> Here -->
> </row>
> <row>
> <entry valign="top" align="left" namest="col1"
> nameend="col2"><p>centra</p></entry>
> <!-- One row is missing here -->
> </row>
> </tbody>
> </tgroup>
> </table>

Your XML looks rather like XHTML, maybe you could use an XHTML validator 
(or search CPAN for suitable modules).


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

Date: Mon, 12 Mar 2007 14:59:35 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Find Missing Column and Extra Column
Message-Id: <k3nav25ftm8qd4dkg4os4qmh7ubtnfl3f0@4ax.com>

On 12 Mar 2007 03:31:29 -0700, "Rahul" <sahoo.byomokesh@gmail.com>
wrote:

>This XML file is 2 errors. My table is 3 columns. One is extra column
>and another is missing one columne. How i will find those error
>through perl script.

Why do you think that reposting what's basically the same question
discussed in another thread as a new one is going to help you?


PS: well done, eventually preparing a reasonably complete xml
example...


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: 12 Mar 2007 06:48:51 -0700
From: "Leif Wessman" <leifwessman@hotmail.com>
Subject: Flush buffer combined with mod_deflate doesn't seem to work
Message-Id: <1173707331.019681.311260@v33g2000cwv.googlegroups.com>


I'm trying to print a html header, then flush the buffer and then
print the rest of the page. Like this:

print "header\n";
$| = 1;
print "\n";
sleep 10;
$| = 0;
print "content\n";

header contains more than 8096 bytes (default buffer size according to
http://httpd.apache.org/docs/2.0/mod/mod_deflate.html).

This works fine (header shows immediately, content after 10 seconds)
when _not_ using mod_deflate. When using mod_deflate both header and
content shows after 10 seconds...

What could be the problem?



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

Date: 12 Mar 2007 15:16:26 GMT
From: xhoster@gmail.com
Subject: Re: Flush buffer combined with mod_deflate doesn't seem to work
Message-Id: <20070312111627.535$Ly@newsreader.com>

"Leif Wessman" <leifwessman@hotmail.com> wrote:
> I'm trying to print a html header, then flush the buffer and then
> print the rest of the page. Like this:
>
> print "header\n";
> $| = 1;
> print "\n";
> sleep 10;
> $| = 0;
> print "content\n";
>
> header contains more than 8096 bytes (default buffer size according to
> http://httpd.apache.org/docs/2.0/mod/mod_deflate.html).
>
> This works fine (header shows immediately, content after 10 seconds)
> when _not_ using mod_deflate. When using mod_deflate both header and
> content shows after 10 seconds...
>
> What could be the problem?

The problem is related to Apache or your web browser, not the Perl itself.

Xho

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


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

Date: Mon, 12 Mar 2007 11:11:17 GMT
From: nospam@geniegate.com (Jamie)
Subject: Re: invoking system commands from a perl script
Message-Id: <Lc117367732743220x8b15dcc@pong.podro.com>

In <1173627021.574379.153870@q40g2000cwq.googlegroups.com>,
"vabby" <vaibhav.aparimit@gmail.com> mentions:
>so using backticks or system is teh same thing except when you want to
>capture the result value of teh command. my idea of asking the
>question was that somebody told me , that using system to execute unix
>commands, is the synchronous way of doing it, and using backticks the
>asynchronous way

Backtics are a sort of hackish way to get the output of the command (output
as in, standard output, NOT the result)

They're like the shell counterparts. In a standard shell, you can:

-------------- shell ----------
TOP=`pwd`
echo $TOP
 ------------------------------


In perl, you can also do this:

	open(PIPE,"pwd |");
	while(<PIPE>){
		... 
	}
	close(PIPE);

Have to be a little careful with backtics. (actually, I sort of wish perl
didn't have them as they are confusing with ') 

To get the "result", (error code) you want to look at the $? variable, sorta
like this:

	my $rc = ($? >> 8);


They all involve forking (at least on a unix platform) the difference is,
things like backtics or system will wait() for the process to terminate
before returning control back to you. This is generally what you want, if
your task can't resume until something is done by the system.

fork() and open(PIPE,"command_name |"); will launch the process and then
return to you before the command completes. (in the above case, close()
waits for the command to complete) This allows you to process the data
from the shell command "as it happens" as opposed to "all at once".


Jamie
-- 
http://www.geniegate.com                    Custom web programming
Perl * Java * UNIX                        User Management Solutions


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

Date: Mon, 12 Mar 2007 09:46:36 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: invoking system commands from a perl script
Message-Id: <x7bqiyv7sj.fsf@mail.sysarch.com>

>>>>> "J" == Jamie  <nospam@geniegate.com> writes:

  J> Backtics are a sort of hackish way to get the output of the command (output
  J> as in, standard output, NOT the result)

hackish??? they are a perfectly normal and proper way to get all the
stdout of a subprocess.

  J> They're like the shell counterparts. In a standard shell, you can:

they were totally borrowed/stolen from the shell. like many other perl
features were.

  J> Have to be a little careful with backtics. (actually, I sort of
  J> wish perl didn't have them as they are confusing with ')

so use qx() instead. hard to confuse those with single quotes.


  J> To get the "result", (error code) you want to look at the $?
  J> variable, sorta like this:

  J> 	my $rc = ($? >> 8);

why sorta?? i wouldn't call that the "result" either as few programs use
the exit code (not error code) for real communication. a typical
subprocess called under qx will just send output to stdout.

  J> They all involve forking (at least on a unix platform) the difference is,
  J> things like backtics or system will wait() for the process to terminate
  J> before returning control back to you. This is generally what you want, if
  J> your task can't resume until something is done by the system.

  J> fork() and open(PIPE,"command_name |"); will launch the process and then
  J> return to you before the command completes. (in the above case, close()
  J> waits for the command to complete) This allows you to process the data
  J> from the shell command "as it happens" as opposed to "all at once".

and in most common subprocess cases there won't be much difference. the
choice is more about how much output is generated (due to buffering
needs) and how long the subprocess takes to run. some bigger differences
is whether the shell is invoked in the middle and that open |'s exit
code is returned by close. and you still need the same >>8 stuff to get
the "exit" code.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 12 Mar 2007 08:34:04 -0700
From: "Matthew" <mmundy1@gmail.com>
Subject: Re: Non-blocking directory watching
Message-Id: <1173713349.473791.116940@q40g2000cwq.googlegroups.com>

Naw.  I too am polling at the moment.  This was more of a curiosity
question in the hopes of adding to my knowledge.

Thanks.
---Matthew
On Mar 9, 2:41 pm, xhos...@gmail.com wrote:
> "Matthew" <mmun...@gmail.com> wrote:
> > Hello all.
>
> > Is there a way to watch a directory for files w/o blocking?  I was
> > hoping there was something similar to select but I have found nothing.
>
> I can't think of a way of watching a directory *with* blocking (I'd just do
> polling which may be inefficient but doesn't block waiting for a change to
> happen).  If you have such a method (efficient but blocking) in mind and
> you share it with us, I might be able to help you make it nonblocking.
>
> > inotify will not work b/c of the linux kernel requirement.  I'd like
> > to stay cross-platform
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> Usenet Newsgroup Service                        $9.95/Month 30GB




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

Date: 12 Mar 2007 09:15:37 -0700
From: "Matthew" <mmundy1@gmail.com>
Subject: Re: Non-blocking directory watching
Message-Id: <1173713280.897653.71950@p10g2000cwp.googlegroups.com>

Naw.  I too am polling at the moment.  This was more of a curiosity
question in the hopes of adding to my knowledge.

Thanks.
---Matthew
On Mar 9, 2:41 pm, xhos...@gmail.com wrote:
> "Matthew" <mmun...@gmail.com> wrote:
> > Hello all.
>
> > Is there a way to watch a directory for files w/o blocking?  I was
> > hoping there was something similar to select but I have found nothing.
>
> I can't think of a way of watching a directory *with* blocking (I'd just do
> polling which may be inefficient but doesn't block waiting for a change to
> happen).  If you have such a method (efficient but blocking) in mind and
> you share it with us, I might be able to help you make it nonblocking.
>
> > inotify will not work b/c of the linux kernel requirement.  I'd like
> > to stay cross-platform
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> Usenet Newsgroup Service                        $9.95/Month 30GB




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

Date: 12 Mar 2007 10:22:19 -0700
From: "filippo" <filippo2991@virgilio.it>
Subject: passing passords to pgsql/pg_create/pg_dump programmatically
Message-Id: <1173720138.960358.83320@t69g2000cwt.googlegroups.com>

Hello,

I have written a program perl/Tkprogram, based on postgres. For
maintenance reasons in my program I use these commands:

      `dropdb -U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;
      `createdb -U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;
      `pg_dump -U postgres -h $DATABASE_SERVER $DATABASE_NAME | psql -
U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;

my @psqlOutput = `psql -l -U postgres -h $_`;


my program has a graphic interface but whenever I use these command,
postgres ask for passord in the command line. How can I give these
commands the right passowrd programmatically or how can I   interact
with these to give the passwords by a graphic box?

Thanks and best refards,

Filippo



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

Date: Mon, 12 Mar 2007 12:01:40 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: passing passords to pgsql/pg_create/pg_dump programmatically
Message-Id: <45f595c1$0$501$815e3792@news.qwest.net>

filippo wrote:
> Hello,
> 
> I have written a program perl/Tkprogram, based on postgres. For
> maintenance reasons in my program I use these commands:
> 
>       `dropdb -U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;
>       `createdb -U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;
>       `pg_dump -U postgres -h $DATABASE_SERVER $DATABASE_NAME | psql -
> U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;
> 
> my @psqlOutput = `psql -l -U postgres -h $_`;
> 
> 
> my program has a graphic interface but whenever I use these command,
> postgres ask for passord in the command line. How can I give these
> commands the right passowrd programmatically or how can I   interact
> with these to give the passwords by a graphic box?

Read the documentation for those commands to determine how the user
name and/or password is passed, then add the options and values to your 
program.  Since you wrote the above code, you should be able to figure
out how to add another option and value.


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

Date: Mon, 12 Mar 2007 11:47:40 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@dformosa.zeta.org.au>
Subject: Recomended Frameworks and Modules for REST
Message-Id: <slrnevag34.90f.dformosa@localhost.localdomain>

I currently investigating using the REST archtectural style for my
next project.  I've found REST::Application on CPAN but I'm wondering
if its the most recomended or are there better modules out there.


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

Date: Mon, 12 Mar 2007 12:29:43 +0000 (UTC)
From: espie@lain.home (Marc Espie)
Subject: Re: Recomended Frameworks and Modules for REST
Message-Id: <et3h3n$ut8$1@biggoron.nerim.net>

In article <slrnevag34.90f.dformosa@localhost.localdomain>,
David Formosa (aka ? the Platypus) <dformosa@dformosa.zeta.org.au> wrote:
>I currently investigating using the REST archtectural style for my
>next project.  I've found REST::Application on CPAN but I'm wondering
>if its the most recomended or are there better modules out there.

I have not played with REST myself, but Catalyst includes some rest support
(Catalyst::Action::REST).

Confere

http://www.catalystframework.org/calendar/2006/9

for an example 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 V11 Issue 217
**************************************


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