[24643] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6807 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 3 13:06:45 2004

Date: Tue, 3 Aug 2004 10:05:54 -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           Tue, 3 Aug 2004     Volume: 10 Number: 6807

Today's topics:
        FS: The Perl Journal Vols 1 - 18, & 20 (Ray Sutton)
        FS: The Perl Journal Vols 1 - 18, & 20 (Ray Sutton)
        function reference errors... <raven_at@home.domonet.ru>
    Re: function reference errors... <1usa@llenroc.ude.invalid>
    Re: function reference errors... <invalid-email@rochester.rr.com>
    Re: function reference errors... <raven_at@home.domonet.ru>
    Re: function reference errors... <tadmc@augustmail.com>
    Re: function reference errors... (Anno Siegel)
        Generic fingerprint ie hash value for compex data struc (Tim Richardson)
    Re: Generic fingerprint ie hash value for compex data s ctcgag@hotmail.com
    Re: Generic fingerprint ie hash value for compex data s (Tim Richardson)
    Re: Generic fingerprint ie hash value for compex data s ctcgag@hotmail.com
        Getopt::Simple V 1.47 <ron@savage.net.au>
        Getting Text Value , in Single line <georgekinley@hotmail.com>
    Re: Getting Text Value , in Single line <jurgenex@hotmail.com>
    Re: Getting Text Value , in Single line <jgibson@mail.arc.nasa.gov>
    Re: Getting Text Value , in Single line <gogala@sbcglobal.net>
    Re: Getting Text Value , in Single line <zen13097@zen.co.uk>
    Re: Getting Text Value , in Single line <t_lawetta@yahoo.com>
        getting Values out of  <Array> <Some.One@hotmail.com>
    Re: getting Values out of  <Array> (Anno Siegel)
        glob function and getting directory contents <matrix_calling@yahoo.dot.com>
    Re: glob function and getting directory contents <mritty@gmail.com>
    Re: glob function and getting directory contents <matrix_calling@yahoo.dot.com>
    Re: glob function and getting directory contents <mritty@gmail.com>
    Re: glob function and getting directory contents <me@privacy.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 26 Jul 2004 13:50:41 -0700
From: rlsutton@chartermi.net (Ray Sutton)
Subject: FS: The Perl Journal Vols 1 - 18, & 20
Message-Id: <cf239c11.0407261250.7a3325b5@posting.google.com>

I have original Perl Journals #1 through #18 and #20. I will sell them
only as a set. They are in perfect condition. A real bargain at $75
plus shipping. Contact me at rlsutton@chartermi.net. Thank you.


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

Date: 26 Jul 2004 13:51:15 -0700
From: rlsutton@chartermi.net (Ray Sutton)
Subject: FS: The Perl Journal Vols 1 - 18, & 20
Message-Id: <cf239c11.0407261251.6527063c@posting.google.com>

I have original Perl Journals #1 through #18 and #20. I will sell them
only as a set. They are in perfect condition. A real bargain at $75
plus shipping. Contact me at rlsutton@chartermi.net. Thank you.


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

Date: Fri, 23 Jul 2004 23:54:52 +0400
From: "Sergei Shelukhin" <raven_at@home.domonet.ru>
Subject: function reference errors...
Message-Id: <2md8o4FlusbqU1@uni-berlin.de>

I am starting to write my first Perl module ever, I want to create standart
DBGrid thing...
However, I have osmething messed up and I cannot figure out what is wrong.

        #!!!!!!!!!!!!!
line indicates the problem. Problem is that, even though function reference
seems to be passed and everything seems to be ok, it doesn't launch, and
instead, the script is terminating with errors.
What am I doing wrong?

Here's the test script
use strict;
use lib qw(e:\\workplace);
use CGI qw/standart/;
use CGI::Carp qw/fatalsToBrowser/;
use DBI;
use dbgrid;

sub draw_callback
{
my ($field,$key,$value) = @_;
return "Callback says $value";
}

my $db = DBI->connect( "DBI:mysql:blogbase:localhost", "root", "pwd" ) or
croak "MySQL seems to be down, or something is fubared.";
my $sql = "SELECT * FROM Record";
my $eventscript = "test.pl";
my $key = "RecordId";
my (%column1,%column2);
$column1{Type} = "ctLabel";
$column1{Title} = "ID";
$column1{FieldName} = "RecordId";
$column2{Type} = "ctCallback";
$column2{Title} = "TITLE";
$column2{FieldName} = "Title";
my @columns = (\%column1,\%column2);
my $test = DBGrid->create($db,$sql,$eventscript,\@columns,$key);
$test->SetCallbacks(\&draw_callback,0,0);
$test->output_columns();


