[32086] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3350 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 13 18:09:26 2011

Date: Wed, 13 Apr 2011 15: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           Wed, 13 Apr 2011     Volume: 11 Number: 3350

Today's topics:
    Re: Changing XML tag value in Perl <rajpreetsidhu@gmail.com>
        dereferencing in perl <Uno@example.invalid>
    Re: dereferencing in perl <marc.girod@gmail.com>
    Re: dereferencing in perl <marc.girod@gmail.com>
    Re: dereferencing in perl <marc.girod@gmail.com>
    Re: FAQ 2.12 Which magazines have Perl content? <brian.d.foy@gmail.com>
    Re: FAQ 2.12 Which magazines have Perl content? <justin.1104@purestblue.com>
    Re: FAQ 6.9 How can I quote a variable to use in a rege <brian.d.foy@gmail.com>
    Re: FAQ 6.9 How can I quote a variable to use in a rege <cartercc@gmail.com>
    Re: FAQ 6.9 How can I quote a variable to use in a rege <uri@StemSystems.com>
    Re: FAQ 6.9 How can I quote a variable to use in a rege <willem@toad.stack.nl>
    Re: FAQ 6.9 How can I quote a variable to use in a rege (Alan Curry)
    Re: FAQ 6.9 How can I quote a variable to use in a rege <nospam-abuse@ilyaz.org>
    Re: FAQ 6.9 How can I quote a variable to use in a rege <nospam-abuse@ilyaz.org>
    Re: FAQ 6.9 How can I quote a variable to use in a rege <tadmc@seesig.invalid>
    Re: FAQ 6.9 How can I quote a variable to use in a rege <cartercc@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Apr 2011 13:48:29 -0700 (PDT)
From: Rajpreet <rajpreetsidhu@gmail.com>
Subject: Re: Changing XML tag value in Perl
Message-Id: <c2ed2c8c-5872-41d4-8e6e-d455aac8119f@v11g2000prb.googlegroups.com>

Thanks for your inputs. However problem in my case is my production
environment has just XML::Parser . I am not allowed to download any
thing. So options are either to directly manipulate or use
XML::Parser. I have not done XML parsing anytime earlier . Would
appreciate your inputs. Thanks.


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

Date: Wed, 13 Apr 2011 01:13:57 -0600
From: Uno <Uno@example.invalid>
Subject: dereferencing in perl
Message-Id: <90l0pnFbu8U1@mid.individual.net>

$ perl client5.pl
News::NNTPClient::SOCK1 command: GROUP comp.lang.perl.misc
News::NNTPClient::SOCK1 result(211): 4777 658225 663028 comp.lang.perl.misc
658225   663028
663023

 ...

News::NNTPClient::SOCK1 command: XHDR message-id 663028
News::NNTPClient::SOCK1 result(221): message-id fields follow
News::NNTPClient::SOCK1 received 1 lines
ARRAY(0x85a7a98)
News::NNTPClient::SOCK1 command: QUIT
News::NNTPClient::SOCK1 result(205): .
$ cat client5.pl
#!/usr/bin/perl
use strict;
use warnings;
use Net::NNTP ();
require News::NNTPClient;

my $group = 'comp.lang.perl.misc';
my $server = 'News.Individual.NET';
my $USER = '';
my $PASS = '';

my $c = new News::NNTPClient($server);
$c->authinfo($USER, $PASS);
$c->debug(2);
my ($first, $last) = ($c->group($group));
print "$first   $last  \n";

   for (my $i = ($last -5); $i <= $last; $i++) {
       print "$i \n";
       my $subject = $c->xhdr("", $i);
      print "$subject\n";

   }
__END__
$

I have a tried a million things to see the contents of the array as 
opposed to reference and give up.  Suggestions?
-- 
Uno


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

Date: Wed, 13 Apr 2011 04:39:23 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: dereferencing in perl
Message-Id: <7f35eee9-b21f-4115-b8fc-8fccf485d211@hg8g2000vbb.googlegroups.com>

On Apr 13, 8:13=A0am, Uno <U...@example.invalid> wrote:

> I have a tried a million things to see the contents of the array as
> opposed to reference and give up. =A0Suggestions?

I got neither which array, nor what exactly you tried so far, so,
let's start simple:

$ perl -le '$qq=3D[qw(a b c)]; print $qq; print for @{$qq}'
ARRAY(0x816db50)
a
b
c

Marc


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

Date: Wed, 13 Apr 2011 04:46:20 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: dereferencing in perl
Message-Id: <db6d1a01-0f87-452c-a217-97ae2008accf@t16g2000vbi.googlegroups.com>

On Apr 13, 12:39=A0pm, Marc Girod <marc.gi...@gmail.com> wrote:

> I got neither which array, nor what exactly you tried so far

Sorry. Now I saw.
But I have to think.
Marc


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

Date: Wed, 13 Apr 2011 05:08:42 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: dereferencing in perl
Message-Id: <51d7eaef-4d22-4927-b4dc-6c2b9ce277c1@s3g2000vbf.googlegroups.com>

