[25393] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7638 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 12 18:05:39 2005

Date: Wed, 12 Jan 2005 15:05:09 -0800 (PST)
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, 12 Jan 2005     Volume: 10 Number: 7638

Today's topics:
        $! is set to "Inappropriate ioctl..." on Linux amirkargerweb@yahoo.com
    Re: $! is set to "Inappropriate ioctl..." on Linux xhoster@gmail.com
    Re: 20050111: list basics (Jay Tilton)
    Re: Adding a delimiter inbetween number characters and  toomanyjoes@mail.utexas.edu
    Re: Adding a delimiter inbetween number characters and  <news@chaos-net.de>
    Re: Adding a delimiter inbetween number characters and  <spamtrap@dot-app.org>
    Re: Adding a delimiter inbetween number characters and  <abigail@abigail.nl>
    Re: disk space script <jgarretthood@gmail.com>
    Re: disk space script <jgarretthood@gmail.com>
    Re: Looking for strategies for performance improvements <jgibson@mail.arc.nasa.gov>
    Re: Looking for strategies for performance improvements <spamtrap@dot-app.org>
    Re: Looking for strategies for performance improvements <spamtrap@dot-app.org>
    Re: Looking for strategies for performance improvements xhoster@gmail.com
    Re: Looking for strategies for performance improvements <spamtrap@dot-app.org>
    Re: Problem splitting lines from file input <abigail@abigail.nl>
        Use of string var within qw// <joe.cipale@radisys.com>
    Re: Use of string var within qw// <mritty@gmail.com>
    Re: Use of string var within qw// <mritty@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 12 Jan 2005 14:00:57 -0800
From: amirkargerweb@yahoo.com
Subject: $! is set to "Inappropriate ioctl..." on Linux
Message-Id: <1105567257.387610.45040@z14g2000cwz.googlegroups.com>

Hi.

Running perl5.8.* on Linux (more details later), I get:

==============
>echo 'hi' > zzz
>echo 'bye' >> zzz
>perl -we 'print ".$\!.\n";open FOO, "<zzz" or die "foo\n";print
".$\!.\n"; print <FOO>'
 ..
 .Inappropriate ioctl for device.
hi
bye
==============

- Why is $! getting set if the open was successful?
- My open command seems pretty darn simple. Am I doing something wrong?
- Is this a known issue?

More details:
This problem happened on a variety of 2.4 RedHat Linux kernels (Intel
and AMD), plus Mandrake 2.6. It did NOT happen on OS X 10.3, Solaris 9
on SPARC, or Digital Unix.
Any thoughts?

Thanks,

-Amir Karger
amirkargerweb@yahoo.com



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

Date: 12 Jan 2005 22:38:29 GMT
From: xhoster@gmail.com
Subject: Re: $! is set to "Inappropriate ioctl..." on Linux
Message-Id: <20050112173829.195$98@newsreader.com>

amirkargerweb@yahoo.com wrote:
> Hi.
>
> Running perl5.8.* on Linux (more details later), I get:
>
> ==============
> >echo 'hi' > zzz
> >echo 'bye' >> zzz
> >perl -we 'print ".$\!.\n";open FOO, "<zzz" or die "foo\n";print
> ".$\!.\n"; print <FOO>'
> ..
> .Inappropriate ioctl for device.
> hi
> bye
> ==============
>
> - Why is $! getting set if the open was successful?

Take a look at the friendly docs.

       $!      If used numerically, yields the current value of the C
               "errno" variable, or in other words, if a system or library
               call fails, it sets this variable.  This means that the
               value of $! is meaningful only immediately after a failure:

You aren't immediately after a failure.  The value of $! is meaningless.

Xho

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


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

Date: Wed, 12 Jan 2005 22:16:40 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: 20050111: list basics
Message-Id: <41e5a1ac.164131278@news.erols.com>

"Xah Lee" <xah@xahlee.org> wrote:

: # in perl, list is done with paren ().
: # the at sign in front of variable is necessary.
: # it tells perl that it is a list.
: @a = (0,1,2,'three',4,5,6,7,8,9);

