[29166] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 410 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 6 14:10:09 2007

Date: Sun, 6 May 2007 11:09: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           Sun, 6 May 2007     Volume: 11 Number: 410

Today's topics:
    Re: 2 array problem <abigail@abigail.be>
    Re: 2 array problem anno4000@radom.zrz.tu-berlin.de
    Re: Double backslash behavior not as expected <mina86@tlen.pl>
    Re: eval problem! <jaford@watford53.freeserve.co.uk>
        Home-built Twirling Bar Between Multiple System Calls <ewijaya@gmail.com>
        how to convert the following ASP code to perl code <avdavid.noreply@gmail.com>
        how to join array into array <tradeorganizer@gmail.com>
    Re: how to join array into array <bik.mido@tiscalinet.it>
    Re: how to join array into array <noreply@gunnar.cc>
    Re: how to join array into array <someone@example.com>
    Re: how to join array into array <tadmc@augustmail.com>
    Re: how to join array into array <tradeorganizer@gmail.com>
    Re: how to join array into array <tradeorganizer@gmail.com>
    Re: need a quick script <bik.mido@tiscalinet.it>
    Re: need a quick script <cdalten@gmail.com>
    Re: need a quick script <noreply@gunnar.cc>
    Re: need a quick script <lambik@kieffer.nl>
    Re: need a quick script <noreply@gunnar.cc>
    Re: system call - how-to. <hjp-usenet2@hjp.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 06 May 2007 10:34:44 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: 2 array problem
Message-Id: <slrnf3rbpc.hl5.abigail@alexandra.abigail.be>

anno4000@radom.zrz.tu-berlin.de (anno4000@radom.zrz.tu-berlin.de) wrote
on MMMMCMXCVI September MCMXCIII in <URL:news:5a4u04F2m9n3rU1@mid.dfncis.de>:
:)  Abigail  <abigail@abigail.be> wrote in comp.lang.perl.misc:
:) > Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMCMXCIV September
:) > MCMXCIII in <URL:news:5mnm33h3207b0e0eptvsrtlemj326alaf3@4ax.com>:
:) > <>  On 04 May 2007 15:07:18 GMT, Abigail <abigail@abigail.be> wrote:
:) > <>  
:) > <> >That '@a' doesn't warn in your example has little to do with @a being
:) > <> >special.  It just has to do with the fact that *a exists. Which exists
:) > <>  
:) > <>  That's surely what Anno meant. As you surely know full well.
:) > 
:) > 
:) > Then I don't get it. @a behaves the same as @c.
:)  
:)  True, but the specialness of $a (the package variable) makes it easier
:)  to use it inadvertently.  That way @c is slightly safer than @a.


I still fail to get it. You seem to be saying "because $a is special,
you might not get the warning @main::a used only once". But that is
only a useful warning if you *mistype* a variable name - in which case
it's safer to use @a (which if mistyped to @c triggers the warning -
or triggers a strict error) than to use @c (which if mistypes to @a may
not trigger the warning or error). But that doesn't make much sense.



Abigail
-- 
#!/opt/perl/bin/perl -w
$\ = $"; $SIG {TERM} = sub {print and exit};
kill 15 => fork for qw /Just another Perl Hacker/;


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

Date: 6 May 2007 16:12:22 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: 2 array problem
Message-Id: <5a6d36F2moh34U1@mid.dfncis.de>

Abigail  <abigail@abigail.be> wrote in comp.lang.perl.misc:
> anno4000@radom.zrz.tu-berlin.de (anno4000@radom.zrz.tu-berlin.de) wrote
> on MMMMCMXCVI September MCMXCIII in <URL:news:5a4u04F2m9n3rU1@mid.dfncis.de>:
> :)  Abigail  <abigail@abigail.be> wrote in comp.lang.perl.misc:
> :) > Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMCMXCIV September
> :) > MCMXCIII in <URL:news:5mnm33h3207b0e0eptvsrtlemj326alaf3@4ax.com>:
> :) > <>  On 04 May 2007 15:07:18 GMT, Abigail <abigail@abigail.be> wrote:
> :) > <>  
> :) > <> >That '@a' doesn't warn in your example has little to do with @a being
> :) > <> >special.  It just has to do with the fact that *a exists. Which exists
> :) > <>  
> :) > <>  That's surely what Anno meant. As you surely know full well.
> :) > 
> :) > 
> :) > Then I don't get it. @a behaves the same as @c.
> :)  
> :)  True, but the specialness of $a (the package variable) makes it easier
> :)  to use it inadvertently.  That way @c is slightly safer than @a.
> 
> 
> I still fail to get it. You seem to be saying "because $a is special,
> you might not get the warning @main::a used only once". But that is
> only a useful warning if you *mistype* a variable name - in which case
> it's safer to use @a (which if mistyped to @c triggers the warning -
> or triggers a strict error) than to use @c (which if mistypes to @a may
> not trigger the warning or error). But that doesn't make much sense.