On Apr 13, 12:46=A0pm, Marc Girod <marc.gi...@gmail.com> wrote:

> But I have to think.

I cannot connect to that server, so that I cannot reproduce.
Not sure what output comes from the debug info.
So, I give up.
Sorry again for the noise.
Marc


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

Date: Tue, 12 Apr 2011 13:25:44 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 2.12 Which magazines have Perl content?
Message-Id: <120420111325441762%brian.d.foy@gmail.com>

In article <c23dd$4da4810e$ce534406$28907@news.eurofeeds.com>,
<"thegist@nospam.net"> wrote:

> > 2.12: Which magazines have Perl content?
> >
> >      *The Perl Review* ]

> Doesn't the current faq maintainer also run tpr?
> Why doesn't he update this with the fact that tpr hasn't published
> an issue in over a year and had been barely surviving on life support
> for years before then?

Well, it was never barely surviving, but people wanted more web stuff
and less print stuff. Still, that means it's not a magazine so no one
should call it that. As for why: I don't comb the FAQ for updates. I
fix problems when people point them out. :)

 .
> When mentioning tpj why not mention that O'Reilly has collected and 
> published
> the best articles into three volumes?

Because that's the job of perlbooks.pod :)


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

Date: Wed, 13 Apr 2011 09:33:39 +0100
From: Justin C <justin.1104@purestblue.com>
Subject: Re: FAQ 2.12 Which magazines have Perl content?
Message-Id: <3o3g78-68s.ln1@zem.masonsmusic.co.uk>

On 2011-04-12, PerlFAQ Server <brian@theperlreview.com> wrote:
>
> 2.12: Which magazines have Perl content?

[snip]
>
>     In 2006, *TPJ* merged with Dr. Dobbs
>     Journal (online edition). To read old *TPJ* articles, see
>     http://www.ddj.com/ , brian d foy's index of online TPJ content (
>     http://www.perlmonks.org/index.pl?node_id=711609 ).

As we're picking holes in this one today :-)     

That last link to perlmonks.org works, but some of the links from that
page are 404 (I started at the bottom of the main list, those at the top
seem OK, but I didn't have the patience to check them all).

   Justin.

-- 
Justin C, by the sea.


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

Date: Tue, 12 Apr 2011 13:27:05 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 6.9 How can I quote a variable to use in a regex?
Message-Id: <120420111327056612%brian.d.foy@gmail.com>

In article
<8e4f1b32-f977-4dac-8c83-101709aa95a1@r13g2000yqk.googlegroups.com>,
ccc31807 <cartercc@gmail.com> wrote:

> Question: is there any way I can use the OS file glob in a regex
> without changing it? Can I put my file descriptor in a variable and
> pass it reliably to the regex?

Isn't that what glob() is for?


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

Date: Tue, 12 Apr 2011 13:00:48 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: FAQ 6.9 How can I quote a variable to use in a regex?
Message-Id: <45b53ba4-cf39-400a-81f9-81554b51bd6e@d2g2000yqn.googlegroups.com>

On Apr 12, 1:43=A0pm, "Uri Guttman" <u...@StemSystems.com> wrote:
> so just swapping * and . makes no sense.

As a file glob, 'USA_*.txt' gets all the files that begin with 'USA_'
and end with '.txt' with (perhaps) a few characters in between.

As a regular expression, /USA_.*txt/ matches a string that contains
the literal characters 'USA_', followed by zero or more characters,
followed by 'txt'.

As a matter of fact, swapping the dot and star actually didn't work in
my application (due to other reasons not material here). I solved the
problem by assigning all the literal characters before the star to a
variable, and then matched the variable. The fact that the file name
ends in 'txt' doesn't matter.

I would have liked to use the same value both as a file glob for the
purpose of getting the file (which I do by running pscp as an external
process) and as a regular expression to process just the files I need,
but in the end it doesn't matter -- except maybe as a reminder that
the file glob syntax and the regex syntax isn't identical.

CC.


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

Date: Tue, 12 Apr 2011 16:14:43 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: FAQ 6.9 How can I quote a variable to use in a regex?
Message-Id: <87oc4bjkgc.fsf@quad.sysarch.com>

>>>>> "c" == ccc31807  <cartercc@gmail.com> writes:

  c> On Apr 12, 1:43 pm, "Uri Guttman" <u...@StemSystems.com> wrote:
  >> so just swapping * and . makes no sense.

  c> As a file glob, 'USA_*.txt' gets all the files that begin with 'USA_'
  c> and end with '.txt' with (perhaps) a few characters in between.

please don't tell me how globs work.

  c> As a regular expression, /USA_.*txt/ matches a string that contains
  c> the literal characters 'USA_', followed by zero or more characters,
  c> followed by 'txt'.

please don't tell me how regexes work.


  c> As a matter of fact, swapping the dot and star actually didn't work in
  c> my application (due to other reasons not material here). I solved the
  c> problem by assigning all the literal characters before the star to a
  c> variable, and then matched the variable. The fact that the file name
  c> ends in 'txt' doesn't matter.

it wouldn't work under any circumstances. regexes are not globs.

the regex will match USA_txt without the . which you should have. the
glob MUST have a . matched. they are different patterns.

  c> I would have liked to use the same value both as a file glob for the
  c> purpose of getting the file (which I do by running pscp as an external
  c> process) and as a regular expression to process just the files I need,
  c> but in the end it doesn't matter -- except maybe as a reminder that
  c> the file glob syntax and the regex syntax isn't identical.

did you see what i said about a proper way to fix it? i don't think
so. swapping is wrong on many levels. my solution is correct on all
levels.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Tue, 12 Apr 2011 20:45:30 +0000 (UTC)
From: Willem <willem@toad.stack.nl>
Subject: Re: FAQ 6.9 How can I quote a variable to use in a regex?
Message-Id: <slrniq9efa.1m5q.willem@toad.stack.nl>

brian d foy wrote:
) In article
)<8e4f1b32-f977-4dac-8c83-101709aa95a1@r13g2000yqk.googlegroups.com>,
) ccc31807 <cartercc@gmail.com> wrote:
)
)> Question: is there any way I can use the OS file glob in a regex
)> without changing it? Can I put my file descriptor in a variable and
)> pass it reliably to the regex?
)
) Isn't that what glob() is for?

