[24285] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6476 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 27 11:05:54 2004

Date: Tue, 27 Apr 2004 08:05:08 -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, 27 Apr 2004     Volume: 10 Number: 6476

Today's topics:
    Re: A1 Triple Gold Star for Robin <uri@stemsystems.com>
    Re: free source blogger (works) <uri@stemsystems.com>
    Re: free source blogger (works) <uri@stemsystems.com>
    Re: free source blogger (works) <remorse@partners.org>
    Re: Ignore errors inserting dup records? <remorse@partners.org>
    Re: Ignore errors inserting dup records? ctcgag@hotmail.com
    Re: Ignore errors inserting dup records? ctcgag@hotmail.com
        Is it possible to choose a better way? <nospam_@shaw.ca>
        Newbie : How to exclude particular files from glob()? <matrix_calling@yahoo.dot.com>
    Re: Newbie : How to exclude particular files from glob( <thepoet_nospam@arcor.de>
    Re: Newbie : How to exclude particular files from glob( <xx087@freenet.carleton.ca>
    Re: Newbie : How to exclude particular files from glob( <matrix_calling@yahoo.dot.com>
        Newbie: Looking for comments on this (working) script <treborrude@SPAMBGONE.comcast.net>
    Re: other perl groups <jboes@qtm.net>
        perl & Mac G4 <King@ask.for.email.invalid>
    Re: perl & Mac G4 <kevin@vaildc.net>
        Perl scares me ... <richard@zync.co.uk>
    Re: Please Recommend A Good Perl Book. <jboes@qtm.net>
    Re: sending data from one program to a perl prog <noreply@gunnar.cc>
    Re: sort numeric lists (Anno Siegel)
    Re: SV_TYPE_* constants? <ThomasKratz@REMOVEwebCAPS.de>
    Re: variable scope and use strict <PerlGuRu2b@bobotheclown.org>
    Re: variable scope and use strict <tadmc@augustmail.com>
    Re: variable scope and use strict <remorse@partners.org>
    Re: variable scope and use strict <dwall@fastmail.fm>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 27 Apr 2004 13:22:18 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: A1 Triple Gold Star for Robin
Message-Id: <x7n04xa73p.fsf@mail.sysarch.com>

>>>>> "Jd" == Julia deSilva <jds@nospantrumpetweb.co.uk> writes:

  Jd> Many Congratulations to Robin.

  Jd> How does this guy (or gal) do it, I mean, how is it possible to
  Jd> take such stick, stay cool and come back for more. Many others
  Jd> have got themselves into similar situations in this NG and have
  Jd> ended up taking offence, being rude, and then getting plonked, or
  Jd> worse.

he is too dumb to know better? notice he seems to think moronzilla has a
clue.

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: Tue, 27 Apr 2004 13:20:18 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: free source blogger (works)
Message-Id: <x7pt9ta771.fsf@mail.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> Uri Guttman  <uri.guttman@fmr.com> wrote in comp.lang.perl.misc:
  >> >>>>> "R" == Robin  <robin @ infusedlight.net> writes:

  >> winblows runs but it doesn't work. hell, it has no spec at all
  >> so it will never 'work'.

  AS> Careful there...  Perl doesn't have specs either :)

but it does have a moby amount of tests and docs which do form a spec of
sorts. nothing formal mind you but someone (crazy enough) could build
another version from that and know when they have gotten it
'working'. consider the ponie project as such a beast.

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: Tue, 27 Apr 2004 13:44:24 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: free source blogger (works)
Message-Id: <x7r7u9a77l.fsf@mail.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> Uri Guttman  <uri.guttman@fmr.com> wrote in comp.lang.perl.misc:
  >> >>>>> "R" == Robin  <robin @ infusedlight.net> writes:

  >> winblows runs but it doesn't work. hell, it has no spec at all
  >> so it will never 'work'.

  AS> Careful there...  Perl doesn't have specs either :)

but it does have a moby amount of tests and docs which do form a spec of
sorts. nothing formal mind you but someone (crazy enough) could build
another version from that and know when they have gotten it
'working'. consider the ponie project as such a beast.

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: Tue, 27 Apr 2004 10:18:13 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: free source blogger (works)
Message-Id: <remorse-02D82B.10181327042004@plato.harvard.edu>

In article <slrnc8r3n4.q1d.tadmc@magna.augustmail.com>,
 Tad McClellan <tadmc@augustmail.com> wrote:

> Robin <robin@infusedlight.net> wrote:
> 
> > some of it is just sucky advice though, for example, the
> > fact that I'm using if (! ) instead of unless makes no difference.
> 
> 
> Yes it does. You just have not been programming long enough to 
> recognize the difference.
> 
> You are communicating with the reader of your code.
> 
> If it communicates more clearly, then it is NON-sucky.

Truth to tell, I usually side with Robin on this one.  'unless' makes my 
head hurt in most cases.  I usually find 'if (!defined...)' or such to 
make more sense, because they are positive assertions, which usually 
meshes better with the way I think.

I do find that 'unless' works well for a statement modifier (ie, 'next 
unless m/\S/').  But 'unless ($test) { ... }' is often confusing.

Ricky

-- 
Pukku


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

Date: Tue, 27 Apr 2004 09:49:20 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: Ignore errors inserting dup records?
Message-Id: <remorse-B7E678.09492027042004@plato.harvard.edu>

In article <pan.2004.04.26.22.03.22.916075@aursand.no>,
 Tore Aursand <tore@aursand.no> wrote:

> You probably want to do this:
> 
>   INSERT INTO T (v) VALUES ('The'), ('walrus'), ('was'), ('Paul')
> 
> The above is a multiline insert which will work fine, and if you have
> defined the 'v' column to be unique, it'll be impossible to insert any
> duplicate data into it.

This will depend on the database backend.  Oracle 8i, at least, doesn't 
seem to support multiline inserts.  (If I'm wrong, _please_ someone tell 
me!)

So it may be necessary to do something like:

my $sql = "insert into t (v) values (?)";
my $sth = $db->prepare($sql);
foreach (qw/the walrus was paul/) {
   $sth->execute($_);
}
$sth->finish();

HTH,
Ricky

-- 
Pukku


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

Date: 27 Apr 2004 14:37:24 GMT
From: ctcgag@hotmail.com
Subject: Re: Ignore errors inserting dup records?
Message-Id: <20040427103724.474$9X@newsreader.com>

mnemotronic@yahoo.com (pt) wrote:
> spamtotrash@toomuchfiction.com (Kevin Collins) wrote in message
> news:<slrnc8r0qi.dsd.spamtotrash@doom.unix-guy.com>...
> > In article <da662010.0404261328.3a6a1845@posting.google.com>, pt wrote:
> > > I have a table "T" with an autonum primary key field "ID" and a
> > > text/string field "v".  The field "v" is indexed and declared UNIQUE.
> > > Is there a syntax which will allow me to add records and ignore (or
> > > not add) any which would violate the "unique" aspect of "v"?
> > >
> > > Table "T":
> > > ID v
> > > ----
> > > 1 I
> > > 2 am
> > > 3 the
> > > 4 walrus
> > > 5 oo
> > > 6 koo
> > > 7 katchoo
> > >
> > > Given this table, I run this :
> > > INSERT INTO T (v) VALUES ("The" , "walrus" , "was" , "Paul") ;
> > >
> > > The insertion of "walrus" will fail because it already exists, and
> > > "v" is indexed/no_dups.  I want the SQL to insert records for "The",
> > > "was", and "Paul", and not error when in sees "walrus" already
> > > present at record #4.

MySQL has the "INSERT IGNORE" syntax, I don't know if Access does or not.


> > No, it won't. It will fail because you are trying to insert 4 column
> > values into a table which has oonly 1 column!
>
> You noticed that SQL isn't my strong suite.  Are you saying the only
> way to insert 4 rows is to execute 4 individual SQL statements?

It certainly isn't the only way.  You can also use a vector of values,
if Access supports it.  ...values ("The"),("walrus"),("was")....


> Sounds like a lot of overhead.  Is there another way?

Both Oracle and MySQL have specific bulk loading tools you can use.  I
don't know if access does or not.

> What if I have
> not 4, but 40,000 records I want to insert?

Probably the best solution is call insert 40,000 times.  It isn't like
you have to carry the bits over the data bus/ethernet by hand.  If the
performance is absolutely critical, well, I probably wouldn't use Access
anyway.

>
> > >
> > > I'm doing this with Perl + DBI/DBD (not ODBC) talking to a MS-Access
> > > .MDB file.

If you are using RaiseError, you could wrap your insert in eval {} and
catch the unique key violation error.  But with a vectorized insert, I
don't know if it would insert all values other than the errors, all values
upto the first error, or none of the values.  You'd have to look in the
Access documentation or just try it and see.

Xho

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


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

Date: 27 Apr 2004 14:41:12 GMT
From: ctcgag@hotmail.com
Subject: Re: Ignore errors inserting dup records?
Message-Id: <20040427104112.882$cM@newsreader.com>

Richard Morse <remorse@partners.org> wrote:
> In article <pan.2004.04.26.22.03.22.916075@aursand.no>,
>  Tore Aursand <tore@aursand.no> wrote:
>
> > You probably want to do this:
> >
> >   INSERT INTO T (v) VALUES ('The'), ('walrus'), ('was'), ('Paul')
> >
> > The above is a multiline insert which will work fine, and if you have
> > defined the 'v' column to be unique, it'll be impossible to insert any
> > duplicate data into it.
>
> This will depend on the database backend.  Oracle 8i, at least, doesn't
> seem to support multiline inserts.  (If I'm wrong, _please_ someone tell
> me!)

And if it did, I still wouldn't use them.  It is difficult to use
those inserts with bind variables, and bind variables are the way to
go, especially with Oracle.

Xho

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


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

Date: Tue, 27 Apr 2004 13:07:30 GMT
From: "Alpha" <nospam_@shaw.ca>
Subject: Is it possible to choose a better way?
Message-Id: <mWsjc.266182$Pk3.205820@pd7tw1no>

   With spring in full swing, summer approaching, and the end of school just
round the corner, many people will be looking forward to a summer of low
wage work in the primary service industries.
Although there might not be anything wrong with simple honest work
Ask yourself if you would prefer smarter work, that produces more, or
simpler work, that produces less? Although the answer to this
question may seem clear what is not so apparent is
a way you could actually produce more, and with
greater success, than the way you are currently following.
Although all paths lead somewhere they do not all lead to the right place.
If you’re tired of where yours is taking you, give ours a try
We give you ten alternatives over the path of marginal utility
Ten individual ways we believe to be more socially
responsible, productive, and efficient, than what you might choose this summer.
If you’re on the path offering little reward, give ours a try, we guarantee
you’ll be the better for it, or your money back

All we’re offering is a choice
Make the right choice, and free yourself today

To receive fast confidential delivery send 10* to:

DELTA
BOX 8176
Victoria  BC  V8W 3R8
CANADA

To assure a prompt and safe delivery, please:
1. Fold payment* inside a piece of scrap paper before placing in envelope
2. Clearly write your name and mailing address on the back of the envelope
3. Clearly write our address on the front of the envelope
4. Affix sufficient postage** (return shipping is included for all destinations)

*We accept payment in Euros, British, Canadian, and American paper currency
  -other regions may send international money orders payable in any of the above
   currencies

**For the USA, including Hawaii and Alaska, the UK, most parts of
Western Europe, and Australia, three standard stamps ,or one international stamp,
will supply ample postage
-orders originating from other regions may need additional stamps
-if in doubt add an extra stamp, or check with your postal service



Please allow 1-2 weeks for delivery within North America
Other destinations may take longer







Delta, its employees, representatives, and agents, will not be held liable for any
improper, or illegal use of our products.
By ordering our products you agree that you will use them in a spirit they where
designed to be used in.
This may include legal responsibilities your country imposes, or other restrictions.
It is up to you to inform yourself of, and ensure compliance to, any legal
restrictions your country imposes. These rules, and other rules, are included with
all of our products. You must agree to these rules before you use any of our products.
Any purpose for our products, other than for information,
is the sole responsibility of the individual.







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

Date: Tue, 27 Apr 2004 18:49:40 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: Newbie : How to exclude particular files from glob()?
Message-Id: <vctjc.14$BD6.239@news.oracle.com>

Hi

I need to do an glob on a Directory, but exclude a set of  particular 
file starting with "Master" .

Using

my @x =  <[!M][!a][!s][!t][!e][!r]*>;

  is definitely wrong ..It omits files such as "Faster" too ..

What is the correct way to do it .. ?

Thanks
Abhinav



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

Date: Tue, 27 Apr 2004 15:35:37 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Newbie : How to exclude particular files from glob()?
Message-Id: <408e61a9$0$10887$9b4e6d93@newsread2.arcor-online.net>

Abhinav schrieb:
> Hi
> 
> I need to do an glob on a Directory, but exclude a set of  particular 
> file starting with "Master" .
> 
> Using
> 
> my @x =  <[!M][!a][!s][!t][!e][!r]*>;
> 
>  is definitely wrong ..It omits files such as "Faster" too ..
> 
> What is the correct way to do it .. ?

I don't know csh very well, so maybe there's a really simple
solution using standard glob syntax, but I'd do it like this:

my @x = grep !/^Master/, <*>;

HTH
-Christian


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

Date: 27 Apr 2004 13:51:11 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Newbie : How to exclude particular files from glob()?
Message-Id: <slrnc8spah.7o8.xx087@smeagol.ncf.ca>

Abhinav <matrix_calling@yahoo.dot.com> wrote:
>  Hi
>  
>  I need to do an glob on a Directory, but exclude a set of  particular 
>  file starting with "Master" .
>  
>  Using
>  
>  my @x =  <[!M][!a][!s][!t][!e][!r]*>;
>  
>    is definitely wrong ..It omits files such as "Faster" too ..
>  
>  What is the correct way to do it .. ?

One way is to filter the list of all files:  
    my @x = grep !/^Master/, <*>;

-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


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

Date: Tue, 27 Apr 2004 20:21:34 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: Re: Newbie : How to exclude particular files from glob()?
Message-Id: <Eyujc.27$BD6.287@news.oracle.com>

Hi Glenn/Christian,

Glenn Jackman wrote:
> Abhinav <matrix_calling@yahoo.dot.com> wrote:
> 
>> Hi
>> 
>> I need to do an glob on a Directory, but exclude a set of  particular 
>> file starting with "Master" .
>> 
>> Using
>> 
>> my @x =  <[!M][!a][!s][!t][!e][!r]*>;
>> 
>>   is definitely wrong ..It omits files such as "Faster" too ..
>> 
>> What is the correct way to do it .. ?
> 
> 
> One way is to filter the list of all files:  
>     my @x = grep !/^Master/, <*>;
> 
Thanks !
Regards
Abhinav



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

Date: Tue, 27 Apr 2004 13:51:58 GMT
From: "Trebor A. Rude" <treborrude@SPAMBGONE.comcast.net>
Subject: Newbie: Looking for comments on this (working) script
Message-Id: <2Atjc.42186$GR.5866053@attbi_s01>

I've been trying to learn Perl in recent days, and was hoping the group
could offer some pointers on my first attempt to do something useful (to
me, anyway) with it. To that end, any constructive comments, suggestions,
etc. on this script would be appreciated.

The script takes a list of .ogg files on the command line and reads the tag
information from them (which come out in "key=value" form), then uses it to
construct a command to put the same tag information into a
corresponding .mp3 file (I prefer .oggs for listening on my computer, but
my car's CD player only works with audio or MP3 CDs). Here it is:

#!/usr/bin/perl

use warnings;
use strict;
use vars '$file';

my %options = (title => '-t',
               artist => '-a',
               album => '-A',
               tracknumber => '-T');

sub run_id3v2 (@)
{
  my @command = ("id3v2", @_, $file);
  return system(@command) == 0;
}

foreach (@ARGV)
{
  $file = $_;
  my @output = `vorbiscomment -l \Q$file\E 2>&1`;

  if ($? != 0)
  {
    print "Problems reading tags from $file, skipping it:\n", @output;
    next;
  }

  my %comments = map { chomp; split /=/, $_, 2 } @output;

  my @arguments = ();

  # Also considered using (if this is strange indentation, thank
  # cperl-mode):
  #
  # push @arguments,
  #   map {($options{$_}, $comments{$_})}
  #     grep exists $options{$_}, keys %comments;

  push @arguments,
    map {exists $options{$_} ? ($options{$_}, $comments{$_}) : ()}
      keys %comments;

  $file =~ s/\.ogg/.mp3/;

  run_id3v2('-D') or die "Problem removing old tags from $file.";
  run_id3v2(@arguments) or die "Problem adding new tags to $file.";
  run_id3v2('-s') or die "Problem removing new id3v1 tags from $file.";
}



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

Date: Tue, 27 Apr 2004 14:00:56 GMT
From: Jeff Boes <jboes@qtm.net>
Subject: Re: other perl groups
Message-Id: <55fe5cc6441aa93585c4b4428a4d28ab@news.teranews.com>

pfancy wrote:
> Are the any other perl groups who will actually help out people who are NEW
> to perl.
> 
> 

The following resources should be investigated when looking for starting 
points in learning or improving your Perl skills:

http://learn.perl.org/

http://perlmonks.org/

http://perl.com/pub/q/resources

As with many such free training resources, you get only modestly more 
than you pay for, and no more than what you put in. Your *best* approach 
for learning Perl is to find a college-level course in programming Perl 
(if you already know a computer language). If you know nearly nothing 
about programming (hint: how many of the following terms could you 
define without recourse to a book? function, compiler, variable, control 
structure, debug, loop. If your answer wasn't "all of them", then maybe 
you need to learn how to program *first*), then you should investigate a 
100-level course in programming using nearly *any* language, and only 
*then* come back to Perl. (If you can find a college-level class in 
learning to program that uses Perl, congratuate yourself on extreme good 
fortune.)

Do not take the advice in this message as an insult to you. I do not 
know your programming background, so I'm assuming the worst. Also, 
messages like this get read by dozens of other seekers of Perl help, so 
I'm writing for them, too.

As to the other respondents to this thread that jumped on the original 
poster for the perceived insult to "the group", *rather* than offering 
help, shame on you.

-- 
(Posted from an account used as a SPAM dump. If you really want to get
in touch with me, dump the 'jboes' and substitute 'mur'.)
________
Jeffery Boes <>< jboes@qtm.net


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

Date: Tue, 27 Apr 2004 14:12:00 GMT
From: The King of Pots and Pans <King@ask.for.email.invalid>
Subject: perl & Mac G4
Message-Id: <QStjc.4976$Jy3.2087@fed1read03>

I am thinking about getting a Powerbook G4. Does perl work on it?

-- 
The King of Pots and Pans


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

Date: Tue, 27 Apr 2004 14:35:31 GMT
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: perl & Mac G4
Message-Id: <kevin-510A77.10352927042004@news.verizon.net>

In article <QStjc.4976$Jy3.2087@fed1read03>,
 The King of Pots and Pans <King@ask.for.email.invalid> wrote:

> I am thinking about getting a Powerbook G4. Does perl work on it?

Yes.
-- 
Found Poetry (_Science News_, 14-Jun-2003): oldest _homo sapiens_ find
+-----------------------------------------+ ocean eddies' far-flung effects;
|  Kevin Michael Vail <kevin@vaildc.net>  | superior threads spun
+-----------------------------------------+ the pox from prairie dogs.


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

Date: Tue, 27 Apr 2004 15:27:10 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Perl scares me ...
Message-Id: <c6lqjn$kgc$1@news.freedom2surf.net>

While trying to work out the syntax for building a dispatch table of
coderefs from strings in a database I had occasion to construct the
following:

#!/usr/bin/perl

use strict;
use warnings;

my $one = "mysub";

sub mysub {
    print shift,"\n";
}

#1
{
    no strict 'refs';
    $one->('scalar');
}

#2
{
    'mysub'->('string');
}

#3
{
    my $subref = \&$one;
    $subref->('subref');
}

This produces the output:

scalar
string
subref

If there was any further proof needed that Perl updates are received in a
back alley somewhere from some dude with red eyes who smells of sulphur
 ... I mean, honestly !!! ;-)

And then there's my slight amazement that #1 needs "no strict 'refs'" and
#2 doesn't ...

Rich


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

Date: Tue, 27 Apr 2004 14:01:58 GMT
From: Jeff Boes <jboes@qtm.net>
Subject: Re: Please Recommend A Good Perl Book.
Message-Id: <7cb2be7b5c6dbef8471598b09800cbbe@news.teranews.com>

http://perl.com/cs/user/query/q/6?id_topic=34



-- 
(Posted from an account used as a SPAM dump. If you really want to get
in touch with me, dump the 'jboes' and substitute 'mur'.)
________
Jeffery Boes <>< jboes@qtm.net


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

Date: Tue, 27 Apr 2004 16:44:08 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: sending data from one program to a perl prog
Message-Id: <c6lrpr$dggnd$1@ID-184292.news.uni-berlin.de>

Joe Smith wrote:
> Gunnar Hjalmarsson wrote:
>> 
>>     my $msg;
>>     my $maxsize = 131072;
>>     unless ($ENV{CONTENT_LENGTH} > $maxsize) {
>>         $msg = do {local $/; <STDIN>};
>> 
>> I'd better add that such a check of message size does not always
>> work. For instance, the sendmail configuration on my own brand
>> new server is so 'secure' so that no %ENV variable at all is
>> present when a process is run as the mail program. Perl's stat()
>> function, i.e. (stat STDIN)[7], does not contain the size
>> either...
>> 
>> Oh, well.
> 
> What about something like
>     my $bytes_read = read STDIN,$msg,$maxsize;
>     unless eof(STDIN) { return 'error'};

Yes, that's it. (But you don't need $bytes_read, do you?) Thanks, Joe!

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 27 Apr 2004 13:31:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: sort numeric lists
Message-Id: <c6lnaq$clf$1@mamenchi.zrz.TU-Berlin.DE>

Robin <robin @ infusedlight.net> wrote in comp.lang.perl.misc:

[50 lines by Uri snipped]

> uri, does my code...(below)...do what he needs?

What code?  And how about testing your code yourself?

You should take a little more care in preparing your articles.  Quoting
fifty lines just to add a single one is not the done thing.  Forgetting
to add necessary text (or to remove large chunks of unwanted text) may
happen once in a while, but with your posts it happens with a regularity
that seems to say you don't care.

Take the time to look over your articles before you post them and make
sure they contain all you want them to contain and nothing you don't
want them to contain.  On Usenet, that's part of common courtesy.

Anno


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

Date: Tue, 27 Apr 2004 16:35:49 +0200
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: SV_TYPE_* constants?
Message-Id: <408e7121.0@juno.wiesbaden.netsurf.de>

FixerDave wrote:

> Hi,
> 
> anyone willing to point me in the right direction for finding information
> on "SV_TYPE_* constants"?  The docs for Win32::NetAdmin say "For flags, see
> SV_TYPE_* constants," with no other mention of them.  I've been running
> around is circles trying to figure out what these are.
> 
> Actually, all I really want is to check ONE stupid little checkbox in NT's
> usermanager for "User must change password at next logon"  Everything else
> works fine...  Oh, I'm trying to avoid using Win32::AdminMisc as I'm on
> ActiveState's 5.8.0 build.  I'm hoping this flag thing will let me make the
> setting I need.
> 
>     David...
> 
> 

In addition to what Tassilo told you, I would strongly reccommend using 
Win32::Lanman for all win32 related net stuff. It's implementation of the 
lanmanager API is AFAIK complete, completely documented and works.

Thomas

-- 
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</  #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..


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

Date: Tue, 27 Apr 2004 13:17:01 GMT
From: Rocky <PerlGuRu2b@bobotheclown.org>
Subject: Re: variable scope and use strict
Message-Id: <pan.2004.04.27.13.13.38.348765@bobotheclown.org>

On Tue, 27 Apr 2004 15:00:50 +0200, Tore Aursand wrote:

> On Tue, 27 Apr 2004 12:46:17 +0000, Rocky wrote:
>> I am trying to use strict all the time now.
> 
> But you don't.  Your code doesn't use strict at all.  It doesn't use
> warnings, either;
> 
>   #!/usr/bin/perl
>   #
>   use strict;
>   use warnings;
I usually put use strict; but didn't here so that the script would work
> 
>> I have a problem with the following code.  When I use strict the value
>> of $highest won't leave the foreach construct.  I know this is by design
>> but I cannot figure out how make that variable available outside the
>> loop.  Any advice?
>> 
>> my $dir = "/etc/backup";
> 
> Needless use of double quotes;
is this because the value of $dir does not contain another variable and
does not need to be interpolated?
> 
>   my $dir = '/etc/backup';
> 
>> opendir DIR1, $dir;
> 
> Always check if 'open()' and 'opendir()' succeeds;
> 
>   opendir( DIR1, $dir ) or die "$!\n";
> 
> Eventually;
> 
>   if ( opendir(DIR1, $dir) ) {
>       closedir( DIR1 );
>   }
>   else {
>       # Something bad happened; Error message in $!
>   }
> Can I open and close a directory before I push it's contents into an
array?
>> my @files = readdir(DIR1);
>> closedir DIR1;
>> foreach my $filename (@files) {
>>         push(@filenum, $1)  if ($filename =~ /^CUX(\d+)\.txt$/); #my
>>         $highest = (sort { $a <=> $b } @filenum)[-1];
>>      }
>>         $highest = (sort { $a <=> $b } @filenum)[-1]; $final = $highest
>>         + $number;
>> print "CUX00" . "$final" . ".txt\n";
> 
> You could always make sure that you have the correct set of files when you
> first read them in with 'readdir';
> 
>   my @files = grep { /^CUX\d+\.txt$/ } readdir( DIR1 );
> 
> It seems to be that you're trying to find the filename which have the
> highest number.  This could be done like this;
> 
>   opendir( DIR1, $dir ) or die "$!\n";
>   my @files = sort { $a <=> $b } grep { /^CUX\d+\.txt$/ } readdir( DIR1 );
>   closedir( DIR1 );
> 
>   print 'Highest valued filename: ' . $files[-1] . "\n";
> your kung foo is very strong
The filename is returned to a korn shell script, but the filename is
highest + 1 so that the korn shell script can create the file and add
details about last night's backups.

>> Also if someone could tell me where to find perldoc regarding "use
>> strict;" or scoping in general I would appreciate it.
> 
> I guess 'perldoc strict' would get you going.
I read the strict perldoc and that was good but I am still missing
something.  
thank you for your help.  


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

Date: Tue, 27 Apr 2004 08:17:02 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: variable scope and use strict
Message-Id: <slrnc8snae.tko.tadmc@magna.augustmail.com>

Rocky <PerlGuRu2b@bobotheclown.org> wrote:

> Also if someone could tell me where to find perldoc regarding "use
> strict;" or scoping in general I would appreciate it.


   perldoc strict

and

   "Coping with Scoping":

      http://perl.plover.com/FAQs/Namespaces.html


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


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

Date: Tue, 27 Apr 2004 10:32:20 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: variable scope and use strict
Message-Id: <remorse-8150A2.10322027042004@plato.harvard.edu>

In article <pan.2004.04.27.12.43.01.8345@bobotheclown.org>,
 Rocky <PerlGuRu2b@bobotheclown.org> wrote:

> I am trying to use strict all the time now.  I have a problem with the
> following code.  When I use strict the value of $highest won't leave the
> foreach construct.  I know this is by design but I cannot figure out how
> make that variable available outside the loop.  Any advice?
> 
> Also if someone could tell me where to find perldoc regarding "use
> strict;" or scoping in general I would appreciate it.
> 
> 
> #!/usr/bin/perl
> my $number = 1;
> my $dir = "/etc/backup";
> opendir DIR1, $dir;
> my @files = readdir(DIR1);
> closedir DIR1;
> foreach my $filename (@files)
>     {
>         push(@filenum, $1)  if ($filename =~ /^CUX(\d+)\.txt$/);
>         #my $highest = (sort { $a <=> $b } @filenum)[-1];
>      }
>         $highest = (sort { $a <=> $b } @filenum)[-1];
>         $final = $highest + $number;
> print "CUX00" . "$final" . ".txt\n";

I _think_ (although I'm not certain), you're asking how to make a 
variable available outside a loop.

Try this example:

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

my $highest;
$highest = 0;
foreach (1 .. 9) {
   if ($_ > $highest) {
      $highest = $_;
   }
}

print $highest, "\n";
__END__

The key point (if I understand your question) is to declare the variable 
before you enter the loop (I also initialized it to 0, so I didn't get a 
warning about uninitialized values being used in the comparison).  Then 
it remains available once you leave the loop.

One trick -- make sure you don't rescope the variable inside the loop 
(ie, don't use 'my $highest' inside the loop), because that would hide 
the original $highest from the statements inside the loop.

HTH,
Ricky

-- 
Pukku


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

Date: Tue, 27 Apr 2004 15:00:19 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: variable scope and use strict
Message-Id: <Xns94D86FF3998C1dkwwashere@216.168.3.30>

Rocky <PerlGuRu2b@bobotheclown.org> wrote:

> On Tue, 27 Apr 2004 15:00:50 +0200, Tore Aursand wrote:
 
>> On Tue, 27 Apr 2004 12:46:17 +0000, Rocky wrote:

>>> my $dir = "/etc/backup";

>> Needless use of double quotes;

> is this because the value of $dir does not contain another
> variable and does not need to be interpolated?

Yes. It's a stylistic choice; like proper indentation, it can make your 
code easier to read. Using single quotes indicates to the reader that 
there's no need to look for variable interpolation, and conversely, 
double quotes are a signal to look for variable interpolation.

It's not a major issue in this case, but using appropriate quoting is a 
good habit to develop.



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

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


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