The advice would have to be never to misspell "a" or "b" when you intend
to write something else.  I guess you got me there.

So the use of @a, @b, %a, and %b as package variables (or lexicals)
seems to be technically no problem.  The lexicals $a and $b should be
avoided if there is a chance you want to run sort() in the same
scope.  There always is; you'd have to use a prototyped comparison
function, a major nuisance.

If one is interested in them at all, the package variables $::a and
$::b are less problematic than they would seem to be.  If used in a
sub, you must localize them, but that goes for all package variables
that aren't meant to be global.  $a and $b are only special in that
they can't reasonably be used globally.

The reason to avoid them would be that from "perldoc -f sort" one
would expect sort() to overwrite them randomly.  But that doesn't
happen:

    ( $a, $b) = ( 99, 100);
    my @s = sort { $b <=> $a } 1 .. 4;
    print "$a $b\n";

still prints "99, 100".  The preserving behavior has been around for
a long time, but it isn't documented or I overlooked it more than once.
Apart from that, there doesn't seem to be much reason to avoid $::a
and $::b at all, except, of course, who wants them in the first place.

Lexical $a and $b would be nice, but they remain problematic.

Anno


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

Date: Sun, 06 May 2007 13:00:48 +0200
From: Michal Nazarewicz <mina86@tlen.pl>
Subject: Re: Double backslash behavior not as expected
Message-Id: <87ps5ep673.fsf@erwin.mina86.com>

"John W. Krahn" <someone@example.com> writes:

> alt.testing@{g}mail.com wrote:
>> Hi all,
>> the simple concept of escaping a "backslash", thus translating to a
>> literal backslash; does not provide the implied result, under the
>> following example.
>> 
>> $mount_result = qx#strace /bin/mount -t smbfs \\\\$machine\\documents
>> /mnt/workstation_shares/$mount/documents/ -o ro -o username=$user -o
>> password=$pass#;
>> 
>> The top part of the "strace" output gives this:
>> 
>> execve("/bin/mount", ["/bin/mount", "-t", "smbfs", "\\an2documents",
>> "/mnt/workstation_shares/xxxx/doc"..., "-o", "ro", "-o",
>> "username=xxxx", "-o", "password=xxxxxxxxxx"], [/* 22 vars */]) = 0
>> 
>> "\\an2documents"
>> 
>> Note; that there is no "\" in between the machine name, and the share.
>> It should be "\\an2\documents".
>> 
>> [root@mercedes sbin]# perl -e 'print "\\\\an2\\documents\n"'
>> \\an2\documents
>> 
>> 
>> I'm sure it's a simple thing, but can someone enlighten me on this
>> parlay? 
>
> Your string is interpolated twice, once by perl and then by the shell.
>
> $ perl -le'
> $machine = "an2";
> $mount = "xxxx";
> print qx#echo /bin/mount -t smbfs
> \\\\$machine\\documents/mnt/workstation_shares/$mount/documents/#;
> '
> /bin/mount -t smbfs \an2documents/mnt/workstation_shares/xxxx/documents/
>
>
> You need to double up on the back-slashes.
>
> $ perl -le'
> $machine = "an2";
> $mount = "xxxx";
> print qx#echo /bin/mount -t smbfs
> \\\\\\\\$machine\\\\documents/mnt/workstation_shares/$mount/documents/#;
> '
> /bin/mount -t smbfs \\an2\documents/mnt/workstation_shares/xxxx/documents/