[snip]

You have no idea what you're talking about, do you?

See "What is the difference between a list and an array?" in perlfaq4.



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

Date: 12 Jan 2005 11:15:36 -0800
From: toomanyjoes@mail.utexas.edu
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <1105557335.996163.107930@c13g2000cwb.googlegroups.com>

One last post Sherm, then I'm done. No matter what obscenities you
respond with, and understand this, I'm happy. The code snippet Jim and
Brian gave me worked. Though in the spirit of learning I wouldn't mind
getting a break down of what each portion does, RegEx's confuse me.

But heres what I want to say, and in all logic try to understand,
putting emotions aside. When you ask someone how to do something and
they say "read the manual" in practice that is basically dismissing the
question. It has an arrogant "better than thou" tone to it. Is this
hard to understand? Perhaps Paul didn't understand this and still
doesn't recognize it. Perhaps he didn't even mean it this way, but
anyone who has asked a question and gotten "Pssh, thats easy read the
manual" knows exactly what I mean. First that assumes I haven't read
those docs. Which I am still doing (and was doing before I asked the
question) because I have a few more things I need to do in Perl after
this. But I don't see the harm in posting a question before I know
everything about Perl. Now I realize it is a mortal sin to have any
kind of response to a person on newsgroups who basically tells you to
"fuck off" without multiple allies otherwise you get a barrage of
emails from that person and his cronies defending him. Thats a mistake
I made. I'm lucky that some people still were willing to help me
because no matter what you say after you have a swarm of enemies
bombarding you with replies, you always come out the bad guy. So thanks
to those who helped. But I just want to make that clear.



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

Date: 12 Jan 2005 19:20:48 GMT
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <slrncuau4f.3lq.news@maki.homeunix.net>

toomanyjoes@mail.utexas.edu wrote :
> In spite of Scotts message anyone can feel free to post useful
> information. Scott, I already knew about those references. I've been
> going through them. My post did not violate any rules for this group, I
> have read those too. I am not new to newgroups, only to the Perl
> language. You guys could make someone new here a little more
> comfortable posting questions. Rather than more people telling me how
> little I know about Perl, I would be much oblidged to anyone who can
> post a little snippet of code for me.
>
I guess the problem is not, that you know little about perl.
The problem might rather be, that you don't know how to ask the right
questions.
Maybe this page can help you understand:
	http://www.catb.org/~esr/faqs/smart-questions.html

However, here is some code for you.
Since I'm new to Perl, too, this is certanly not the best way to solve
your problem, but it works.
I took your OP, to analyze the problem by myself and practice coding.

      1 #!/usr/bin/perl
      2 
      3 use warnings;
      4 use strict;
      5 my $lastline="";
      6 my @lastline;
      7 
      8 while (<DATA>)
      9 {
     10     chomp ($lastline) if (/^\D/);
     11     &printline;
     12     $lastline = $_;
     13     }
     14     &printline;
     15 
     16 sub printline
     17 {
     18     if ($lastline =~ /^\d+/)
     19     {
     20         @lastline = split /(^\d+)/,  $lastline;
     21         print "$lastline[1]\t<-->\t";
     22         print "--$lastline[2]";
     23     }
     24     else
     25     {
     26         print $lastline;
     27     }
     28 }
     29 
     30 __DATA__
     31 1sampletextsampletextsamplet22tsampletextsampletextsampletext
     32 2sampletextsampletextsampletextsam56etextsampletextsampletext
     33 3sampletextsampletextsampletextsampletextsampletextsampletext
     34 8sampletextsampletextsampletex765mpletextsampletextsampletext
     35 9sampletextsampletextsampletextsampletextsampletextsampletext
     36 15sampletextsampletextsampletextsampletextsampletextsampletext
     37 sampletextsampletextsampletextsample324tsampletextsampletext
     38 18sampletextsampletextsampletextsampletextsampletextsampletext
     39 sampletextsampletextsampletextsampletextsampletextsampletext
     40 sampletextsampletext566pletextsampletextsampletextsampletext
     41 22sampletextsampletextsampletextsampletextsampletextsampletext
     42 1sampletextsampletextsamplete467ampletextsampletextsampletext