Here's my module in its current state (unimportant pieces have been cut out)

package DBGrid;

use strict;
use CGI qw/standart/;
use CGI::Carp qw/fatalsToBrowser/;
use DBI;

my %props;

###############################################################

sub output_columns
{
my $columns = $props{columns};
my ($header,$footer,@rows) = ("","",0);
#
# ...
#
my $i = 0;
while ( my $row = $props{query}->fetchrow_hashref() )
  {
#
# ...
#
  for my $column (@$columns)
    {
#
# ...
#
    my $type = $$column{Type};
    if ( !$$column{Custom} )
      {
      if ( $type eq "ctLabel" )
        {
        $rows[$i] .= $$row{$$column{FieldName}};
        }
#
# ...
#
      if ( $type eq "ctCallback" )
        {
        #!!!!!!!!!!!!! error here
        $rows[$i] .=
$props{DrawCallback}($$column{FieldName},$key,$$row{$$column{FieldName}});
        }
      }
    else
      {
#
# ...
#
      }
#
# ...
#
  ++$i;
  }

print $header;
print join('',@rows) if ($#rows+1);
print $footer;
}

###############################################################

sub create
{
shift;
($props{db},$props{sql},$props{EventScript},$props{columns},$props{KeyField}
) = @_;
$props{query} = $props{db}->prepare($props{sql}) or croak "Error
initialising database object: ".$props{db}->errstr;
$props{query}->execute() or croak "Error executing SQL statement :
".$props{db}->errstr;
build_columns() if !defined $props{columns} or !$props{columns};
my $self = \%props;
bless $self;
return $self;
}

###############################################################

sub build_columns
{
#
# ...
#
}

###############################################################

sub SetCallbacks
{
#improve to ignore zeros
($props{DrawCallback},$props{CustomCallback},$props{OutputCallback}) = @_;
}

###############################################################
return 1;










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

Date: 23 Jul 2004 20:20:42 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: function reference errors...
Message-Id: <Xns952FA644648D5asu1cornelledu@132.236.56.8>

"Sergei Shelukhin" <raven_at@home.domonet.ru> wrote in
news:2md8o4FlusbqU1@uni-berlin.de: 

> I am starting to write my first Perl module ever, I want to create
> standart DBGrid thing...
> However, I have osmething messed up and I cannot figure out what is
> wrong. 
> 
>         #!!!!!!!!!!!!!
> line indicates the problem. Problem is that, even though function
> reference seems to be passed and everything seems to be ok, it doesn't
> launch, and instead, the script is terminating with errors.
> What am I doing wrong?
> 
> Here's the test script
> use strict;
> use lib qw(e:\\workplace);
> use CGI qw/standart/;

That should be:

use CGI qw /standard/;

Did you copy and paste this from the actual source you are running or did 
you type it in to your newsreader?

I am going to stop reading your code at this point.

> sub draw_callback
> {
> my ($field,$key,$value) = @_;
> return "Callback says $value";
> }

Please properly indent your code if you want others to read your code.

> package DBGrid;
> 
> use strict;
> use CGI qw/standart/;

Same here.

-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)



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

Date: Sat, 24 Jul 2004 02:54:45 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: function reference errors...
Message-Id: <4101CF18.3010200@rochester.rr.com>

Sergei Shelukhin wrote:

> I am starting to write my first Perl module ever, I want to create standart
> DBGrid thing...
> However, I have osmething messed up and I cannot figure out what is wrong.
> 
>         #!!!!!!!!!!!!!
> line indicates the problem. Problem is that, even though function reference
> seems to be passed and everything seems to be ok, it doesn't launch, and
> instead, the script is terminating with errors.

-------------------------^^^^^^^^^^^^^^^^^^^^^^^

What errors, *exactly*, would those be?  We can't read your mind.


> What am I doing wrong?


The error messages you don't bother to mention probably offer some hints 
about that.


> 
> Here's the test script
> use strict;
> use lib qw(e:\\workplace);
> use CGI qw/standart/;

:standard----^^^^^^^^

Correct spelling is very important.  And so is the leading : .


> use CGI::Carp qw/fatalsToBrowser/;
> use DBI;
> use dbgrid;

DBG---^^^
Below you define this as DBGrid.  Case is important, even on Windoze. 
Maybe more important, because Perl will find the module file due to the 
case-insensitive file system and won't give that error, but the package 
won't work -- but there is no error message.


 ...
> Here's my module in its current state (unimportant pieces have been cut out)
> 
> package DBGrid;
> 
> use strict;
> use CGI qw/standart/;

:standard----^^^^^^^^

You did it again.


> use CGI::Carp qw/fatalsToBrowser/;
> use DBI;
> 
> my %props;
> 
 ...


I didn't go over the rest of your code in detail -- I didn't immediately 
see anything else.  Maybe it will work with those fixes?

It would really help if you could whittle the posted code down to a 
minimal-length script that exhibits the problem and can be 
copy/paste/executed by anyone.  I suspect, for example, that all the 
database stuff is irrelevant to your problem, as is the fact that it is 
a CGI script.  And, probably, in the course of doing that, you will 
discover the source of the error for yourself.

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Sat, 24 Jul 2004 14:40:41 +0400
From: "Sergei Shelukhin" <raven_at@home.domonet.ru>
Subject: Re: function reference errors...
Message-Id: <2meskvFlvfmfU1@uni-berlin.de>

Ok, I fixed the callback problem, I forgot that the first parameter passed
to a method is the object itself in SetCallbacks... Thanks for corrections
too, I typoed standard in the "use" statement and copy-pasted it to test
script; I didn't get to using it anyway (thus far), so I didn't notice the
error.

Now, there's a version problem. I have ActiveState Perl installed both at
work and at home; of course, both boxes are running Windows, and the script
is working as it should.
However, when I tried launching the script on my Linux box (Perl version is
5.005_03), it returned syntax errors near "})" (no additional comments, the
error is just "syntax error").
The line where the error resides is:

 $rows[$i] .=
$props{DrawCallback}($$column{FieldName},$key,$$row{$$column{FieldName}});

How do I make this version compartable? I tried googling it, but i canot
really come up with good word combo to find something appropriate.






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

Date: Sat, 24 Jul 2004 09:10:23 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: function reference errors...
Message-Id: <slrncg4ref.5u6.tadmc@magna.augustmail.com>

Sergei Shelukhin <raven_at@home.domonet.ru> wrote:

> Now, there's a version problem. I have ActiveState Perl installed both at
> work and at home; of course, both boxes are running Windows, and the script
> is working as it should.


Hmmm, I dunno what's going on with that...


> However, when I tried launching the script on my Linux box (Perl version is
> 5.005_03), it returned syntax errors near "})" (no additional comments, the
> error is just "syntax error").
> The line where the error resides is:


The line reported in the error message is NOT necessarily the
line where the error is.

The line reported is the line where perl _noticed_ that there
is a syntax error. The actual error may be several lines before
the line reported.


>  $rows[$i] .=
> $props{DrawCallback}($$column{FieldName},$key,$$row{$$column{FieldName}});
                     ^^
                     ^^

Don't you need to _de_reference the coderef?


   $props{DrawCallback}->( ... );
                       ^^
                       ^^

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


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

Date: 24 Jul 2004 18:49:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: function reference errors...
Message-Id: <cduavb$4mp$1@mamenchi.zrz.TU-Berlin.DE>

Tad McClellan  <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> Sergei Shelukhin <raven_at@home.domonet.ru> wrote:
> 
> > Now, there's a version problem. I have ActiveState Perl installed both at
> > work and at home; of course, both boxes are running Windows, and the script
> > is working as it should.
> 
> 
> Hmmm, I dunno what's going on with that...
> 
> 
> > However, when I tried launching the script on my Linux box (Perl version is
> > 5.005_03), it returned syntax errors near "})" (no additional comments, the
> > error is just "syntax error").
> > The line where the error resides is:
> 
> 
> The line reported in the error message is NOT necessarily the
> line where the error is.
> 
> The line reported is the line where perl _noticed_ that there
> is a syntax error. The actual error may be several lines before
> the line reported.
> 
> 
> >  $rows[$i] .=
> > $props{DrawCallback}($$column{FieldName},$key,$$row{$$column{FieldName}});
>                      ^^
>                      ^^
> 
> Don't you need to _de_reference the coderef?
> 
> 
>    $props{DrawCallback}->( ... );
>                        ^^
>                        ^^

In new-ish Perls you don't, apparently.  I'm not too surprised, it's
in the spirit of leaving out the arrow between brackets, which has
been around all along.  But I'm not too surprised either that this
doesn't work for subrefs in earlier versions.  The documentation in
perlref only talks about [] and {}.

To the OP:  Do both, add the arrow, and upgrade Perl on that machine.
The arrow-dropping mechanism should be used sparingly.  As a rule,
use it only when a series of arrows can be removed, not for a single
one.

Anno


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

Date: 24 Jul 2004 08:39:31 -0700
From: timrichardson@yahoo.com (Tim Richardson)
Subject: Generic fingerprint ie hash value for compex data structure?
Message-Id: <62c3a3a6.0407240739.2279315e@posting.google.com>

I am doing a depth-first generative search with a recursive algorithm.
My problem can return to a node already visited. I need to know this,
otherwise I could end up in loops. I think this is not unlike a chess
program, which I think solves the problem by a "hash table", which
quickly lets the search algorithm realise it is somewhere it has
already been.

I can also make a unique value for each node, and add this to a
special hash. I wonder if there is a good generic way to do this?
Using Digest::MD5 or something like it perhaps?

For sure I am reinventing the wheel, but this is a hobby program as I
try to improve my Perl.

Tim


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

Date: 24 Jul 2004 16:22:06 GMT
From: ctcgag@hotmail.com
Subject: Re: Generic fingerprint ie hash value for compex data structure?
Message-Id: <20040724122206.124$G9@newsreader.com>

timrichardson@yahoo.com (Tim Richardson) wrote:
> I am doing a depth-first generative search with a recursive algorithm.
> My problem can return to a node already visited. I need to know this,
> otherwise I could end up in loops. I think this is not unlike a chess
> program, which I think solves the problem by a "hash table", which
> quickly lets the search algorithm realise it is somewhere it has
> already been.

Well, I would think the best way would be to have some kind of marker in
the nodes themselves, indicating whether or not they have been visited.

> I can also make a unique value for each node, and add this to a
> special hash. I wonder if there is a good generic way to do this?
> Using Digest::MD5 or something like it perhaps?

What would you be doing the digest on?  whatever you would be doing the
digest on, why not just use the undigested thing directly?

Is this a multi-threaded program where something else may be changing the
structures while the depth-first search is running?

If your nodes are perl objects (i.e. blessed references), how about just
using the stringified references?

Xho

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


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

Date: 26 Jul 2004 11:01:56 -0700
From: timrichardson@yahoo.com (Tim Richardson)
Subject: Re: Generic fingerprint ie hash value for compex data structure?
Message-Id: <62c3a3a6.0407261001.1ddbc7ba@posting.google.com>

> 
> Well, I would think the best way would be to have some kind of marker in
> the nodes themselves, indicating whether or not they have been visited.
Hmm. I am making each new state recursively from existing states, but
my code has no graph knowledge, ie it does not know how it got to
where it is.  I could do this, it is fairly easy and I think in many
cases this would be the most efficient way to go.

> 
> > I can also make a unique value for each node, and add this to a
> > special hash. I wonder if there is a good generic way to do this?
> > Using Digest::MD5 or something like it perhaps?
> 
> What would you be doing the digest on? 
The "serialised" value of the object instance (from Data::Dumper)
> digest on, why not just use the undigested thing directly?
Yes, you're right, on first thought I was worried about how perl copes
with long hash keys but it's going to be a very special case where the
overhead of Digest is lower than whatever problems perl may have with
long keys. In fact I was being very silly; I know nothing about Perl
internals but this can not be a problem.

> 
> Is this a multi-threaded program where something else may be changing the
> structures while the depth-first search is running?
no

> 
> If your nodes are perl objects (i.e. blessed references), how about just
> using the stringified references?

because the memory allocator will not be smart enough to know that my
new state representation is the same as existing ones, it is an object
equivalence problem (cf the allegedly missing === operator).

> 
> Xho
I ended up making a special low cost state string; I hope I got it
right. Perhaps I will test it by using Data::Dumper.


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

Date: 27 Jul 2004 15:59:31 GMT
From: ctcgag@hotmail.com
Subject: Re: Generic fingerprint ie hash value for compex data structure?
Message-Id: <20040727115931.057$rR@newsreader.com>

timrichardson@yahoo.com (Tim Richardson) wrote:

> > > I can also make a unique value for each node, and add this to a
> > > special hash. I wonder if there is a good generic way to do this?
> > > Using Digest::MD5 or something like it perhaps?
> >
> > What would you be doing the digest on?

> The "serialised" value of the object instance (from Data::Dumper)

From what you say later, I would be worried about this.  I think that
Hashes which are formally identical, but which have different histories,
can possibly serialize differently.  So if you do this, I'd set
$Data::Dumper::Sortkeys.

> > Is this a multi-threaded program where something else may be changing
> > the structures while the depth-first search is running?
> no
>
> >
> > If your nodes are perl objects (i.e. blessed references), how about
> > just using the stringified references?
>
> because the memory allocator will not be smart enough to know that my
> new state representation is the same as existing ones, it is an object
> equivalence problem (cf the allegedly missing === operator).

Hmmm.  I think this is somewhat unusual.  In the graph programs I've worked
on, it was always legal for two different nodes to have identical external
labelling and yet still be different entities.  If this is not the case
for you, then I would think the labelling that constrains you from having
duplicates would also serve as the key for holding in a marker hash.

Xho

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


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

Date: Thu, 29 Jul 2004 06:18:52 GMT
From: Ron Savage <ron@savage.net.au>
Subject: Getopt::Simple V 1.47
Message-Id: <I1qH80.3HM@zorch.sf-bay.org>

The pure Perl module Getopt::Simple V 1.47
is available immediately from CPAN,
and from http://savage.net.au/Perl-modules.html.

On-line docs, and a *.ppd for ActivePerl are also
available from the latter site.

An extract from the docs:

1.47  Tue Jul 20 20:43:00 2004
	- Change Makefile.PL to coexist with Module::Build
	- Document parameters properly
	- Test against Getopt::Long V 2.34
	- Add t/pod.t to test all PODs
--
Cheers
Ron Savage, ron@savage.net.au on 29/07/2004
http://savage.net.au/index.html




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

Date: Tue, 27 Jul 2004 10:58:56 GMT
From: "George Kinley" <georgekinley@hotmail.com>
Subject: Getting Text Value , in Single line
Message-Id: <QzqNc.21308$k4.419340@news1.nokia.com>

I have a String, which is long Path of a file 
for example "c:\kl\w\e\l\pol....\FileName.EXT" now I want to have
"FileName" out of this Sting, I can very well do it by writing a few l
lines of code, can it be done in single line,

-- 


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

Date: Tue, 27 Jul 2004 11:13:21 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Getting Text Value , in Single line
Message-Id: <lNqNc.14204$PK5.2687@nwrddc02.gnilink.net>

George Kinley wrote:
> I have a String, which is long Path of a file
> for example "c:\kl\w\e\l\pol....\FileName.EXT" now I want to have
> "FileName" out of this Sting, I can very well do it by writing a few l
> lines of code, can it be done in single line,

use File::Basename;
($name,$path,$suffix) = fileparse($fullname,@suffixlist);

Ok, that's two lines, but correctness is more important then shortness, even
in Perl golf.

jue




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

Date: Tue, 27 Jul 2004 13:02:32 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Getting Text Value , in Single line
Message-Id: <270720041302328707%jgibson@mail.arc.nasa.gov>

In article <QzqNc.21308$k4.419340@news1.nokia.com>, George Kinley
<georgekinley@hotmail.com> wrote:

> I have a String, which is long Path of a file 
> for example "c:\kl\w\e\l\pol....\FileName.EXT" now I want to have
> "FileName" out of this Sting, I can very well do it by writing a few l
> lines of code, can it be done in single line,

my( $filename ) = ($String =~ m|([^\\]+)\.\w+$|);

If the pattern match fails, then $filename will be empty.


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

Date: Tue, 27 Jul 2004 17:22:16 -0400
From: Mladen Gogala <gogala@sbcglobal.net>
Subject: Re: Getting Text Value , in Single line
Message-Id: <pan.2004.07.27.21.22.16.401091@sbcglobal.net>

On Tue, 27 Jul 2004 10:58:56 +0000, George Kinley wrote:

> I have a String, which is long Path of a file 
> for example "c:\kl\w\e\l\pol....\FileName.EXT" now I want to have
> "FileName" out of this Sting, I can very well do it by writing a few l
> lines of code, can it be done in single line,

$ pwd
/home/mgogala/Business/work
$ pwd|perl -ne '$A=(split(/\//))[-1]; print $A;'
work
$


-- 
A city is a large community where people are lonesome together.



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

Date: 29 Jul 2004 07:53:52 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: Getting Text Value , in Single line
Message-Id: <4108ad10$0$7116$db0fefd9@news.zen.co.uk>

On Tue, 27 Jul 2004 13:02:32 -0700, Jim Gibson
			    <jgibson@mail.arc.nasa.gov> wrote:
>
>  my( $filename ) = ($String =~ m|([^\\]+)\.\w+$|);
>

Which fails nicely if .EXT doesn't match \w+ - the OP mentioned no such
restriction.

  my( $filename ) = ($String =~ m|([^\\/]+)\.[^.]+$|);

would be better, but the best thing to do is use fileparse(), as someone else
suggested, which will Do The Right Thing.

--
Cheers,
Dave.



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

Date: Mon, 02 Aug 2004 09:40:11 +0200
From: Tony Muler <t_lawetta@yahoo.com>
Subject: Re: Getting Text Value , in Single line
Message-Id: <410defdd$1@news.vo.lu>

George Kinley wrote:
> I have a String, which is long Path of a file 
> for example "c:\kl\w\e\l\pol....\FileName.EXT" now I want to have
> "FileName" out of this Sting, I can very well do it by writing a few l
> lines of code, can it be done in single line,

Looks like you want anything between the last path separator
and the last dot in the full path?

my $full = 'c:\kl\w\e\l\pol....\FileName.EXT';
my ($base) = $full =~ /.*\\(.*)\..*/;

This works also for pathnames with less '....' ;-)