One may also use open() to skip shell.

#v+
$_ = "\\\\$machine\\documents/mnt/workstation_shares/$mount/documents/";
open(FH, '-|', '/bin/echo', '/bin/mount', '-t', 'smbfs', $_)
    or die "Could not exec: $!"
print while (<FH>);
#v-

(not tested)

-- 
Best regards,                                         _     _
 .o. | Liege of Serenly Enlightened Majesty of      o' \,=./ `o
 ..o | Computer Science,  Michal "mina86" Nazarewicz   (o o)
 ooo +--<mina86*tlen.pl>---<jid:mina86*chrome.pl>--ooO--(_)--Ooo--


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

Date: Sun, 06 May 2007 16:18:07 GMT
From: Jim Ford <jaford@watford53.freeserve.co.uk>
Subject: Re: eval problem!
Message-Id: <3dn%h.6882$H4.5477@newsfe2-gui.ntli.net>

Jim Ford wrote:
> I have a script using a module I've written which is used in a Tk 
> callback. The module contains the following line:
> 
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

Sorted!

While stripping the code down in order to provide a concise version to 
show here, I discovered a coding logic error.

Thanks to those who responded and prompted me to pare the code down, and 
thus find the problem!

Jim Ford


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

Date: 6 May 2007 08:20:03 -0700
From: foolishbrat <ewijaya@gmail.com>
Subject: Home-built Twirling Bar Between Multiple System Calls
Message-Id: <1178464803.820499.223030@y5g2000hsa.googlegroups.com>

Dear all,
AFAIK, progress/twirling bar can only be applied under loops. For
example we can use Term::ProgressBar or Smart::Comments. But is there
away to do it for system call like this:

__BEGIN__
#!/usr/bin/perl
system("code1.out param1 > output.txt");
system("code2.out param2 output.txt > output_final.txt");
__END__

How can I show progress/twirling Bar between first (code1) system call
and the second (code2) system call? Especially we don't know how long
each system call will take.

Preferrably not using external CPAN module (except pre-installed
module).



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

Date: 6 May 2007 05:35:49 -0700
From: DavidNorep <avdavid.noreply@gmail.com>
Subject: how to convert the following ASP code to perl code
Message-Id: <1178454949.303985.123110@o5g2000hsb.googlegroups.com>

I do not know asp or perl. Can somebody please tell me how this ASP
cgi should be in perl (I am trying an AJAX example from w3schools).


<%
response.expires=-1
response.write(time)
%>



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

Date: 6 May 2007 03:46:31 -0700
From: Tradeorganizer <tradeorganizer@gmail.com>
Subject: how to join array into array
Message-Id: <1178448391.228147.26710@n76g2000hsh.googlegroups.com>

Hi

I am having two array example below :

@x;
@y;

values in x and y are :

$x[0] = (1,2,3,4)
$x[1] = (2,3,4,5)
 ....
till
$x[31] = (1,1,1,1)

now the value of y contains

$y[0] = (2,2,3,4)
$y[1] = (2,3,3,5)
 ....
till
$y[31] =(4,4,4,4)
 .....

till
$y[500] = (1,1,1,1)

i want to make a loop where i can append the array y or create new
array with having array x value fixed till record [31] ie end of array
x plus value of array[y] till record [31] and then repeating again the
value of array x to next records of array y i mean till next 31
records of y

so if you see the results output it should be lik below :

@newxy

$newxy[0] = (1,2,3,4,2,2,3,4)
$newxy[1] = (2,3,4,5,2,3,3,5 )
 .....
till $newxy[31] = (1,1,1,1, 4,4,4,4)

and $newxy[32] values will look like  (1,2,3,4,5,5,5,5) here its
getting repeating value from array x till it finished 31 record and
then restared.

kindly help i know perl but could not find the loop idea for this

Regards



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

Date: Sun, 06 May 2007 13:40:49 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: how to join array into array
Message-Id: <v4fr339i82bdmg97902jj93mrer4vof5gp@4ax.com>

On 6 May 2007 03:46:31 -0700, Tradeorganizer
<tradeorganizer@gmail.com> wrote:

>Hi

Hi

>I am having two array example below :
>
>@x;
>@y;

Yes...

>values in x and y are :
>
>$x[0] = (1,2,3,4)
>$x[1] = (2,3,4,5)

You're missing the semicolons, btw.

Anyway, this does not make much sense: you have a list assigned to a
scalar. The above is perfectly equivalent to

  $x[0] = 4;
  $x[1] = 4;

Perhaps you mean

  $x[0] = [1,2,3,4];
  $x[1] = [2,3,4,5];

>i want to make a loop where i can append the array y or create new
>array with having array x value fixed till record [31] ie end of array
>x plus value of array[y] till record [31] and then repeating again the
>value of array x to next records of array y i mean till next 31
>records of y

I can't understand.

>so if you see the results output it should be lik below :
>
>@newxy
>
>$newxy[0] = (1,2,3,4,2,2,3,4)
>$newxy[1] = (2,3,4,5,2,3,3,5 )
>.....
>till $newxy[31] = (1,1,1,1, 4,4,4,4)
>
>and $newxy[32] values will look like  (1,2,3,4,5,5,5,5) here its
>getting repeating value from array x till it finished 31 record and
>then restared.

Mild possibility of me understanding. Could you please post a reduced
example with say @x having 3 entries, @y 4 and your desired @xy
output?

>kindly help i know perl but could not find the loop idea for this

The above seems to suggest you don't know Perl very well, but I may be
wrong. Anyway, you should show what you have tried thus far. That
would help us to understand what you're really after.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Sun, 06 May 2007 14:57:32 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how to join array into array
Message-Id: <5a61qfF2nsl97U1@mid.individual.net>

Michele Dondi wrote:
> On 6 May 2007 03:46:31 -0700, Tradeorganizer
> <tradeorganizer@gmail.com> wrote:
>>kindly help i know perl but could not find the loop idea for this
> 
> The above seems to suggest you don't know Perl very well, but I may be
> wrong.

In any case, the guy doesn't know Usenet very well. He multi-posted...

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


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

Date: Sun, 06 May 2007 15:19:16 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: how to join array into array
Message-Id: <Ulm%h.6420$au6.6178@edtnps90>

Tradeorganizer wrote:
> 
> I am having two array example below :
> 
> @x;
> @y;
> 
> values in x and y are :
> 
> $x[0] = (1,2,3,4)
> $x[1] = (2,3,4,5)
> ....
> till
> $x[31] = (1,1,1,1)
> 
> now the value of y contains
> 
> $y[0] = (2,2,3,4)
> $y[1] = (2,3,3,5)
> ....
> till
> $y[31] =(4,4,4,4)
> .....
> 
> till
> $y[500] = (1,1,1,1)
> 
> i want to make a loop where i can append the array y or create new
> array with having array x value fixed till record [31] ie end of array
> x plus value of array[y] till record [31] and then repeating again the
> value of array x to next records of array y i mean till next 31
> records of y
> 
> so if you see the results output it should be lik below :
> 
> @newxy
> 
> $newxy[0] = (1,2,3,4,2,2,3,4)
> $newxy[1] = (2,3,4,5,2,3,3,5 )
> .....
> till $newxy[31] = (1,1,1,1, 4,4,4,4)
> 
> and $newxy[32] values will look like  (1,2,3,4,5,5,5,5) here its
> getting repeating value from array x till it finished 31 record and
> then restared.
> 
> kindly help i know perl but could not find the loop idea for this

my @newxy;
for my $index_y ( 0 .. $#y ) {
    push @newxy, [ @{ $x[ $index_y % @x ] }, @{ $y[ $index_y ] } ];
    }





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


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

Date: Sun, 6 May 2007 11:49:02 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: how to join array into array
Message-Id: <slrnf3s1nu.br0.tadmc@tadmc30.august.net>

Tradeorganizer <tradeorganizer@gmail.com> wrote:

> values in x and y are :
>
> $x[0] = (1,2,3,4)


Please speak Perl rather than English, when possible.

   $x[0] = [1,2,3,4];


> $x[1] = (2,3,4,5)
> ....
> till
> $x[31] = (1,1,1,1)