Wouldn't it be nice if there were a glob() that worked on strings ?


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT


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

Date: Tue, 12 Apr 2011 21:28:12 +0000 (UTC)
From: pacman@kosh.dhis.org (Alan Curry)
Subject: Re: FAQ 6.9 How can I quote a variable to use in a regex?
Message-Id: <io2g5c$q2f$1@speranza.aioe.org>

In article <slrniq9efa.1m5q.willem@toad.stack.nl>,
Willem  <willem@toad.stack.nl> wrote:
>brian d foy wrote:
>
>Wouldn't it be nice if there were a glob() that worked on strings ?

An excellent summary of the original long-form question.

There is such a function in the POSIX C library, called fnmatch(). It
doesn't seem to be present in POSIX.pm, but look what I got by googling
"perl fnmatch":

http://search.cpan.org/~mjp/File-FnMatch-0.02/FnMatch.pm

Seems to be just the thing.

-- 
Alan Curry


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

Date: Tue, 12 Apr 2011 21:32:08 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: FAQ 6.9 How can I quote a variable to use in a regex?
Message-Id: <slrniq9h6o.rf9.nospam-abuse@powdermilk.math.berkeley.edu>

On 2011-04-12, Willem <willem@toad.stack.nl> wrote:
> Wouldn't it be nice if there were a glob() that worked on strings ?

Did you actually inspect File::Glob before doing your wishful
thinking?  (You claim you do not need learning how glob() operates,
right?)

Ilya


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

Date: Tue, 12 Apr 2011 21:34:22 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: FAQ 6.9 How can I quote a variable to use in a regex?
Message-Id: <slrniq9hau.rf9.nospam-abuse@powdermilk.math.berkeley.edu>

On 2011-04-12, Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> On 2011-04-12, Willem <willem@toad.stack.nl> wrote:
>> Wouldn't it be nice if there were a glob() that worked on strings ?
>
> Did you actually inspect File::Glob before doing your wishful
> thinking?  (You claim you do not need learning how glob() operates,
> right?)

My apologies - in the last sentence I mixed you up with someone else. :-(

Yours,
Ilya


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

Date: Tue, 12 Apr 2011 16:44:07 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: FAQ 6.9 How can I quote a variable to use in a regex?
Message-Id: <slrniq9hk8.q66.tadmc@tadbox.sbcglobal.net>

ccc31807 <cartercc@gmail.com> wrote:

> a reminder that
> the file glob syntax and the regex syntax isn't identical.


They are not even similar!

The glob language and the regex language are different languages.

We need a reminder that the funny characters in different languages
mean different things?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Tue, 12 Apr 2011 19:09:42 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: FAQ 6.9 How can I quote a variable to use in a regex?
Message-Id: <3788bc64-b9e5-49ff-a904-9fe39121074c@n2g2000prj.googlegroups.com>

On Apr 12, 5:44=A0pm, Tad McClellan <ta...@seesig.invalid> wrote:
> We need a reminder that the funny characters in different languages
> mean different things?

Unfortunately, sometimes we do, especially when we don't concentrate
on the particular tool currently in use.

I use vi, emacs, and Textpad for different things, and sometimes I
have all three open and in use at the same time, and sometimes I type
a Ctl-p in vi, or a :x in Textpad, or a Ctl-v in emacs, and
momentarily wonder what's wrong with the command. I'm just not good
enough to juggle three balls at the same time. Hell, I'm often not
good enough to juggle ONE ball at the same time!

CC.


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 3350
***************************************


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