[29088] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 332 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 13 14:10:00 2007

Date: Fri, 13 Apr 2007 11:09:07 -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, 13 Apr 2007     Volume: 11 Number: 332

Today's topics:
    Re: Absolute Path errors <bik.mido@tiscalinet.it>
    Re: Absolute Path errors <bik.mido@tiscalinet.it>
    Re: Extracting text between two market lines. (FAQ vari <scobloke2@infotop.co.uk>
    Re: Extracting text between two market lines. (FAQ vari <paduille.4061.mumia.w+nospam@earthlink.net>
    Re: How to change decimal point ',' to decimal comma ', <nobull67@gmail.com>
    Re: My script to download YouTube videos (critique want <bik.mido@tiscalinet.it>
        perl print form without linefeeds lratzan@gmail.com
    Re: perl print form without linefeeds usenet@DavidFilmer.com
    Re: perl print form without linefeeds <nobull67@gmail.com>
    Re: perl regular expression <wahab-mail@gmx.de>
    Re: perl regular expression <wahab-mail@gmx.de>
    Re: perl regular expression <wahab-mail@gmx.de>
    Re: Print Subject without characters Just Numbers using <julises@gmail.com>
    Re: Search Replace using Hash -p0777 <rvtol+news@isolution.nl>
        Splitting a string with placeholders <bcc@nospam.net>
    Re: Splitting a string with placeholders <someone@example.com>
    Re: Splitting a string with placeholders <jurgenex@hotmail.com>
    Re: Splitting a string with placeholders <purlgurl@purlgurl.net>
    Re: Splitting a string with placeholders <bcc@nospam.net>
    Re: Splitting a string with placeholders <bcc@nospam.net>
    Re: Splitting a string with placeholders <wahab-mail@gmx.de>
    Re: Top Turds of comp.lang.perl.misc (2007) <sigzero@gmail.com>
        XML parsing using PERL.... URGENT <ramesh9999@gmail.com>
    Re: XML parsing using PERL.... URGENT <ignoramus10909@NOSPAM.10909.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 13 Apr 2007 19:51:35 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Absolute Path errors
Message-Id: <3ggv1312b0kah3kipc742nhtsskqenimv4@4ax.com>

On 13 Apr 2007 02:00:24 -0700, "skieros" <nikos1337@gmail.com> wrote:

>So although the path were relative Apache can locate them and Perl
>open() them with the use of the OS. No?!

I think you are still confusing URLs and paths. URLs are designed to
look somewhat like paths. This allows for easily transforming them, in
some cases, into actual paths. Think of the webserver as of an
interface: on the one side of it you have URLs, on the other one,
paths. There's no rule a priori that maps exactly one URL to a given
path and vice versa. When a given URL points to a page that is
actually dinamically generated by a program it *can happen* that an
URL relative to that base URL can also be used *verbatim* as a
relative path with respect to that particular program. This is exactly
what you had in the first case. But it's *not* generally the case.


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: Fri, 13 Apr 2007 19:53:49 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Absolute Path errors
Message-Id: <ppgv13hthj7buqntb79363hilinbfkht2n@4ax.com>

On 13 Apr 2007 02:03:54 -0700, "skieros" <nikos1337@gmail.com> wrote:

>> What happens in both cases can be known if index.pl informs of it's
>> current work directory
>
>Yes, maybe...
>
>Because i cannot else explain how Apache could locate all files for
>opening with the redirection method and after removed the redirection
>it couldnt.....

To put it briefly: COINCIDENCE!

>If it could in the first place it can locate them and i can use them
>with relative apth only.

You can still use relative paths, provided you massage them a little
as duly explained by another poster. That would only require a
negligible amount of effort.


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: Fri, 13 Apr 2007 17:28:35 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Extracting text between two market lines. (FAQ variation?)
Message-Id: <461fafbc$0$6951$fa0fcedb@news.zen.co.uk>

Ian Wilson wrote:
> The following program extracts a portion of text between two marker lines.
<snip>
> I've read the FAQ. I'm unsure how best to modify this so that the 
> extracted text omits the markers.
> My best attempt:
<snip>
> Anyone have suggestions for "better", clearer or more succinct code?

Thanks Anno, Abigail.


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

Date: Fri, 13 Apr 2007 17:57:54 GMT
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Extracting text between two market lines. (FAQ variation?)
Message-Id: <CwPTh.2598$3P3.816@newsread3.news.pas.earthlink.net>

On 04/13/2007 05:43 AM, Ian Wilson wrote:
> The following program extracts a portion of text between two marker lines.
> 
> ----------------------------------8<------------------------------
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> my $cert;
> while(<DATA>) {
>   $cert .= $_ if /BEGIN CERTIFICATE/ .. /END CERTIFICATE/;
> }
> 
> print "*** cert is [$cert] ***\n";
> 
> __DATA__
> foo
> bar
> -----BEGIN CERTIFICATE-----
> This is a certificate
> it has several lines
> this is the last
> -----END CERTIFICATE-----
> whizz
> bang
> ------------------------------------------------------------------
> 
> I've read the FAQ. I'm unsure how best to modify this so that the 
> extracted text omits the markers.
> My best attempt:
> 
> ----------------------------------8<------------------------------
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> my $cert;
> while(<DATA>) { $cert .= $_; }
> $cert =~ s/.*BEGIN CERTIFICATE-----\n(.*)\n-----END CERT.*/$1/s;
> 
> print "*** cert is [$cert] ***\n";
> 
> __DATA__
> foo
> bar
> -----BEGIN CERTIFICATE-----
> This is a certificate
> it has several lines
> this is the last
> -----END CERTIFICATE-----
> whizz
> bang
> ------------------------------------------------------------------
> 
> Anyone have suggestions for "better", clearer or more succinct code?
> ~

It's definitely not succinct, but this is another option:

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

my $cert;
while(<DATA>) {
   do {
     $cert .= $_ unless /(BEGIN|END) CERTIFICATE/;
   } if /BEGIN CERTIFICATE/ .. /END CERTIFICATE/;
}

print "*** cert is [$cert] ***\n";

__UNTESTED_CODE__


-- 
Count the YOYOs:
http://home.earthlink.net/~mumia.w.18.spam/games_fever/


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

Date: 13 Apr 2007 10:22:39 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: How to change decimal point ',' to decimal comma ','
Message-Id: <1176484959.783915.224060@o5g2000hsb.googlegroups.com>

On Apr 13, 1:09 pm, "PERO" <p...@pero.pero> wrote:
> How to change decimal point ',' to decimal comma ','
>
> eg:
>
> $num=1345,25;
> TNX

There is AFAIK no way to get Perl to recognise a decimal comma in
numeric literals in Perl source code.

If you are talking about _data_ not _code_ then the locale-based
solutions or simple string manipulations will do the trick. For string
manipulations I'd use tr/./,/ rather than s/\./,/.



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

Date: Fri, 13 Apr 2007 20:01:24 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: My script to download YouTube videos (critique wanted)
Message-Id: <avgv13tql2p94uc373amk9jqb7pgok17vu@4ax.com>

On 12 Apr 2007 20:35:18 -0700, "grocery_stocker" <cdalten@gmail.com>
wrote:

>>   sub get_webpage {
>>       my $url = shift;
>>       my $req = HTTP::Request->new(GET => $url);
>>
>>       for( 1..4 ) {
>>           my $result = get_request $req;
>>           if( !$result ) {
>>               warn "Failed to get '$url' ($_).\n";
>>               next;
>>           }
>>           return $result;
>>       }
>>       return;
>>   }
>>
>> to
>>
>>   sub get_webpage {
>>       my $url = shift;
>>       my $req = HTTP::Request->new(GET => $url);
>>
>>       for( 1..4 ) {
>>           my $result = get_request $req;
>>           return $result if $result;
>>           warn "Failed to get '$url' ($_).\n";
>>       }
>>       return;
>>   }
>>
>
>What's the advantage of switching the logic? The onl thing I can see
>is that the code is a bit shorter.

The advantage is that the code is a bit shorter, less convoluted, more
readable and easier to understand.


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: 13 Apr 2007 10:13:14 -0700
From: lratzan@gmail.com
Subject: perl print form without linefeeds
Message-Id: <1176484394.883905.198420@o5g2000hsb.googlegroups.com>

Hello:

We need the following output to appear across a single line, not two
lines.
If the first line is a functional print, how do we remove the
linefeed?

h3, ("Update your address"),
a({-href=>http://www.umdnj.edu},"click here"),

Please respond to Lee Ratzan (lratzan@gmail.com)

Thank you



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

Date: 13 Apr 2007 10:24:55 -0700
From: usenet@DavidFilmer.com
Subject: Re: perl print form without linefeeds
Message-Id: <1176485095.395885.289550@p77g2000hsh.googlegroups.com>

On Apr 13, 10:13 am, lrat...@gmail.com wrote:

> We need the following output to appear across a single line
> h3, ("Update your address"),
> a({-href=>http://www.umdnj.edu},"click here"),

h3 is a block formatting tag (it's intended for use in headlines).
You should apply inline styling to your label instead of block
styling.  You can do this with <font> tags; most folks these days
would use CSS.

> Please respond to Lee Ratzan (lrat...@gmail.com)

no.



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

Date: 13 Apr 2007 10:35:05 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: perl print form without linefeeds
Message-Id: <1176485705.560647.36630@e65g2000hsc.googlegroups.com>

On Apr 13, 6:13 pm, lrat...@gmail.com wrote:
> Hello:
>
> We need the following output to appear across a single line, not two
> lines.

What do you mean by "output to appear"? Do you mean when rendered via
a graphical HTML renderer?

> If the first line is a functional print,

What do you mean by "a functional print".

> how do we remove the linefeed?

What linefeed?

> h3, ("Update your address"),
> a({-href=>http://www.umdnj.edu},"click here"),

Please show us real code. This is particularly important if your
English is limited.

> Please respond to Lee Ratzan (lrat...@gmail.com)

Post to Usenet, read on Usenet.

BTW: I'm guessing your real problem has not the slightest thing to do
with Perl but is actually a pure HTML problem.

I'm gessing that you don't realise that In HTML H3 is a block-level
element. In a CSS aware browser you can override this by giving the H3
element  a style attribute "display: inline" but I would consider this
very ugly.



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

Date: Fri, 13 Apr 2007 15:22:19 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: perl regular expression
Message-Id: <evo0gq$c4r$1@mlucom4.urz.uni-halle.de>

kiranmn@my-deja.com wrote:
> I want all doublequote in a string to be prefixed with '\'. I want
> to achive this with  a regular expression and this regular expression
> will be in a loop, so for the same input if this same RE runs multiple
> times, it will  add multiple '\` before doublequote, to avoid that i
> am checking for " NOT A  BACKSLASH" in following RE.
> 
> Following RE works for me, but it fails for two consecutive
> doublequotes.
> Why RE is failing to replace second double quote, even with /g ?

You modifying the string contents of
character positions to match in the
next run of /g. By one \\ each time.

So you may go back in the match position
by one on each /g step:

   ...

   while ($input =~ s/([^\\x])"/$1\\"/g) {
     pos($input)--;
   }

   ...


BTW. what does the 'x' in the
character class mean?

Regards

M.


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

Date: Fri, 13 Apr 2007 15:28:25 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: perl regular expression
Message-Id: <evo0s7$c69$2@mlucom4.urz.uni-halle.de>

kiranmn@my-deja.com wrote:
 > I want all doublequote in a string to be prefixed with '\'. I want
 > to achive this with  a regular expression and this regular expression
 > will be in a loop, so for the same input if this same RE runs multiple
 > times, it will  add multiple '\` before doublequote, to avoid that i
 > am checking for " NOT A  BACKSLASH" in following RE.
 >
 > Following RE works for me, but it fails for two consecutive
 > doublequotes.
 > Why RE is failing to replace second double quote, even with /g ?

You are modifying the string contents of character positions
for the next match by one \\ each time.

You could go back in the match position
by one on each match or simply match
successively:

   ...

   1 while $input =~ s/([^\\x])"/$1\\"/g;

   ...


BTW. what does the 'x' in the
character class mean?

Regards

M.


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

Date: Fri, 13 Apr 2007 15:33:16 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: perl regular expression
Message-Id: <evo2m6$cmv$1@mlucom4.urz.uni-halle.de>

Mirco Wahab wrote:
>   ...
> 
>   1 while $input =~ s/([^\\x])"/$1\\"/g;
> 
>   ...

Of course, if your whole problem is
to escape quotes which aren't quoted
already, you could do a "double magical"

    $input =~ s|(?<!\\)(?=")|\\|g;

which combines two zero-width assertions

   (?<!\\) ==> not a \\
   (?=")   ==> before a quote

and replaces that 'cleft' by a \\

Regards

M.


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

Date: 13 Apr 2007 07:57:32 -0700
From: "odhiseo" <julises@gmail.com>
Subject: Re: Print Subject without characters Just Numbers using POP3Client. Please Help
Message-Id: <1176476252.480945.99240@y5g2000hsa.googlegroups.com>


> Sorry, now I understood your question
>
>  use Mail::POP3Client;
>
>  $pop = new Mail::POP3Client(   USER     => "xxxxxxxxxxxxxxxxx",
>                                 PASSWORD => "xxxxxxxxxx",
>                                 HOST     => "xxxxxxxxxx" );
>
>    for ($i = 1; $i <= $pop->Count(); $i++) {
>      foreach ( $pop->Head( $i ) ) {

>        /^Subject:\.+\s(\d+)/i && print $1, "\n";
>      }
>      print "\n";
>      sleep 5;
>   }- Hide quoted text -
>
> - Show quoted text -

Here is another way to do It (TMTOWTDI)


use Mail::POP3Client;

my $n = 10;  #Length of number string in the subject


 $pop = new Mail::POP3Client(   USER     => "xxxxxxxxxxxxxxxxx",
                                PASSWORD => "xxxxxxxxxx",
                                HOST     => "xxxxxxxxxx" );

   for ($i = 1; $i <= $pop->Count(); $i++) {
     foreach ( $pop->Head( $i ) ) {

       next unless /^Subject:/;
       /\s(\d{$n})(\s|$)/;
       print $1;
     }
     print "\n";
     sleep 5;
 }

And in the previous reply I had a little error, you must change:
        /^Subject:\.+\s(\d+)/i && print $1, "\n";
for:
        /^Subject:.+\s(\d+)/i && print $1, "\n";




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

Date: Thu, 12 Apr 2007 10:43:32 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Search Replace using Hash -p0777
Message-Id: <evl2ja.1o8.1@news.isolution.nl>

dscastroii@earthlink.net schreef:
> I'm trying to replace ascii codes (or &entities) in a text file with
> it's equivalent character using a hash.   The problem I'm running into
> is I am not allowed to use a foreach or while loop to do this (yes,
> this is a homework assignment).  I must use the -p0777 option with the
> #!/usr/bin/perl -p0777 which provides the looping and print function.
> I must do this using one line of code only.  I must use the /sg
> options in the replace statement to satisfy the instructor's
> requirements.
>
> The hash table consists of %entity = ( lt=> '<', gt=> '>', amp=> '&',
> '#65'=> 'A', quot=> '"', nbs => chr 160);
>
> I need to loop through a text file that contains these &entities of
> variable characters and lengths like so:
>
> &amp; hello
> &lt; bye
> &#65 sparky
>
> The output should be:
> &; hello
> <; bye
> A; sparky
>
> My code is this:
> s/keys %hash/values %hash/sg;

I think you need something like

    s/ &          # ampersand
       ([^;]+)    # capture: non-semicolons
       (?=;)      # look-ahead: semicolon
     /$entity{$1}/xsg;

Read `perldoc perlretut` and `perldoc perlre` for details.
I found no reason for the s-modifier though.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Fri, 13 Apr 2007 17:24:06 GMT
From: Bryan <bcc@nospam.net>
Subject: Splitting a string with placeholders
Message-Id: <W0PTh.8918$Kd3.4783@newssvr27.news.prodigy.net>

I have a string like this:
my $string = "A\tB\tC\t\t\t\t\t\t\n";

When I do:
my @array = split("\t", $string);

I get the following array:
@array = ["A", "B", "C"];

The placeholding '\t's are lost.

How can I keep these so that my array is like this:
@array = ["A", "B", "C", "", "", "", "", ""];

Thanks,
B


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

Date: Fri, 13 Apr 2007 17:42:32 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Splitting a string with placeholders
Message-Id: <ciPTh.12052$Uf7.3422@edtnps89>

Bryan wrote:
> I have a string like this:
> my $string = "A\tB\tC\t\t\t\t\t\t\n";
> 
> When I do:
> my @array = split("\t", $string);
> 
> I get the following array:
> @array = ["A", "B", "C"];
> 
> The placeholding '\t's are lost.
> 
> How can I keep these so that my array is like this:
> @array = ["A", "B", "C", "", "", "", "", ""];

my @array = split /\t/, $string, -1;



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: Fri, 13 Apr 2007 17:47:19 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Splitting a string with placeholders
Message-Id: <HmPTh.11$F32.1@trndny02>

Bryan wrote:
> I have a string like this:
> my $string = "A\tB\tC\t\t\t\t\t\t\n";
>
> When I do:
> my @array = split("\t", $string);
>
> I get the following array:
> @array = ["A", "B", "C"];
>
> The placeholding '\t's are lost.
>
> How can I keep these so that my array is like this:
> @array = ["A", "B", "C", "", "", "", "", ""];

Did you check the documentation of split()?
<quote>
    split /PATTERN/,EXPR,LIMIT
      [...] If LIMIT is
      unspecified or zero, trailing null fields are stripped [...]
      If LIMIT is
      negative, it is treated as if an arbitrarily large LIMIT had
      been specified.
</quote>

jue 




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

Date: Fri, 13 Apr 2007 10:51:54 -0700
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: Splitting a string with placeholders
Message-Id: <S_SdnTHvPYeqXoLbnZ2dnUVZ_hqdnZ2d@giganews.com>

Bryan wrote:

> I have a string like this:
> my $string = "A\tB\tC\t\t\t\t\t\t\n";

> When I do:
> my @array = split("\t", $string);

> I get the following array:
> @array = ["A", "B", "C"];

@array = ("A", "B", "C");

Parentheses, not brackets.


> The placeholding '\t's are lost.

> How can I keep these so that my array is like this:
> @array = ["A", "B", "C", "", "", "", "", ""];

@array = ("A", "B", "C", "", "", "", "", "");

Parentheses, not brackets. You are missing one element.


#!perl

$string = "A\tB\tC\t\t\t\t\t\t\n";

@array = split("\t", $string);

print scalar (@array);

print "\n\n";

for (@array)
  { print "$_ X "; }


PRINTED RESULTS:

9

A X B X C X  X  X  X  X  X
  X


Purl Gurl


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

Date: Fri, 13 Apr 2007 10:57:30 -0700
From: Bryan <bcc@nospam.net>
Subject: Re: Splitting a string with placeholders
Message-Id: <6wPTh.153$iZ5.48@newssvr22.news.prodigy.net>

John W. Krahn wrote:
> Bryan wrote:
>> I have a string like this:
>> my $string = "A\tB\tC\t\t\t\t\t\t\n";
>>
>> When I do:
>> my @array = split("\t", $string);
>>
>> I get the following array:
>> @array = ["A", "B", "C"];
>>
>> The placeholding '\t's are lost.
>>
>> How can I keep these so that my array is like this:
>> @array = ["A", "B", "C", "", "", "", "", ""];
> 
> my @array = split /\t/, $string, -1;
> 
> 
> 
> John

Thanks John,

I need to omit the placeholder for the \n however.  How do I do that?

BTW, where did you find the -1 thing?  Its not in the perldoc -f split 
info...

Cheers,
Bryan


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

Date: Fri, 13 Apr 2007 18:05:47 GMT
From: Bryan <bcc@nospam.net>
Subject: Re: Splitting a string with placeholders
Message-Id: <461FC685.9050605@nospam.net>

Bryan wrote:
> John W. Krahn wrote:
>> Bryan wrote:
>>> I have a string like this:
>>> my $string = "A\tB\tC\t\t\t\t\t\t\n";
>>>
>>> When I do:
>>> my @array = split("\t", $string);
>>>
>>> I get the following array:
>>> @array = ["A", "B", "C"];
>>>
>>> The placeholding '\t's are lost.
>>>
>>> How can I keep these so that my array is like this:
>>> @array = ["A", "B", "C", "", "", "", "", ""];
>>
>> my @array = split /\t/, $string, -1;
>>
>>
>>
>> John
> 
> Thanks John,
> 
> I need to omit the placeholder for the \n however.  How do I do that?
> 
> BTW, where did you find the -1 thing?  Its not in the perldoc -f split 
> info...
> 
> Cheers,
> Bryan

Oh duh. Found it.



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

Date: Fri, 13 Apr 2007 19:53:30 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Splitting a string with placeholders
Message-Id: <evogoi$gn7$1@mlucom4.urz.uni-halle.de>

Jürgen Exner wrote:
> Bryan wrote:
>> my $string = "A\tB\tC\t\t\t\t\t\t\n";
> Did you check the documentation of split()?
> ...
>       unspecified or zero, trailing null fields are stripped [...]
>       If LIMIT is
>       negative, it is treated as if an arbitrarily large LIMIT had
> ...

If I'm not mistaken, there's no 'trailing null field' here,
because it's an un-chomped string ...

Regards

M.



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

Date: 13 Apr 2007 07:13:24 -0700
From: "Robert Hicks" <sigzero@gmail.com>
Subject: Re: Top Turds of comp.lang.perl.misc (2007)
Message-Id: <1176473604.345102.244390@q75g2000hsh.googlegroups.com>

On Apr 12, 1:40 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:
<snip>
> Noooo, and didn't you start an endless flame about how the core of
> clpmisc is composed of elitist dumbasses who take a particular
> pleasure at rudely bashing newbies? I find that hard to believe...
> :-)
>
> Michele

I don't think "I" have started any flame wars. : \

Hmmm....maybe I will have to look into that.

Robert



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

Date: 13 Apr 2007 08:34:03 -0700
From: "Ram" <ramesh9999@gmail.com>
Subject: XML parsing using PERL.... URGENT
Message-Id: <1176478443.107001.200390@y5g2000hsa.googlegroups.com>

Hi,

I am new to PERL and i want to parse the xml file to csv with only 2
tags using perl.
Please help me out with this...


Sample of XML:

  <?xml version="1.0" encoding="ISO-8859-1" ?>
  <!DOCTYPE FOF (View Source for full doctype...)>
- <FOF Name="BBH3" Previous="00001" Date="20070403">
- <OB cl="FOMessage.FIOMMessage.FIOMObject" no="1019.1008.51"
vr="1.43" od="1" mn="0">
  <tx no="51" nm="provider1ID" mn="0" ky="1" />
  <tx no="51" nm="provider2ID" mn="0" ky="1" />
  <tx no="51" nm="provider3ID" mn="0" ky="1" />
  <sp no="1008" nm="creationTime" mn="0" />
  <tx no="1008" nm="author" mn="0" />
  <nu no="1019" nm="revisionNo" mn="0" />
  <sp no="1019" nm="createTimestamp" mn="0" />
  <tx no="1019" nm="createUserID" mn="0" vl="WMS" />
  <tx no="1019" nm="initiatorId" mn="0" />
  <tx no="1019" nm="messageFromID" mn="0" />
  <tx no="1019" nm="messageToID" mn="0" />
  <fg no="1019" nm="isEndOfDelivery" mn="0" />
  <fg no="1019" nm="isExecuted" mn="0" />
- <R no="1019" nm="fiomData">
- <RP mn="0">
- <OB cl="QuoteHolder.TopLevelObject.FIOMObject" no="208.1080.51"
vr="1.43" od="2" mn="0">
  <tx no="51" nm="provider1ID" mn="0" ky="1" />
  <tx no="51" nm="provider2ID" mn="0" ky="1" />
  <tx no="51" nm="provider3ID" mn="0" ky="1" />
  <cr no="208" nm="currency" mn="0" ky="1" vl="6 WKN 965642
Waehrung_BdB EO ISIN EU0009656420 BoersenkuerzelInland EUR
Waehrung_ISO4217 EUR DB_KEY 69" />
  <R no="1080" nm="result" />
- <R no="1080" nm="vdpsInformation">
- <RP mn="0">
- <OB cl="VDPSInformation.FIOMObject" no="160.51" vr="1.43" od="3"
mn="0">
  <tx no="51" nm="provider1ID" mn="0" ky="1" />
  <tx no="51" nm="provider2ID" mn="0" ky="1" />
  <tx no="51" nm="provider3ID" mn="0" ky="1" />
  <fg no="160" nm="hasPendingActivities" mn="0" vl="FALSE" />
  <tx no="160" nm="vstName" mn="0" vl="QuoteHolder" />
  <tx no="160" nm="vstVersion" mn="0" vl="WM_003a" />
  <em no="160" nm="foType" mn="0" dm="FOType" vl="500" />
  <tx no="160" nm="createUserID" mn="0" vl="WMS" />
  <sp no="160" nm="createTimestamp" mn="0" vl="05.07.2005 - 21:54:20
@0" />
  <tx no="160" nm="updateUserID" mn="0" vl="WMS" />
  <sp no="160" nm="updateTimestamp" mn="0" vl="03.04.2007 - 20:27:10
@0" />
  <nu no="160" nm="vstQuality" mn="0" vl="10" />
  <fg no="160" nm="isRelevant" mn="0" vl="TRUE" />
  <tx no="160" nm="modificationReason" mn="0" />
  <nu no="160" nm="revisionNo" mn="0" vl="939" />
  <tx no="160" nm="remarks" mn="0" />
  <fg no="160" nm="hasFutureMessages" mn="0" />
  <nu no="160" nm="vstRequiredQuality" mn="0" vl="5" />
  <tx no="160" nm="provider1Symbol" mn="0" ky="1" />
  <tx no="160" nm="provider2Symbol" mn="0" ky="1" />
  <tx no="160" nm="provider3Symbol" mn="0" ky="1" />
  <em no="160" nm="dataStatusType" mn="0" dm="DataStatusType" />
  <nu no="160" nm="vstMaximumQuality" mn="0" vl="10" />
  <nu no="160" nm="newVstQuality" mn="0" />
  <fg no="160" nm="isChecked" mn="0" />
  <tx no="160" nm="messageInfo" mn="0" />
  <fg no="160" nm="fotWizardIsDisabled" mn="0" />
  <em no="160" nm="blockingCodeType" mn="0" dm="BlockingCodeType" />
  <em no="160" nm="logicDeletionType" mn="0" dm="LogicDeletionType" /
>
  <tx no="160" nm="foDBKey" mn="0" />
  <fg no="160" nm="isOnDB" mn="0" vl="TRUE" />
  <fg no="160" nm="isFastInsertion" mn="0" />
  <em no="160" nm="priorityType" mn="0" dm="PriorityType" />
  <R no="160" nm="genericInformations" />
  <R no="160" nm="areaInformations" />
  </OB>
  </RP>
  </R>
  <R no="1080" nm="control" />
  <R no="1080" nm="pendingActivity" />
  <R no="1080" nm="pendingChange" />
- <WR no="208" tn="BTID3" nm="instrument">
  <id no="0_BTID3" tn="BTID3" nm="destinationKey" mn="0" vl="5
CommonCode 16245151 WKN 628946 ISIN DE0006289465 BoersenkuerzelInland
EXHA DB_KEY 18615" />
  </WR>
- <R no="208" nm="recentQuoteValues">
- <RP mn="0">
- <OB cl="QuoteValue.FIOMObject" no="213.51" vr="1.43" od="4" mn="0">
  <tx no="51" nm="provider1ID" mn="0" ky="1" />
  <tx no="51" nm="provider2ID" mn="0" ky="1"
vl="20070314K01005L21NULK02_1_4" />
  <tx no="51" nm="provider3ID" mn="0" ky="1" />
  <tx no="213" nm="quoteTypeIdSymbol" mn="0" vl="03_K02_1_4" />
  <em no="213" nm="valueType" mn="0" dm="ValueType" vl="9001" />
  <ft no="213" nm="quoteValue" mn="0" vl="130.97" />
  <em no="213" nm="valueStyleType" mn="0" dm="ValueStyleType" vl="5" /
>
  <ft no="213" nm="quoteSize" mn="0" />
  <sp no="213" nm="quoteTime" mn="0" vl="14.03.2007 - 99:99:99 @99" /
>
  <em no="213" nm="sizeStyleType" mn="0" dm="SizeStyleType" />
  <em no="213" nm="reliabilityType" mn="0" dm="ReliabilityType" />
  <fg no="213" nm="isCorrection" mn="0" />
  <sp no="213" nm="validUntil" mn="0" />
  <em no="213" nm="settlementTimeType" mn="0" dm="SettlementTimeType" /
>
  <em no="213" nm="settlementCodeType" mn="0" dm="SettlementCodeType" /
>
  <em no="213" nm="settlementStatusType" mn="0"
dm="QuoteSettleStatusType" />
  <em no="213" nm="valueStyleRefinedType" mn="0"
dm="ValueStyleRefinedType" vl="9121" />
  <tx no="213" nm="quoteTypeSchemeSymbol" mn="0" vl="03_Fondspreise" /
>
  <em no="213" nm="fixingCapitalEventType" mn="0"
dm="FixingCapitalEventType" />
  <lg no="213" nm="valueDescr" mn="0" />
  <R no="213" nm="listingInformation" />
  <R no="213" nm="providedService" />
  <R no="213" nm="quoteListings" />
  <RD no="213" nm="quoteType" mn="0" kyA="quoteTypeIdSymbol/
quoteTypeSchemeSymbol" />
  </OB>
  </RP>

My CSV file should be:
03042007
EU0009656420,130.97(quoteValue tag)


Please help me out with this...



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

Date: Fri, 13 Apr 2007 10:43:24 -0500
From: Ignoramus10909 <ignoramus10909@NOSPAM.10909.invalid>
Subject: Re: XML parsing using PERL.... URGENT
Message-Id: <3Y6dncdtyaaBOILbnZ2dnUVZ_rHinZ2d@giganews.com>

Try using XML::Simple

i

On 13 Apr 2007 08:34:03 -0700, Ram <ramesh9999@gmail.com> wrote:
> Hi,
>
> I am new to PERL and i want to parse the xml file to csv with only 2
> tags using perl.
> Please help me out with this...
>
>
> Sample of XML:
>
>  <?xml version="1.0" encoding="ISO-8859-1" ?>
>  <!DOCTYPE FOF (View Source for full doctype...)>
> - <FOF Name="BBH3" Previous="00001" Date="20070403">
> - <OB cl="FOMessage.FIOMMessage.FIOMObject" no="1019.1008.51"
> vr="1.43" od="1" mn="0">
>  <tx no="51" nm="provider1ID" mn="0" ky="1" />
>  <tx no="51" nm="provider2ID" mn="0" ky="1" />
>  <tx no="51" nm="provider3ID" mn="0" ky="1" />
>  <sp no="1008" nm="creationTime" mn="0" />
>  <tx no="1008" nm="author" mn="0" />
>  <nu no="1019" nm="revisionNo" mn="0" />
>  <sp no="1019" nm="createTimestamp" mn="0" />
>  <tx no="1019" nm="createUserID" mn="0" vl="WMS" />
>  <tx no="1019" nm="initiatorId" mn="0" />
>  <tx no="1019" nm="messageFromID" mn="0" />
>  <tx no="1019" nm="messageToID" mn="0" />
>  <fg no="1019" nm="isEndOfDelivery" mn="0" />
>  <fg no="1019" nm="isExecuted" mn="0" />
> - <R no="1019" nm="fiomData">
> - <RP mn="0">
> - <OB cl="QuoteHolder.TopLevelObject.FIOMObject" no="208.1080.51"
> vr="1.43" od="2" mn="0">
>  <tx no="51" nm="provider1ID" mn="0" ky="1" />
>  <tx no="51" nm="provider2ID" mn="0" ky="1" />
>  <tx no="51" nm="provider3ID" mn="0" ky="1" />
>  <cr no="208" nm="currency" mn="0" ky="1" vl="6 WKN 965642
> Waehrung_BdB EO ISIN EU0009656420 BoersenkuerzelInland EUR
> Waehrung_ISO4217 EUR DB_KEY 69" />
>  <R no="1080" nm="result" />
> - <R no="1080" nm="vdpsInformation">
> - <RP mn="0">
> - <OB cl="VDPSInformation.FIOMObject" no="160.51" vr="1.43" od="3"
> mn="0">
>  <tx no="51" nm="provider1ID" mn="0" ky="1" />
>  <tx no="51" nm="provider2ID" mn="0" ky="1" />
>  <tx no="51" nm="provider3ID" mn="0" ky="1" />
>  <fg no="160" nm="hasPendingActivities" mn="0" vl="FALSE" />
>  <tx no="160" nm="vstName" mn="0" vl="QuoteHolder" />
>  <tx no="160" nm="vstVersion" mn="0" vl="WM_003a" />
>  <em no="160" nm="foType" mn="0" dm="FOType" vl="500" />
>  <tx no="160" nm="createUserID" mn="0" vl="WMS" />
>  <sp no="160" nm="createTimestamp" mn="0" vl="05.07.2005 - 21:54:20
> @0" />
>  <tx no="160" nm="updateUserID" mn="0" vl="WMS" />
>  <sp no="160" nm="updateTimestamp" mn="0" vl="03.04.2007 - 20:27:10
> @0" />
>  <nu no="160" nm="vstQuality" mn="0" vl="10" />
>  <fg no="160" nm="isRelevant" mn="0" vl="TRUE" />
>  <tx no="160" nm="modificationReason" mn="0" />
>  <nu no="160" nm="revisionNo" mn="0" vl="939" />
>  <tx no="160" nm="remarks" mn="0" />
>  <fg no="160" nm="hasFutureMessages" mn="0" />
>  <nu no="160" nm="vstRequiredQuality" mn="0" vl="5" />
>  <tx no="160" nm="provider1Symbol" mn="0" ky="1" />
>  <tx no="160" nm="provider2Symbol" mn="0" ky="1" />
>  <tx no="160" nm="provider3Symbol" mn="0" ky="1" />
>  <em no="160" nm="dataStatusType" mn="0" dm="DataStatusType" />
>  <nu no="160" nm="vstMaximumQuality" mn="0" vl="10" />
>  <nu no="160" nm="newVstQuality" mn="0" />
>  <fg no="160" nm="isChecked" mn="0" />
>  <tx no="160" nm="messageInfo" mn="0" />
>  <fg no="160" nm="fotWizardIsDisabled" mn="0" />
>  <em no="160" nm="blockingCodeType" mn="0" dm="BlockingCodeType" />
>  <em no="160" nm="logicDeletionType" mn="0" dm="LogicDeletionType" /
>>
>  <tx no="160" nm="foDBKey" mn="0" />
>  <fg no="160" nm="isOnDB" mn="0" vl="TRUE" />
>  <fg no="160" nm="isFastInsertion" mn="0" />
>  <em no="160" nm="priorityType" mn="0" dm="PriorityType" />
>  <R no="160" nm="genericInformations" />
>  <R no="160" nm="areaInformations" />
>  </OB>
>  </RP>
>  </R>
>  <R no="1080" nm="control" />
>  <R no="1080" nm="pendingActivity" />
>  <R no="1080" nm="pendingChange" />
> - <WR no="208" tn="BTID3" nm="instrument">
>  <id no="0_BTID3" tn="BTID3" nm="destinationKey" mn="0" vl="5
> CommonCode 16245151 WKN 628946 ISIN DE0006289465 BoersenkuerzelInland
> EXHA DB_KEY 18615" />
>  </WR>
> - <R no="208" nm="recentQuoteValues">
> - <RP mn="0">
> - <OB cl="QuoteValue.FIOMObject" no="213.51" vr="1.43" od="4" mn="0">
>  <tx no="51" nm="provider1ID" mn="0" ky="1" />
>  <tx no="51" nm="provider2ID" mn="0" ky="1"
> vl="20070314K01005L21NULK02_1_4" />
>  <tx no="51" nm="provider3ID" mn="0" ky="1" />
>  <tx no="213" nm="quoteTypeIdSymbol" mn="0" vl="03_K02_1_4" />
>  <em no="213" nm="valueType" mn="0" dm="ValueType" vl="9001" />
>  <ft no="213" nm="quoteValue" mn="0" vl="130.97" />
>  <em no="213" nm="valueStyleType" mn="0" dm="ValueStyleType" vl="5" /
>>
>  <ft no="213" nm="quoteSize" mn="0" />
>  <sp no="213" nm="quoteTime" mn="0" vl="14.03.2007 - 99:99:99 @99" /
>>
>  <em no="213" nm="sizeStyleType" mn="0" dm="SizeStyleType" />
>  <em no="213" nm="reliabilityType" mn="0" dm="ReliabilityType" />
>  <fg no="213" nm="isCorrection" mn="0" />
>  <sp no="213" nm="validUntil" mn="0" />
>  <em no="213" nm="settlementTimeType" mn="0" dm="SettlementTimeType" /
>>
>  <em no="213" nm="settlementCodeType" mn="0" dm="SettlementCodeType" /
>>
>  <em no="213" nm="settlementStatusType" mn="0"
> dm="QuoteSettleStatusType" />
>  <em no="213" nm="valueStyleRefinedType" mn="0"
> dm="ValueStyleRefinedType" vl="9121" />
>  <tx no="213" nm="quoteTypeSchemeSymbol" mn="0" vl="03_Fondspreise" /
>>
>  <em no="213" nm="fixingCapitalEventType" mn="0"
> dm="FixingCapitalEventType" />
>  <lg no="213" nm="valueDescr" mn="0" />
>  <R no="213" nm="listingInformation" />
>  <R no="213" nm="providedService" />
>  <R no="213" nm="quoteListings" />
>  <RD no="213" nm="quoteType" mn="0" kyA="quoteTypeIdSymbol/
> quoteTypeSchemeSymbol" />
>  </OB>
>  </RP>
>
> My CSV file should be:
> 03042007
> EU0009656420,130.97(quoteValue tag)
>
>
> Please help me out with this...
>


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

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


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