Wouldn't having just 2 or 3 illustrate your problem just as
well as having 32 of them?


> now the value of y contains
>
> $y[0] = (2,2,3,4)
> $y[1] = (2,3,3,5)
> ....
> till
> $y[31] =(4,4,4,4)
> .....
>
> till
> $y[500] = (1,1,1,1)
>
> i want to make a loop where i can append the array y or create new
> array with having array x value fixed till record [31] ie end of array
> x plus value of array[y] till record [31] and then repeating again the
> value of array x to next records of array y i mean till next 31
> records of y


If I understand you correctly, then I think this does it:

----------------------------
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;

my @x = (
   [1,2,3,4],
   [2,3,4,5],
);

my @y = (
   [2,2,3,4],
   [2,3,3,5],
   [3,4,5,6],
   [7,8,9,0],
   [1,1,1,1],
);


my @newxy;
for ( my $xi = my $yi = 0; defined $y[$yi]; $xi++, $yi++ ) {
    push @newxy, [ @{ $x[$xi] }, @{ $y[$yi] } ];
    $xi = -1 if $xi == $#x;  # roll back to zero
}

print Dumper \@newxy;
----------------------------



> kindly help i know perl 


Then you should be able to speak Perl in your posts.

Have you seen the Posting Guidelines that are posted here frequently?


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


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

Date: 6 May 2007 10:41:55 -0700
From: Tradeorganizer <tradeorganizer@gmail.com>
Subject: Re: how to join array into array
Message-Id: <1178473315.074806.272170@l77g2000hsb.googlegroups.com>

On May 6, 9:49 am, Tad McClellan <t...@augustmail.com> wrote:
> Tradeorganizer <tradeorgani...@gmail.com> wrote:
> > values in x and y are :
>
> > $x[0] = (1,2,3,4)
>
> Please speak Perl rather than English, when possible.
>
>    $x[0] = [1,2,3,4];
>
> > $x[1] = (2,3,4,5)
> > ....
> > till
> > $x[31] = (1,1,1,1)
>
> Wouldn't having just 2 or 3 illustrate your problem just as
> well as having 32 of them?
>
>
>
> > now the value of y contains
>
> > $y[0] = (2,2,3,4)
> > $y[1] = (2,3,3,5)
> > ....
> > till
> > $y[31] =(4,4,4,4)
> > .....
>
> > till
> > $y[500] = (1,1,1,1)
>
> > i want to make a loop where i can append the array y or create new
> > array with having array x value fixed till record [31] ie end of array
> > x plus value of array[y] till record [31] and then repeating again the
> > value of array x to next records of array y i mean till next 31
> > records of y
>
> If I understand you correctly, then I think this does it:
>
> ----------------------------
> #!/usr/bin/perl
> use warnings;
> use strict;
> use Data::Dumper;
>
> my @x = (
>    [1,2,3,4],
>    [2,3,4,5],
> );
>
> my @y = (
>    [2,2,3,4],
>    [2,3,3,5],
>    [3,4,5,6],
>    [7,8,9,0],
>    [1,1,1,1],
> );
>
> my @newxy;
> for ( my $xi = my $yi = 0; defined $y[$yi]; $xi++, $yi++ ) {
>     push @newxy, [ @{ $x[$xi] }, @{ $y[$yi] } ];
>     $xi = -1 if $xi == $#x;  # roll back to zero
>
> }
>
> print Dumper \@newxy;
> ----------------------------
>
> > kindly help i know perl
>
> Then you should be able to speak Perl in your posts.
>
> Have you seen the Posting Guidelines that are posted here frequently?
>
> --
>     Tad McClellan                          SGML consulting
>     t...@augustmail.com                   Perl programming
>     Fort Worth, Texas

Hi Tad ,

Thanks for your reply , it worked , but the output i am getting is
below :


C:\perlprog>testlooprt.pl

$VAR1 = [
          [
            1,
            2,
            3,
            4,
            2,
            2,
            3,
            4
          ],
          [
            2,
            3,
            4,
            5,
            2,
            3,
            3,
            5
          ],
          [
            1,
            2,
            3,
            4,
            3,
            4,
            5,
            6
          ],
          [
            2,
            3,
            4,
            5,
            7,
            8,
            9,
            0
          ],
          [
            1,
            2,
            3,
            4,
            1,
            1,
            1,
            1
          ]
        ];