-- 
Epur Si Muove (Gallileo Gallilei)


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

Date: Wed, 12 Jan 2005 15:09:44 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <jYGdndBQWP2UGXjcRVn-pw@adelphia.com>

toomanyjoes@mail.utexas.edu wrote:

> One last post Sherm, then I'm done. No matter what obscenities you
> respond with

Obscenities? What are you talking about? *You* dropped the "F-Bomb" in your
post - I haven't done anything of the sort.

> The code snippet Jim and Brian gave me worked.

Did you read their posts? They both commented on your bad attitude, and
indicated that they're being charitable and helping you despite of it.

> But heres what I want to say, and in all logic try to understand,
> putting emotions aside.

Um... what emotions? Seriously. You're throwing the tantrum here, not me.
I'm trying to explain to you how your behavior will affect the quality and
type of responses you get here. I'm trying to help you - despite your poor
behavior.

> When you ask someone how to do something and
> they say "read the manual" in practice that is basically dismissing the
> question.

Well, it's a good thing Paul didn't say that, now isn't it? He didn't just
dismiss you with "RTFM" - he gave you a nudge in the general direction by
telling you what parts of the manual would be most useful to you.

> It has an arrogant "better than thou" tone to it.

Nonsense. I'm pointing you to the *same* docs I learned from. I'm confident
that you can learn from them just as well as I did. If I were arrogant I
wouldn't think that.

> anyone who has asked a question and gotten "Pssh, thats easy read the
> manual" knows exactly what I mean.

That's not what you got. You got "That's easy with regexes - have a look at
chapter X of the manual to learn about them." It might not have been the
handout you were hoping for, but it *was* a useful push to help get you
started in the right direction.

> But I don't see the harm in posting a question before I know
> everything about Perl.

No one told you you needed to "know everything" before posting a question.
What we're telling you is that you should make some attempt at solving the
problem yourself before asking for help.

There's a difference between asking for help and asking for a handout. You
asked for a handout, and this group strongly discourages that.

> Now I realize it is a mortal sin to have any
> kind of response to a person on newsgroups who basically tells you to
> "fuck off" without multiple allies otherwise you get a barrage of
> emails from that person and his cronies defending him. Thats a mistake
> I made.

Isn't that exactly the sort of emotional, obscenity-laced outburst you
imagined I was guilty of?

> I'm lucky that some people still were willing to help me

Yes you were. Do you intend to depend on good luck in the future? If so, I
hope it works out well for you.

> because no matter what you say after you have a swarm of enemies
> bombarding you with replies, you always come out the bad guy.

It *does* matter what you say. That's the point of all this. If you had read
the suggested docs and tried to write some code, then come back here and
said "here's what I've tried so far - I expected it to do X, but it did Y
instead" there would have been no problem. You'd have been up to your
eyebrows in comments about your code, instead of comments about your
attitude.

Instead you complained that you didn't get the handout you expected.
Naturally, several people - those you imagine as "enemies" - tried to
explain to you that this isn't the place to come asking for handouts.

> So thanks to those who helped.

You're quite welcome.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 12 Jan 2005 22:56:36 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <slrncubap4.ucb.abigail@alexandra.abigail.nl>

toomanyjoes@mail.utexas.edu (toomanyjoes@mail.utexas.edu) wrote on
MMMMCLII September MCMXCIII in <URL:news:1105551129.560260.305130@c13g2000cwb.googlegroups.com>:
@@  Anyone can feel free to post helpful messages despite Paul Lalli's
@@  post. I realize it is trivial, I'm not a Perl programmer, and I am
@@  reading up, but my project is waiting for this one simple task to be
@@  completed before moving on so the faster I figure this out the better.
@@  Paul if its so easy why not post code to do it? I suggest YOU read up
@@  on newsgroup etiquette.