But as someone mentioned already:
File::Basename might do it better.

T.




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

Date: Tue, 03 Aug 2004 09:12:06 GMT
From: Noname <Some.One@hotmail.com>
Subject: getting Values out of  <Array>
Message-Id: <GFIPc.21595$g4.409960@news2.nokia.com>

I am not able to find any litrature on
why?
$Value="@Array" gives the values from an array


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

Date: 3 Aug 2004 09:39:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: getting Values out of  <Array>
Message-Id: <cenmh1$p7h$1@mamenchi.zrz.TU-Berlin.DE>

Noname  <Some.One@hotmail.com> wrote in comp.lang.perl.misc:
> I am not able to find any litrature on
> why?
> $Value="@Array" gives the values from an array

perldoc perldata.  Look for the paragraph that begins "Arrays and slices
are interpolated...".

Anno


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

Date: Tue, 27 Jul 2004 21:14:59 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: glob function and getting directory contents
Message-Id: <ZSuNc.22$5c3.122@news.oracle.com>

Hi,

I have a somewhat trivial problem, on which some input would be highly 
appreciated.

I want to get the list of all the files in the current directory, whose 
names are in the format

[0-9]+.xml
i.e. all files whose names are of the format <positive integer>.xml

I was hoping to do it with glob(), but I cannot come up with a pattern 
which will be able to do this.