where as i need like
$VAR1 = [  [  1, 2, 3, 4, 2, 2, 3, 4 ],
how can i do that.

Regards



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

Date: 6 May 2007 10:50:21 -0700
From: Tradeorganizer <tradeorganizer@gmail.com>
Subject: Re: how to join array into array
Message-Id: <1178473821.520598.233750@y5g2000hsa.googlegroups.com>

On May 6, 8:19 am, "John W. Krahn" <some...@example.com> wrote:
> Tradeorganizer wrote:
>
> > I am having two array example below :
>
> > @x;
> > @y;
>
> > values in x and y are :
>
> > $x[0] = (1,2,3,4)
> > $x[1] = (2,3,4,5)
> > ....
> > till
> > $x[31] = (1,1,1,1)
>
> > now the value of y contains
>
> > $y[0] = (2,2,3,4)
> > $y[1] = (2,3,3,5)
> > ....
> > till
> > $y[31] =(4,4,4,4)
> > .....
>
> > till
> > $y[500] = (1,1,1,1)
>
> > i want to make a loop where i can append the array y or create new
> > array with having array x value fixed till record [31] ie end of array
> > x plus value of array[y] till record [31] and then repeating again the
> > value of array x to next records of array y i mean till next 31
> > records of y
>
> > so if you see the results output it should be lik below :
>
> > @newxy
>
> > $newxy[0] = (1,2,3,4,2,2,3,4)
> > $newxy[1] = (2,3,4,5,2,3,3,5 )
> > .....
> > till $newxy[31] = (1,1,1,1, 4,4,4,4)
>
> > and $newxy[32] values will look like  (1,2,3,4,5,5,5,5) here its
> > getting repeating value from array x till it finished 31 record and
> > then restared.
>
> > kindly help i know perl but could not find the loop idea for this
>
> my @newxy;
> for my $index_y ( 0 .. $#y ) {
>     push @newxy, [ @{ $x[ $index_y % @x ] }, @{ $y[ $index_y ] } ];
>     }
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you can special-order
> certain sorts of tools at low cost and in short order.       -- Larry Wall

Hi John

Thanks for help , the array seems to be running fine but i dont know
where i am wrong i am getting ouput value as
below
ARRAY(0x1c653b0)ARRAY(0x1c653ec)ARRAY(0x1c6544c)ARRAY(0x1c65458)ARRAY(0x1c654c4)
what does it mean and how to get value printed for output file. kindly
help

Regards



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

Date: Sun, 06 May 2007 12:40:26 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: need a quick script
Message-Id: <hubr339uq51qmfa2ol8ktutjvlvjefob2e@4ax.com>

On Sun, 06 May 2007 02:27:27 GMT, bob schmo <bob@schmo.com> wrote:

>Subject: need a quick script

How 'bout a bottle of champagne?  ;-)

>Does anyone have a script lying around that will take firstname lastname 
>and create first initial lastname: Bob Schmo --> BSchmo

Nope. I doubt anyone has. It's so easy to write one in a few seconds
that there's no reason one should have a similar thing "lying around".


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 6 May 2007 08:26:44 -0700
From: grocery_stocker <cdalten@gmail.com>
Subject: Re: need a quick script
Message-Id: <1178465203.982729.295160@l77g2000hsb.googlegroups.com>

On May 6, 3:40 am, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On Sun, 06 May 2007 02:27:27 GMT, bob schmo <b...@schmo.com> wrote:
> >Subject: need a quick script
>
> How 'bout a bottle of champagne?  ;-)
>
> >Does anyone have a script lying around that will take firstname lastname
> >and create first initial lastname: Bob Schmo --> BSchmo
>
> Nope. I doubt anyone has. It's so easy to write one in a few seconds
> that there's no reason one should have a similar thing "lying around".
>

I just tried the doing it now. I took me exactly 17 minutes. The thing
that slowed me up was if I had the input of say

Chad Altenburg

I needed to figure out how to store the name the characters 'C' 'h'
'a' 'd' in one array and 'Chad' 'Altenburg' in another array.  All
this was due to the fact that I have a poor grasp over regex.




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

Date: Sun, 06 May 2007 18:36:41 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: need a quick script
Message-Id: <5a6elcF2n85heU1@mid.individual.net>

grocery_stocker wrote:
> I just tried the doing it now. I took me exactly 17 minutes. The thing
> that slowed me up was if I had the input of say
> 
> Chad Altenburg
> 
> I needed to figure out how to store the name the characters 'C' 'h'
> 'a' 'd' in one array and 'Chad' 'Altenburg' in another array.  All
> this was due to the fact that I have a poor grasp over regex.

???

	sub nameconvert {
		my ($first, $last) = split ' ', shift;
		substr($first, 0, 1) . $last
	}

	print nameconvert('Chad Altenburg'), "\n";

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


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

Date: Sun, 6 May 2007 19:51:50 +0200
From: "Lambik" <lambik@kieffer.nl>
Subject: Re: need a quick script
Message-Id: <463e15a8$0$37711$5fc3050@dreader2.news.tiscali.nl>

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:5a6elcF2n85heU1@mid.individual.net...
> grocery_stocker wrote:
> sub nameconvert {
> my ($first, $last) = split ' ', shift;
> substr($first, 0, 1) . $last
> }
>
> print nameconvert('Chad Altenburg'), "\n";
>

Such a hopeless question and i still learned something. I would have done:

return substr($first, 0, 1) . $last

Didn't know the return was optional




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

Date: Sun, 06 May 2007 19:56:18 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: need a quick script
Message-Id: <5a6jalF2mumeiU1@mid.individual.net>

Lambik wrote:
> "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
> news:5a6elcF2n85heU1@mid.individual.net...
>> 
>>sub nameconvert {
>>    my ($first, $last) = split ' ', shift;
>>    substr($first, 0, 1) . $last
>>}
>>
>>print nameconvert('Chad Altenburg'), "\n";
> 
> Such a hopeless question and i still learned something. I would have done:
> 
> return substr($first, 0, 1) . $last
> 
> Didn't know the return was optional

It's optional when I want a sub return the value of the last evaluated 
expression.

     perldoc -f return

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


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

Date: Sun, 6 May 2007 17:27:43 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: system call - how-to.
Message-Id: <slrnf3rsvf.o73.hjp-usenet2@zeno.hjp.at>

On 2007-05-01 11:22, elsiddik <elsiddik@gmail.com> wrote:
> well i wanted to just mess a little with perl and try if it can give
> me the same result of a small shell script i wrote a little while ago
> but it doesnt seems to work out with me . here is my shell script
>
> #!/bin/bash
> DIRECTORY="/usr/bin"
> for file in $DIRECTORY/*
>    do whatis `basename $file`
>
> done
> exit 0
>
> i tried to run a similiar perl code by typing on command line.
>
> perl -e "system qw (whatis /usr/bin/*)"
>
> but its not giving me the same whatislog - what am i doing wrong ?

Your perl script doesn't do the same thing as your shell script.

Your shell script loops over all the filenames matching /usr/bin/*,
extracting the basename of each and calling whatis with that. So if your
/usr/bin/* starts like this:

    /usr/bin/822-date
    /usr/bin/Mail
    /usr/bin/X
    /usr/bin/X11
    /usr/bin/Xorg
    /usr/bin/[
    /usr/bin/a2p
    /usr/bin/aconnect
    /usr/bin/acpi
    /usr/bin/acpi_fakekey

it will invoke

    whatis 822-date
    whatis Mail
    whatis X
    ...

Your perl script just invokes the shell with the command
"whatis /usr/bin/*" (assuming qq instead of qw), which will will in turn
invoke

    whatis /usr/bin/822-date /usr/bin/Mail /usr/bin/X /usr/bin/X11 ...


	hp


-- 
   _  | Peter J. Holzer    | I know I'd be respectful of a pirate 
|_|_) | Sysadmin WSR       | with an emu on his shoulder.
| |   | hjp@hjp.at         |
__/   | http://www.hjp.at/ |	-- Sam in "Freefall"


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 410
**************************************


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