*PLONK*


Abigail
-- 
print 74.117.115.116.32, 97.110.111.116.104.101.114.32,
      80.101.114.108.32, 72.97.99.107.101.114.10;


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

Date: 12 Jan 2005 12:21:17 -0800
From: "jc8glp1hu" <jgarretthood@gmail.com>
Subject: Re: disk space script
Message-Id: <1105561277.102448.233530@z14g2000cwz.googlegroups.com>

Bernd

You may want to check out this page.  It is a list of all of XP's
commands for cmd.

http://www.ss64.com/nt/

So with perl you can just use system() or exec() to output to the
command line.

the only issue may be reading it back in .. in that case do a system()
> diskinfo.txt and read it back in w/ your application then remove it
when you are done w/ it.

That's what I do w/ perl on a Unix environment, so maybe itll work for
you on windows.

Cheers



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

Date: 12 Jan 2005 12:45:42 -0800
From: "jc8glp1hu" <jgarretthood@gmail.com>
Subject: Re: disk space script
Message-Id: <1105562742.012103.24900@z14g2000cwz.googlegroups.com>

Wow, google really butchers the text as you enter it! that system line
with the right arrow thing is supposed to be one line.



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

Date: Wed, 12 Jan 2005 11:58:00 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Looking for strategies for performance improvements
Message-Id: <120120051158008466%jgibson@mail.arc.nasa.gov>

In article <cs3dmn$ikp$1@srv38.cas.org>, <lvirden@gmail.com> wrote:

[ descriptiont of application with problems after long execution ]
> 
> What tools might be available to a newbie perl developer that would assist
> in analysing and improving an application exhibiting this sort of
> behavior?

The print statement. :)


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: Wed, 12 Jan 2005 15:22:02 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Looking for strategies for performance improvements
Message-Id: <L46dnThQu41xG3jcRVn-tQ@adelphia.com>

lvirden@gmail.com wrote:

> He has an application that reads through terabytes of information,
> searching for particular patterns and combinations.  The program
> runs for days.  However, as the time that the program runs progresses,
> it appears to produce results less frequently than expected.
> 
> When he notices this, he stops the application, starts it back up where
> things left off, and the application returns to producing results at
> the frequency expected - until, of course, the next time 8 or 10 or
> whatever hours have gone by...
> 
> What tools might be available to a newbie perl developer that would assist
> in analysing and improving an application exhibiting this sort of
> behavior?

I'd begin with analyzing the algorithms, not the code that implements them.
Nine times out of ten, choosing a better algorithm in a key spot will
result in a far better improvement in execution time than will any number
of code tweaks.

When it comes time to measure and profile the code, have a look at the
Devel::DProf module. It's included with Perl, at least as of 5.8.1, which
is the oldest version I have on hand to check at the moment.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Wed, 12 Jan 2005 15:37:55 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Looking for strategies for performance improvements
Message-Id: <PoSdneoOAr45F3jcRVn-1Q@adelphia.com>

Sherm Pendley wrote:

> lvirden@gmail.com wrote:
> 
>> He has an application that reads through terabytes of information,
>> searching for particular patterns and combinations.  The program
>> runs for days.  However, as the time that the program runs progresses,
>> it appears to produce results less frequently than expected.
>> 
>> When he notices this, he stops the application, starts it back up where
>> things left off, and the application returns to producing results at
>> the frequency expected - until, of course, the next time 8 or 10 or
>> whatever hours have gone by...
>> 
>> What tools might be available to a newbie perl developer that would
>> assist in analysing and improving an application exhibiting this sort of
>> behavior?
> 
> I'd begin with analyzing the algorithms, not the code that implements
> them. Nine times out of ten, choosing a better algorithm in a key spot
> will result in a far better improvement in execution time than will any
> number of code tweaks.

Talking to myself - never a good sign. :-)

More specifically, based on your description it looks like there's a data
structure that grows as execution proceeds, and a method whose execution
time is a function of that data structure's size. If he can, he needs to
find a different algorithm to use for that method - ideally one that
executes in constant time.