In fact, it seems (according to responses to my thread on 
comp.os.linux.misc) that this is not possible ?

Would appreciate any pointers on how this could be done.

Regards

--
Abhinav


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

Date: Tue, 27 Jul 2004 11:54:42 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: glob function and getting directory contents
Message-Id: <20040727115224.K2467@barbara.cs.rpi.edu>

On Tue, 27 Jul 2004, Abhinav wrote:

> Hi,
>
> I have a somewhat trivial problem, on which some input would be highly
> appreciated.
>
> I want to get the list of all the files in the current directory, whose
> names are in the format
>
> [0-9]+.xml
> i.e. all files whose names are of the format <positive integer>.xml
>
> I was hoping to do it with glob(), but I cannot come up with a pattern
> which will be able to do this.
>
> In fact, it seems (according to responses to my thread on
> comp.os.linux.misc) that this is not possible ?

Why do you want to use glob?

open my $dir, '.' or die "Cannot open current directory: $!";
my @files = grep /^\d+\.xml$/, readdir($dir);


If you really want to use glob, I suppose you could also do:
my @files = grep /^\d+\.xml$/, glob('*');

Paul Lalli


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

Date: Tue, 27 Jul 2004 21:32:53 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: Re: glob function and getting directory contents
Message-Id: <L7vNc.23$5c3.21@news.oracle.com>