For example, suppose he has an array to which elements are being added, and
he's doing a linear search into that array. He'd be better off using a hash
in that case instead of an array. A linear search is O(n), a function of
the number of elements in the array, whereas a hash lookup is a constant
O(1).

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 12 Jan 2005 22:04:21 GMT
From: xhoster@gmail.com
Subject: Re: Looking for strategies for performance improvements
Message-Id: <20050112170421.371$hg@newsreader.com>

Sherm Pendley <spamtrap@dot-app.org> wrote:
>
> Talking to myself - never a good sign. :-)
>
> More specifically, based on your description it looks like there's a data
> structure that grows as execution proceeds, and a method whose execution
> time is a function of that data structure's size.

Or a method whose execution time is a function of the VM system not
keeling over :)

> If he can, he needs to
> find a different algorithm to use for that method - ideally one that
> executes in constant time.

I'd argue that this is likely an implementation problem, and not an
algorithm problem.

> For example, suppose he has an array to which elements are being added,
> and he's doing a linear search into that array. He'd be better off using
> a hash in that case instead of an array. A linear search is O(n), a
> function of the number of elements in the array, whereas a hash lookup is
> a constant O(1).

But the OP indicated that the procedure can be restarted in the middle
(and presumably still give correct results).  If you can dump the array
every now and then and still get correct results, then the algorithm never
needed you to keep those array elements in the first place.  If your
implementation is keeping crap the algorithm doesn't need, that sounds like
an implementation problem rather than an algorithm problem.

Xho

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


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

Date: Wed, 12 Jan 2005 17:16:11 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Looking for strategies for performance improvements
Message-Id: <NomdnVrxWNUwPHjcRVn-og@adelphia.com>

xhoster@gmail.com wrote:

> implementation is keeping crap the algorithm doesn't need, that sounds
> like an implementation problem rather than an algorithm problem.

Well, I did say that algorithms would be the *first* thing I'd look at - not
the *only* thing. :-)

I think of it this way - while a poor implementation can easily ruin a good
algorithm, the converse is not necessarily true. A good implementation will
rarely overcome a poor choice of algorithms. So I prefer to evaluate my
choice of algorithms first, and then once I'm satisfied with that, I look
at my implementation of those algorithms.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 12 Jan 2005 22:10:05 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Problem splitting lines from file input
Message-Id: <slrncub81t.ucb.abigail@alexandra.abigail.nl>

Mothra (Mothra@mothra.com) wrote on MMMMCLII September MCMXCIII in
<URL:news:aE7Fd.624600$2W1.51532@news.easynews.com>:
//  I'm trying to parse a log file using ';' as a newline and then wherever 
//  I find items inside '(..)', indenting those lines thus:
//  
//  
//  foo;bar(foo;bar(foobar);foo)foobar
//  
//    becomes
//  
//  foo
//  bar(
//      foo
//      bar(
//          foobar
//      )
//      foo
//  )
//  foobar
//  
//  What I've got so far is below - the problem is that when there are 
//  nested sets of parentheses, I can't increase the indents accordingly. 
//  Also, I can't work out how to get the closing ')' on a line by itself.
//  
//  I'm in a bit of a pickle - can anyone help?

    use strict;
    use warnings;
    no warnings qw /syntax/;

    my $l = 0;
    my $i = "    ";

    while (<>) {
        s((?:([(])|(;)|([)]));*)
         ($l += $1 ? 1 : $3 ? -1 : 0;
         ($1 ? "(\n" : $3 ? "\n" . ($i x $l) . ")\n" : "\n") . ($i x $l))ge;
        print;
    }

    __END__