Paul Lalli wrote:

> On Tue, 27 Jul 2004, Abhinav wrote:
> 
> 
>>Hi,
>>
>>I have a somewhat trivial problem, on which some input would be highly
>>appreciated.
>>
>>I want to get the list of all the files in the current directory, whose
>>names are in the format
>>
>>[0-9]+.xml
>>i.e. all files whose names are of the format <positive integer>.xml
>>
>>I was hoping to do it with glob(), but I cannot come up with a pattern
>>which will be able to do this.
>>
>>In fact, it seems (according to responses to my thread on
>>comp.os.linux.misc) that this is not possible ?
> 
> 
> Why do you want to use glob?
> 

Because I thought that this would be the simplest way to do it. But maybe not

> open my $dir, '.' or die "Cannot open current directory: $!";
> my @files = grep /^\d+\.xml$/, readdir($dir);
> 
> 
> If you really want to use glob, I suppose you could also do:
> my @files = grep /^\d+\.xml$/, glob('*');

Thanks ! This will do well enough !

Regards

--
Abhinav


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

Date: Tue, 27 Jul 2004 12:09:55 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: glob function and getting directory contents
Message-Id: <20040727120420.O2467@barbara.cs.rpi.edu>

On Tue, 27 Jul 2004, Abhinav wrote:

> Paul Lalli wrote:
>
> > On Tue, 27 Jul 2004, Abhinav wrote:
> >
> >
> >>Hi,
> >>
> >>I have a somewhat trivial problem, on which some input would be highly
> >>appreciated.
> >>
> >>I want to get the list of all the files in the current directory, whose
> >>names are in the format
> >>
> >>[0-9]+.xml
> >>i.e. all files whose names are of the format <positive integer>.xml
> >>
> >>I was hoping to do it with glob(), but I cannot come up with a pattern
> >>which will be able to do this.
> >>
> >>In fact, it seems (according to responses to my thread on
> >>comp.os.linux.misc) that this is not possible ?
> >
> >
> > Why do you want to use glob?
>
> Because I thought that this would be the simplest way to do it. But maybe not

glob is useful for filename expansion, as the csh shell would do it.  That
is, it will expand '~mritty' to /users/mritty  or "*.c" to a list of all
files ending in .c.  If you have anything more complex than that, I'd
recommend using Perl's RegExps, which are far more powerful.

> > open my $dir, '.' or die "Cannot open current directory: $!";
> > my @files = grep /^\d+\.xml$/, readdir($dir);
> >
> >
> > If you really want to use glob, I suppose you could also do:
> > my @files = grep /^\d+\.xml$/, glob('*');
>
> Thanks ! This will do well enough !