Abigail
-- 
# Count the number of lines; code doesn't match \w. Linux specific.
()=<>;$!=$=;($:,$,,$;,$")=$!=~/.(.)..(.)(.)..(.)/;
$;++;$*++;$;++;$*++;$;++;`$:$,$;$" $. >&$*`; 


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

Date: 12 Jan 2005 11:17:44 -0800
From: "joe.cipale@radisys.com" <joe.cipale@radisys.com>
Subject: Use of string var within qw//
Message-Id: <1105557464.719732.117630@c13g2000cwb.googlegroups.com>

I am attempting to build a Tk:Optionmenu pull down from a string that
is passed to a sub-routine from one of my menu items. The string may
look like this:
2 3 8 10 14

The string WILL change, which is why I want to pass the string to my
menu pulldown as such:

my @slt_opt = qw/\$slt/;

$frame3->Label(-text => "Slot ID: ")->pack(-side => 'left',
-anchor => 's',
-expand => 1);

$frame3->Optionmenu(-variable => \$slots,
-options  => [@slt_opt],
-command  => [sub {print "args=@_\n"}, 'First']);

======================================
Am I reaching with what qw can do here?

Regards,

Joe



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

Date: Wed, 12 Jan 2005 19:31:38 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Use of string var within qw//
Message-Id: <uWeFd.10678$eb.6187@trndny01>

<joe.cipale@radisys.com> wrote in message
news:1105557464.719732.117630@c13g2000cwb.googlegroups.com...
> I am attempting to build a Tk:Optionmenu pull down from a string that
> is passed to a sub-routine from one of my menu items. The string may
> look like this:
> 2 3 8 10 14
>
> The string WILL change, which is why I want to pass the string to my
> menu pulldown as such:
>
> my @slt_opt = qw/\$slt/;

You have just created the following array:
@slt_opt = ('\$slt');
That is, an array with one element - the string containing a slash, a
dollar sign, and the letters 's','l','t'.  I am not clear on whether or
not that's what you want.  I find it likely, however, that you wanted an
array containing the variable $slt.  For that, you would do:
my @slt_opt = $slt;
or if you feel the need for explict parens:
my @slt_opt = ($slt);


> $frame3->Label(-text => "Slot ID: ")->pack(-side => 'left',
> -anchor => 's',
> -expand => 1);
>
> $frame3->Optionmenu(-variable => \$slots,
> -options  => [@slt_opt],
> -command  => [sub {print "args=@_\n"}, 'First']);
>
> ======================================
> Am I reaching with what qw can do here?

Your post does not make clear what you expect qw// to do.  qw// takes a
space-separated list of barewords, and transforms it into a list of
single-quoted strings.  Under no circumstances does variable
interpolation happen in qw//.  To wit:

qw/foo bar baz/ is equivalent to ('foo', 'bar', 'baz')
qw/$name $id $addr/ is equivalent to ('$name', '$id', '$addr') NOT
($name, $id, $addr).

Does this answer your question?

Paul Lalli



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

Date: Wed, 12 Jan 2005 19:39:46 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Use of string var within qw//
Message-Id: <62fFd.5837$7b.259@trndny05>

<joe.cipale@radisys.com> wrote in message
news:1105557464.719732.117630@c13g2000cwb.googlegroups.com...
> I am attempting to build a Tk:Optionmenu pull down from a string that
> is passed to a sub-routine from one of my menu items. The string may
> look like this:
> 2 3 8 10 14
>
> The string WILL change, which is why I want to pass the string to my
> menu pulldown as such:
>
> my @slt_opt = qw/\$slt/;
>
> $frame3->Label(-text => "Slot ID: ")->pack(-side => 'left',
> -anchor => 's',
> -expand => 1);
>
> $frame3->Optionmenu(-variable => \$slots,
> -options  => [@slt_opt],
> -command  => [sub {print "args=@_\n"}, 'First']);

Reading this again, I *think* I understand.  Are you looking to have
the -options parameter be a reference to an anonymous array containing
2, 3, 8, 10, 14?  If so, you are indeed confused about qw//.  In fact,
I'd say you're assuming the exact *opposite* of qw//'s functionality.
:-)

Instead, you should populate the anonymous array with the return value
of the split() function:
my $slt = '2 3 8 10 14';
 . . .
-options => [split ' ', $slt]

Hope this helps,
Paul Lalli



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

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


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