Quite Welcome.

Paul Lalli


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

Date: Wed, 28 Jul 2004 20:01:40 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: glob function and getting directory contents
Message-Id: <2mp4rsFp3llhU1@uni-berlin.de>


"Paul Lalli" <mritty@gmail.com> wrote in message
news:20040727115224.K2467@barbara.cs.rpi.edu...
> On Tue, 27 Jul 2004, Abhinav wrote:
>
> > Hi,
> >
> > I have a somewhat trivial problem, on which some input would be highly
> > appreciated.
> >
> > I want to get the list of all the files in the current directory, whose
> > names are in the format
> >
> > [0-9]+.xml
> > i.e. all files whose names are of the format <positive integer>.xml
> >
> > I was hoping to do it with glob(), but I cannot come up with a pattern
> > which will be able to do this.
> >
> > In fact, it seems (according to responses to my thread on
> > comp.os.linux.misc) that this is not possible ?
>
> Why do you want to use glob?
>
> open my $dir, '.' or die "Cannot open current directory: $!";
> my @files = grep /^\d+\.xml$/, readdir($dir);
>
>
> If you really want to use glob, I suppose you could also do:
> my @files = grep /^\d+\.xml$/, glob('*');

or a variation on that:

foreach my $file (<*.xml>) {
  next unless $file =~ /^\d+\.xml$/;
  ..
}




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

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


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