Re: When is qw used

2015-06-10 Thread bars0

Hi,

As far as I know qw(some list item) will import from Carp module only 
subs that you've explicitly requested. In this example `some, list, 
item` will be available in your namespace but not other from Carp module.


`use Carp;` will import all of them.

Krzysztof


On 2015-06-10 14:19, rakesh sharma wrote:

I have seen perl syntax like use Carp qw(some list items)
so when do we need to write like this and why is not the items of the
module getting imported


thanks
rakesh


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: When is qw used

2015-06-10 Thread Shawn H Corey
On Wed, 10 Jun 2015 17:49:44 +0530
rakesh sharma rakeshsharm...@hotmail.com wrote:

 I have seen perl syntax like use Carp qw(some list items)so when do
 we need to write like this and why is not the items of the module
 getting imported

As others have said, to import a selected set of functions or to import
functions not in the default import.

Also:

use Carp qw( :all );

Will import everything. Most modules (standard modules and CPAN ones)
will have the tag `:all` to import everything.

If you don't want to import any:

use Carp ();

To use a function in Carp, you would use the fully-qualified name:

Carp::croak ribbit;


-- 
Don't stop where the ink does.
Shawn

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: When is qw used

2015-06-10 Thread Carl Inglis
Some modules import all their endpoints by default; other only export a
subset, requiring you to explicitly request others.

Carp does not, by default, export cluck.

Regards,

Carl

On 10 June 2015 at 13:40, rakesh sharma rakeshsharm...@hotmail.com wrote:

 Hi Krzysztof

 If that was the case , using the subs inside Carp should  not show any
 error.
 Bu I was not able to use cluck without using qw and was able to use croak
 and confess without the qw.
 Don't get it

 thanks
 rakesh

  Date: Wed, 10 Jun 2015 14:30:28 +0200
  From: bars0.bars0.ba...@gmail.com
  To: rakeshsharm...@hotmail.com; beginners@perl.org
  Subject: Re: When is qw used
 
  Hi,
 
  As far as I know qw(some list item) will import from Carp module only
  subs that you've explicitly requested. In this example `some, list,
  item` will be available in your namespace but not other from Carp module.
 
  `use Carp;` will import all of them.
 
  Krzysztof
 
 
  On 2015-06-10 14:19, rakesh sharma wrote:
   I have seen perl syntax like use Carp qw(some list items)
   so when do we need to write like this and why is not the items of the
   module getting imported
  
  
   thanks
   rakesh
 
  --
  To unsubscribe, e-mail: beginners-unsubscr...@perl.org
  For additional commands, e-mail: beginners-h...@perl.org
  http://learn.perl.org/
 
 



RE: When is qw used

2015-06-10 Thread rakesh sharma
Hi Krzysztof
If that was the case , using the subs inside Carp should  not show any error.Bu 
I was not able to use cluck without using qw and was able to use croak and 
confess without the qw.Don't get it
thanksrakesh

 Date: Wed, 10 Jun 2015 14:30:28 +0200
 From: bars0.bars0.ba...@gmail.com
 To: rakeshsharm...@hotmail.com; beginners@perl.org
 Subject: Re: When is qw used
 
 Hi,
 
 As far as I know qw(some list item) will import from Carp module only 
 subs that you've explicitly requested. In this example `some, list, 
 item` will be available in your namespace but not other from Carp module.
 
 `use Carp;` will import all of them.
 
 Krzysztof
 
 
 On 2015-06-10 14:19, rakesh sharma wrote:
  I have seen perl syntax like use Carp qw(some list items)
  so when do we need to write like this and why is not the items of the
  module getting imported
 
 
  thanks
  rakesh
 
 -- 
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/
 
 
  

Re: When is qw used

2015-06-10 Thread bars0

Hi,

Please run perldoc Carp at your command prompt.
As you can see, cluck, longmess and shortmess not exported by default.

NAME
Carp - alternative warn and die for modules

SYNOPSIS
use Carp;

# warn user (from perspective of caller)
carp string trimmed to 80 chars;

# die of errors (from perspective of caller)
croak We're outta here!;

# die of errors with stack backtrace
confess not implemented;

# cluck, longmess and shortmess not exported by default
use Carp qw(cluck longmess shortmess);
cluck This is how we got here!;
$long_message   = longmess( message from cluck() or confess() );
$short_message  = shortmess( message from carp() or croak() );


Krzysztof


On 2015-06-10 14:40, rakesh sharma wrote:

Hi Krzysztof

If that was the case , using the subs inside Carp should  not show any
error.
Bu I was not able to use cluck without using qw and was able to use
croak and confess without the qw.
Don't get it

thanks
rakesh

  Date: Wed, 10 Jun 2015 14:30:28 +0200
  From: bars0.bars0.ba...@gmail.com
  To: rakeshsharm...@hotmail.com; beginners@perl.org
  Subject: Re: When is qw used
 
  Hi,
 
  As far as I know qw(some list item) will import from Carp module only
  subs that you've explicitly requested. In this example `some, list,
  item` will be available in your namespace but not other from Carp module.
 
  `use Carp;` will import all of them.
 
  Krzysztof
 
 
  On 2015-06-10 14:19, rakesh sharma wrote:
   I have seen perl syntax like use Carp qw(some list items)
   so when do we need to write like this and why is not the items of the
   module getting imported
  
  
   thanks
   rakesh
 
  --
  To unsubscribe, e-mail: beginners-unsubscr...@perl.org
  For additional commands, e-mail: beginners-h...@perl.org
  http://learn.perl.org/
 
 


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




When is qw used

2015-06-10 Thread rakesh sharma
I have seen perl syntax like use Carp qw(some list items)so when do we need to 
write like this and why is not the items of the module getting imported

thanksrakesh  

Re: When is qw used

2015-06-10 Thread Shlomi Fish
Hi Rakesh,

On Wed, 10 Jun 2015 18:10:12 +0530
rakesh sharma rakeshsharm...@hotmail.com wrote:

 Hi Krzysztof
 If that was the case , using the subs inside Carp should  not show any
 error.Bu I was not able to use cluck without using qw and was able to use
 croak and confess without the qw.Don't get it thanksrakesh
 

First of all, qw(...) is a notation for writing a list of uninterpolated
strings:

#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper (Dumper);

my @x = qw(Foo bar baz cloox matista englame09555 343);

print Dumper(\@x);

shlomif@telaviv1:~$ perl Test.pl
$VAR1 = [
  'Foo',
  'bar',
  'baz',
  'cloox',
  'matista',
  'englame09555',
  '343'
];
shlomif@telaviv1:~$ 

Secondly:

use Carp qw(cluck);

is equivalent to:

use Carp (cluck);

Finally, if you do «use Carp;» it will try calling Carp-import() with no
arguments which  will import the default symbols. To not import anything , one
should write «use Carp ();». For more info see:

http://perldoc.perl.org/functions/use.html

For good measure and maintenance sanity, one should explicitly import all the
needed symbols and not rely on the default «use Carp;» imports. See:

http://perl-begin.org/tutorials/bad-elements/#non_explicitly_imported_symbols

(*NOTE*: I have created that page and still maintain it.)

Regards,

Shlomi Fish

  Date: Wed, 10 Jun 2015 14:30:28 +0200
  From: bars0.bars0.ba...@gmail.com
  To: rakeshsharm...@hotmail.com; beginners@perl.org
  Subject: Re: When is qw used
  
  Hi,
  
  As far as I know qw(some list item) will import from Carp module only 
  subs that you've explicitly requested. In this example `some, list, 
  item` will be available in your namespace but not other from Carp module.
  
  `use Carp;` will import all of them.
  
  Krzysztof
  
  
  On 2015-06-10 14:19, rakesh sharma wrote:
   I have seen perl syntax like use Carp qw(some list items)
   so when do we need to write like this and why is not the items of the
   module getting imported
  
  
   thanks
   rakesh
  
  -- 
  To unsubscribe, e-mail: beginners-unsubscr...@perl.org
  For additional commands, e-mail: beginners-h...@perl.org
  http://learn.perl.org/
  
  
 


-- 
-
Shlomi Fish   http://www.shlomifish.org/
My Photos - http://www.flickr.com/photos/shlomif/

How can you make a programming language that will be good for everything if you
cannot even make such a screwdriver?
— An Israeli Open Source Software Enthusiast.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Syntax error on use Cwd qw(abs_path);

2011-05-31 Thread Jim Gibson

At 11:10 AM -0700 5/26/11, Derek wrote:

Hello, I am getting the following error:

bash: /var/www/html/bugzilla/email_in.pl: line 2: syntax error near
unexpected token `('
bash: /var/www/html/bugzilla/email_in.pl: line 2: `use Cwd
qw(abs_path);'

The contents of this file are:

#!/usr/bin/perl
use Cwd qw(abs_path);

Thats all. I know basically nothing about perl. I am a Java programmer
mostly. I am getting this same problem in the bugzilla email_in.pl
scripts. So I trimmed it down to the shortest amount of lines that
seem to be the problem. I tried to look up what the lines are doing
but I cant figure it out why its complaining of an error.

I can run this on the command line with no errors:

perl -e 'use Cwd qw(abs_path);'

Why would I not be able to run this in a script but I can on the
command line?


Because bash is not running the Perl interpreter, but trying to 
execute the file as bash commands. That is why the first part of each 
error line is bash:. Something is wrong with your first line. Try 
this:


perl /var/www/html/bugzilla/email_in.pl: line 2: syntax error near

and see what you get.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Syntax error on use Cwd qw(abs_path);

2011-05-28 Thread Derek
Hello, I am getting the following error:

bash: /var/www/html/bugzilla/email_in.pl: line 2: syntax error near
unexpected token `('
bash: /var/www/html/bugzilla/email_in.pl: line 2: `use Cwd
qw(abs_path);'

The contents of this file are:

#!/usr/bin/perl
use Cwd qw(abs_path);

Thats all. I know basically nothing about perl. I am a Java programmer
mostly. I am getting this same problem in the bugzilla email_in.pl
scripts. So I trimmed it down to the shortest amount of lines that
seem to be the problem. I tried to look up what the lines are doing
but I cant figure it out why its complaining of an error.

I can run this on the command line with no errors:

perl -e 'use Cwd qw(abs_path);'

Why would I not be able to run this in a script but I can on the
command line?

Thanks.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Syntax error on use Cwd qw(abs_path);

2011-05-28 Thread Uri Guttman
 D == Derek  derek...@gmail.com writes:

  D Hello, I am getting the following error:
  D bash: /var/www/html/bugzilla/email_in.pl: line 2: syntax error near
  D unexpected token `('

big clue. what is the first word of that line? it is bash! perl is not
seeing your script for some reason. so this is not a perl issue but a
bash one. find out why bash is running your file instead of perl.

uri

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

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Syntax error on use Cwd qw(abs_path);

2011-05-28 Thread Bob goolsby
Mornin' --

Derek Said:

The contents of this file are:

#!/usr/bin/perl
use Cwd qw(abs_path);


If the first line is indeed a blank line, then the default interpreter is
invoked.  The '#!' has to the the first two characters on the first line of
your code.

B

On Sat, May 28, 2011 at 12:10 PM, Uri Guttman u...@stemsystems.com wrote:

  D == Derek  derek...@gmail.com writes:

  D Hello, I am getting the following error:
  D bash: /var/www/html/bugzilla/email_in.pl: line 2: syntax error near
  D unexpected token `('

 big clue. what is the first word of that line? it is bash! perl is not
 seeing your script for some reason. so this is not a perl issue but a
 bash one. find out why bash is running your file instead of perl.

 uri

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

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/





-- 

Bob Goolsby
bob.gool...@gmail.com


Re: How ro specify path in use lib qw()

2010-04-12 Thread Shlomi Fish
Hi Mimi,

On Monday 12 Apr 2010 02:32:12 Mimi Cafe wrote:
 My program is in the same directory as my module directory, but when I use
 relative path in use lib, Perl doesn't find the module.
 
 
 
 use lib qw(MyModule/), use lib qw(./MyModule/), use lib qw(MyModule) or use
 lib qw(./MyModule/) # these don't work.
 
 
 
 use lib qw(/var/www/cgi-bin/MyProject/) # This work fine, but I want to
 avoid absolute path because it will not work on SuSe Linux for example.
 
 
 
 
 
 I have tried various ways of specifying relative path and they don't work
 except the absolute path from the / (file system root). I don't want to use
 the absolute path it will break if my program is not still on RedHat Linux
 where httpd docs are store in /var/www/*.
 
 
 
 What is the recommended way of specifying the path in the CGI application?
 It is relate to the web server document root as the file system / dir?
 

You can try the solution given in:

http://use.perl.org/~Aristotle/journal/33995

use lib can do relative paths just fine (as in the examples you have given), 
but the fact that this is a server-side program may mess with the current 
working directory. You can experiment by debugging stuff using print and 
Data::Dumper to see.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
The Case for File Swapping - http://shlom.in/file-swap

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




How ro specify path in use lib qw()

2010-04-11 Thread Mimi Cafe
 

My program is in the same directory as my module directory, but when I use
relative path in use lib, Perl doesn't find the module.

 

use lib qw(MyModule/), use lib qw(./MyModule/), use lib qw(MyModule) or use
lib qw(./MyModule/) # these don't work.

 

use lib qw(/var/www/cgi-bin/MyProject/) # This work fine, but I want to
avoid absolute path because it will not work on SuSe Linux for example.

 

 

I have tried various ways of specifying relative path and they don't work
except the absolute path from the / (file system root). I don't want to use
the absolute path it will break if my program is not still on RedHat Linux
where httpd docs are store in /var/www/*. 

 

What is the recommended way of specifying the path in the CGI application?
It is relate to the web server document root as the file system / dir?

 

 

Mimi



Strange behavior with POSIX qw(fpathconf)

2010-03-31 Thread Paul Smith
I have a feeling this is not a beginners question (I've been hacking
in Perl for many years and UNIX systems for far longer) but it seems my
choices are this list, or perl5-porters which also doesn't seem right.
Isn't there any list where non-beginner questions can be asked?

Anyway.

I have a Perl environment which is v5.8.8 built for
x86_64-linux-thread-multi, running on a Red Hat Enterprise Linux 5.3
system.  In this environment, I create a pipe then I want to know the
maximum amount I can write to the pipe without blocking.  So, I have
this code:

my ($printrd, $printwd, $pipebuf);
pipe($printrd, $printwd) or die pipe(print): $!\n;
$pipebuf = fpathconf($printwd, _PC_PIPE_BUF)
or die fpathconf(pipe): $!\n;

I wrote this code in 2007 and it's run on Red Hat EL 4 and EL 5 systems
for years.  Once or twice over that time I got reports, that were never
reproduced, of the latter die (fpathconf) being hit.  The error was
invalid file descriptor.

Within the last month or so (I have NO IDEA what's changed!) I've
started getting failures (on multiple quite different systems)
irregularly still, but much more frequently.

I'm really stumped as to what might be the problem here.

Playing around I changed the code so that if the fpathconf() of the
write FD failed, it would try the read FD.  I can't be sure (since the
problem is intermittent) but is _seems_ like the read FD is working.

I really don't want to just change this and call it good, though,
without some indication that this is really the problem, and it's not
just that I've been lucky so far with the read FD.


Has anyone ever heard of anything like this before?  Is it true that
it's better/safer (in Perl?  Everywhere?) to run fpathconf() on the read
FD?  I've never heard of such a thing, but if this is a known behavior
that's fine with me.

Thanks...


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Strange behavior with POSIX qw(fpathconf)

2010-03-31 Thread Bob goolsby
Post this on Perl Monks (http://perlmonks.org/) for non-beginner feed back,

Old Gray Bear

On Tue, Mar 30, 2010 at 2:38 PM, Paul Smith p...@mad-scientist.net wrote:
 I have a feeling this is not a beginners question (I've been hacking
 in Perl for many years and UNIX systems for far longer) but it seems my
 choices are this list, or perl5-porters which also doesn't seem right.
 Isn't there any list where non-beginner questions can be asked?

 Anyway.

 I have a Perl environment which is v5.8.8 built for
 x86_64-linux-thread-multi, running on a Red Hat Enterprise Linux 5.3
 system.  In this environment, I create a pipe then I want to know the
 maximum amount I can write to the pipe without blocking.  So, I have
 this code:

    my ($printrd, $printwd, $pipebuf);
    pipe($printrd, $printwd) or die pipe(print): $!\n;
    $pipebuf = fpathconf($printwd, _PC_PIPE_BUF)
        or die fpathconf(pipe): $!\n;

 I wrote this code in 2007 and it's run on Red Hat EL 4 and EL 5 systems
 for years.  Once or twice over that time I got reports, that were never
 reproduced, of the latter die (fpathconf) being hit.  The error was
 invalid file descriptor.

 Within the last month or so (I have NO IDEA what's changed!) I've
 started getting failures (on multiple quite different systems)
 irregularly still, but much more frequently.

 I'm really stumped as to what might be the problem here.

 Playing around I changed the code so that if the fpathconf() of the
 write FD failed, it would try the read FD.  I can't be sure (since the
 problem is intermittent) but is _seems_ like the read FD is working.

 I really don't want to just change this and call it good, though,
 without some indication that this is really the problem, and it's not
 just that I've been lucky so far with the read FD.


 Has anyone ever heard of anything like this before?  Is it true that
 it's better/safer (in Perl?  Everywhere?) to run fpathconf() on the read
 FD?  I've never heard of such a thing, but if this is a known behavior
 that's fine with me.

 Thanks...


 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/






-- 
B

Bob Goolsby
bob.gool...@gmail.com

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




List with qw and without

2008-07-26 Thread William
package MyConfig;
use constant (DOCUMENT_ROOT = /var/www/);
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(DOCUMENT_ROOT); # This works
#our @EXPORT_OK = (DOCUMENT_ROOT); # But this does not work

1;

use MyConfig qw(DOCUMENT_ROOT);
print DOCUMENT_ROOT;

# If I do not use qw , I will get error of DOCUMENT_ROOT is not exported by 
the MyConfig module
# Why is qw importance is so significance here ?
# I thought qw is just a syntatic sugar of perl to make a list
# Thank you.


Send instant messages to your online friends http://uk.messenger.yahoo.com

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: List with qw and without

2008-07-26 Thread Rob Dixon
William wrote:
 package MyConfig;
 use constant (DOCUMENT_ROOT = /var/www/);
 require Exporter;
 our @ISA = qw(Exporter);
 our @EXPORT_OK = qw(DOCUMENT_ROOT); # This works
 #our @EXPORT_OK = (DOCUMENT_ROOT); # But this does not work
 
 1;
 
 use MyConfig qw(DOCUMENT_ROOT);
 print DOCUMENT_ROOT;
 
 # If I do not use qw , I will get error of DOCUMENT_ROOT is not exported by 
 the MyConfig module
 # Why is qw importance is so significance here ?
 # I thought qw is just a syntatic sugar of perl to make a list
 # Thank you.

That's correct. qw splits its parameter on whitespace, so

  qw(A B C)

is similar to

  split ' ', 'A B C'


So if you write

  use MyConfig 'DOCUMENT_ROOT';

or

  use MyConfig ('DOCUMENT_ROOT');

then your program will work as expected. But because you've defined the constant
DOCUMENT_ROOT to be /var/www/

  use MyConfig (DOCUMENT_ROOT);

is the same as saying

  use MyConfig (/var/www/);

which is nonsense.

HTH,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Shell qw(mysqldump) and localtime.

2007-09-03 Thread Shams Fantar

Hello,

I want to give a date (the year, the day, the hour and the minute) to a 
file. So, I use localtime function. But I don't understand how to use 
localtime (after reading the documentation on this function). Can you 
help me with this function?


Next, I want to use a shell command, so I use the Shell function[2], and 
I must use the 'mysqldump' command :


mysqldump -u root -p *** --all-databases  $FILE

How could I use this command with the Shell function ?

[1] : http://perldoc.perl.org/functions/localtime.html
[2] : http://perldoc.perl.org/Shell.html

I'm a beginner with perl... :-)

Thanks !

--
Shams Fantar (http://snurf.info)


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Shell qw(mysqldump) and localtime.

2007-09-03 Thread Jeff Pang
try the POSIX::strftime,this use the same datetime format as shell's
date command.

perl -e '
use POSIX qw/strftime/;
print strftime(%y%m%d %H:%M,localtime); '

070903 21:51

2007/9/3, Shams Fantar [EMAIL PROTECTED]:
 Hello,

 I want to give a date (the year, the day, the hour and the minute) to a
 file. So, I use localtime function. But I don't understand how to use
 localtime (after reading the documentation on this function). Can you
 help me with this function?

 Next, I want to use a shell command, so I use the Shell function[2], and
 I must use the 'mysqldump' command :

 mysqldump -u root -p *** --all-databases  $FILE

 How could I use this command with the Shell function ?

 [1] : http://perldoc.perl.org/functions/localtime.html
 [2] : http://perldoc.perl.org/Shell.html

 I'm a beginner with perl... :-)

 Thanks !

 --
 Shams Fantar (http://snurf.info)


 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Shell qw(mysqldump) and localtime.

2007-09-03 Thread Shams Fantar

Jeff Pang wrote:

try the POSIX::strftime,this use the same datetime format as shell's
date command.

perl -e '
use POSIX qw/strftime/;
print strftime(%y%m%d %H:%M,localtime); '

070903 21:51
  


Okay. All right.

use POSIX qw(strftime);
my $date1 = strftime(%y/%m/%d %H:%M,localtime);
my $FILE = /home/scripts/backups_db/db-$date1.sql;

  

Next, I want to use a shell command, so I use the Shell function[2], and
I must use the 'mysqldump' command :

mysqldump -u root -p *** --all-databases  $FILE

How could I use this command with the Shell function ?

[2] : http://perldoc.perl.org/Shell.html




  


And for this question ?

Regards,

--
Shams Fantar (http://snurf.info)


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Shell qw(mysqldump) and localtime.

2007-09-03 Thread Jeff Pang
2007/9/3, Shams Fantar [EMAIL PROTECTED]:
 Jeff Pang wrote:
  try the POSIX::strftime,this use the same datetime format as shell's
  date command.
 
  perl -e '
  use POSIX qw/strftime/;
  print strftime(%y%m%d %H:%M,localtime); '
 
  070903 21:51
 

 Okay. All right.

 use POSIX qw(strftime);
 my $date1 = strftime(%y/%m/%d %H:%M,localtime);
 my $FILE = /home/scripts/backups_db/db-$date1.sql;

 
  Next, I want to use a shell command, so I use the Shell function[2], and
  I must use the 'mysqldump' command :
 
  mysqldump -u root -p *** --all-databases  $FILE
 
  How could I use this command with the Shell function ?
 
  [2] : http://perldoc.perl.org/Shell.html
 
 
 
 

 And for this question ?


What question?running shell command in perl script?
You may need the system call.
system('command','arg1','arg2',...)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Shell qw(mysqldump) and localtime.

2007-09-03 Thread Shams Fantar

Jeff Pang wrote:

2007/9/3, Shams Fantar [EMAIL PROTECTED]:
  

Jeff Pang wrote:


try the POSIX::strftime,this use the same datetime format as shell's
date command.

perl -e '
use POSIX qw/strftime/;
print strftime(%y%m%d %H:%M,localtime); '

070903 21:51

  

Okay. All right.

use POSIX qw(strftime);
my $date1 = strftime(%y/%m/%d %H:%M,localtime);
my $FILE = /home/scripts/backups_db/db-$date1.sql;



Next, I want to use a shell command, so I use the Shell function[2], and
I must use the 'mysqldump' command :

mysqldump -u root -p *** --all-databases  $FILE

How could I use this command with the Shell function ?

[2] : http://perldoc.perl.org/Shell.html



  

And for this question ?




What question?running shell command in perl script?
You may need the system call.
system('command','arg1','arg2',...)

  


Yes, or exec().

Regards,

--
Shams Fantar (http://snurf.info)


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Shell qw(mysqldump) and localtime.

2007-09-03 Thread Adriano Ferreira
On 9/3/07, Shams Fantar [EMAIL PROTECTED] wrote:
 Hello,

 I want to give a date (the year, the day, the hour and the minute) to a
 file. So, I use localtime function. But I don't understand how to use
 localtime (after reading the documentation on this function). Can you
 help me with this function?

 Next, I want to use a shell command, so I use the Shell function[2], and
 I must use the 'mysqldump' command :

 mysqldump -u root -p *** --all-databases  $FILE

The Shell module may be used to make this system call to the utility
'mysqldump' transparent to the code. Like this:

  use Shell qw( mysqldump );
  my $content = mysqldump( qw( -u root -p *** --all-databases ) );

The mysqldump() function gets all the output produced by the utility
'mysqldump'. But there's very much to be gained by using Shell. And
unless your script is very small, it's not such a good idea to use it
(the Shell core module).


 How could I use this command with the Shell function ?

 [1] : http://perldoc.perl.org/functions/localtime.html
 [2] : http://perldoc.perl.org/Shell.html

 I'm a beginner with perl... :-)

 Thanks !

Welcome to Perl.

Best regards,
Adriano Ferreira

 --
 Shams Fantar (http://snurf.info)


 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Shell qw(mysqldump) and localtime.

2007-09-03 Thread Shams Fantar

Adriano Ferreira wrote:

On 9/3/07, Shams Fantar [EMAIL PROTECTED] wrote:
  

Hello,

I want to give a date (the year, the day, the hour and the minute) to a
file. So, I use localtime function. But I don't understand how to use
localtime (after reading the documentation on this function). Can you
help me with this function?

Next, I want to use a shell command, so I use the Shell function[2], and
I must use the 'mysqldump' command :

mysqldump -u root -p *** --all-databases  $FILE



The Shell module may be used to make this system call to the utility
'mysqldump' transparent to the code. Like this:

  use Shell qw( mysqldump );
  my $content = mysqldump( qw( -u root -p *** --all-databases ) );

The mysqldump() function gets all the output produced by the utility
'mysqldump'. But there's very much to be gained by using Shell. And
unless your script is very small, it's not such a good idea to use it
(the Shell core module).
  


Okay, there are thus many solutions. ;-)

  

How could I use this command with the Shell function ?

[1] : http://perldoc.perl.org/functions/localtime.html
[2] : http://perldoc.perl.org/Shell.html

I'm a beginner with perl... :-)

Thanks !



Welcome to Perl.

  


Thank you very much !


Best regards,
Adriano Ferreira

  


--
Shams Fantar (http://snurf.info)


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




qw with strings containing spaces

2007-08-09 Thread Mathew Snyder
I need to populate a select multiple on a web page when it loads with a series
of values.  Most of the values will be determined dynamically when the code runs
but some are static.  They look like A - H, I - P and Q - Z.  The spaces
are for readability.

What I am doing is declaring an array and assigning the value:
@array = qw/All A - H I - P Q - Z/;
and then pushing the to-be-determined values onto the array later on.  However,
when I print this all out while testing, I get each letter, hyphen and quote as
individual elements.  I've tried escaping different ways to no avail.

I've looked on PerlMonks and saw a solution which created a scalar with a string
containing each item separated by commas.  It is then run through the split()
function using the commas as the delimiter.  I'd like a more succinct and
cleaner method of doing this though, if possible.

Any ideas?

Mathew
-- 
Keep up with me and what I'm up to: http://theillien.blogspot.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: qw with strings containing spaces

2007-08-09 Thread Flemming Greve Skovengaard

Mathew Snyder wrote:

I need to populate a select multiple on a web page when it loads with a series
of values.  Most of the values will be determined dynamically when the code runs
but some are static.  They look like A - H, I - P and Q - Z.  The spaces
are for readability.

What I am doing is declaring an array and assigning the value:
@array = qw/All A - H I - P Q - Z/;
and then pushing the to-be-determined values onto the array later on.  However,
when I print this all out while testing, I get each letter, hyphen and quote as
individual elements.  I've tried escaping different ways to no avail.

I've looked on PerlMonks and saw a solution which created a scalar with a string
containing each item separated by commas.  It is then run through the split()
function using the commas as the delimiter.  I'd like a more succinct and
cleaner method of doing this though, if possible.

Any ideas?

Mathew


Why not just declare @array like this:
my @array = (All, A - H, I - P, Q - Z);

and then later push new variables onto it, like so:
push @array, qw/1 2 3/;

--
Flemming Greve Skovengaard   FAITH, n.
a.k.a Greven, TuxPower   Belief without evidence in what is told
[EMAIL PROTECTED]  by one who speaks without knowledge,
4011.25 BogoMIPS of things without parallel.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: qw with strings containing spaces

2007-08-09 Thread John W. Krahn

Mathew Snyder wrote:

I need to populate a select multiple on a web page when it loads with a series
of values.  Most of the values will be determined dynamically when the code runs
but some are static.  They look like A - H, I - P and Q - Z.  The spaces
are for readability.

What I am doing is declaring an array and assigning the value:
@array = qw/All A - H I - P Q - Z/;
and then pushing the to-be-determined values onto the array later on.  However,
when I print this all out while testing, I get each letter, hyphen and quote as
individual elements.  I've tried escaping different ways to no avail.


qw/All A - H I - P Q - Z/

is the same as saying:

split ' ', q/All A - H I - P Q - Z/

so when using qw// there are no strings just whitespace characters and 
non-whitespace characters.  What you want is:


my @array = ( 'All', 'A - H', 'I - P', 'Q - Z' );



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

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: qw with strings containing spaces

2007-08-09 Thread usenet
On Aug 9, 11:58 am, [EMAIL PROTECTED] (Mathew Snyder) wrote:

 What I am doing is declaring an array and assigning the value:
 @array = qw/All A - H I - P Q - Z/;

You don't want qw{} here.  Just do it the brute-force way:

 @array = (All, A - H, I - P, Q - Z);


--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Variables in qw?

2004-06-20 Thread John W. Krahn
Gohaku wrote:
 
 Hi everyone,

Hello,

 I was just curious if there is someway to add a variable when using qw.
 I am trying to do the following:
 #Testing qw
 $string_variable = abc;
 @array = qw( string_literal1 string_literal2 $string_variable )
 print join( ,@array);
 #Would like to see:
 #string_literal1 string_literal2 abc
 
 I realize I could do the following:
 @array = qw( string_literal1 string_literal2 );
 push(@array,$string_variable);
 
 would like to hear if there is a shorter way...

Well, you could do it like this:

my @array = ( string_literal1 = string_literal2 = $string_variable );


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Variables in qw?

2004-06-19 Thread gohaku
Hi everyone,
I was just curious if there is someway to add a variable when using qw.
I am trying to do the following:
#Testing qw
$string_variable = abc;
@array = qw( string_literal1 string_literal2 $string_variable )
print join( ,@array);
#Would like to see:
#string_literal1 string_literal2 abc
I realize I could do the following:
@array = qw( string_literal1 string_literal2 ); 
push(@array,$string_variable);

would like to hear if there is a shorter way...
Thanks in advance.
-gohaku
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Variables in qw?

2004-06-19 Thread Charles K. Clarkson
gohaku [EMAIL PROTECTED] wrote:

: Hi everyone,
: I was just curious if there is someway to add a
: variable when using qw. I am trying to do the
: following:

[snip]

my $foo = 'bar';
my @arr = ( qw(foo bar), $foo );


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




use CGI qw(:standard);

2004-06-14 Thread Werner Otto
When using this module and Im printing out a checkbox group:
print checkbox_group(-name='hdel',-values=[$hostname]),;
is there a way to sneak through a hidden value $hostip in there somehow 
aswell?

--
Kind Regards,
Otto
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



use CGI qw(:standard);

2004-06-11 Thread Werner Otto
Hi,
I am making use of use CGI qw(:standard); to create my form. I need to 
amend the size of a submit button and need to tell the button which script 
to call (ie. action=test.cgi). Where can I find documentation on all the 
attributes of the components, or an example for my two queries would be 
appreciated.

--
Otto.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: use CGI qw(:standard);

2004-06-11 Thread Owen Cook

On Fri, 11 Jun 2004, Werner Otto wrote:

 I am making use of use CGI qw(:standard); to create my form. I need to 
 amend the size of a submit button and need to tell the button which script 
 to call (ie. action=test.cgi). Where can I find documentation on all the 
 attributes of the components, or an example for my two queries would be 
 appreciated.


perldoc CGI

look for HOW TO CREATE A SUBMIT BUTTON etc.



Owen 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: use CGI qw(:standard);

2004-06-11 Thread David Dorward
On 11 Jun 2004, at 09:57, Werner Otto wrote:
I am making use of use CGI qw(:standard); to create my form. I need to 
amend the size of a submit button
   print $query-submit(-name='button_name',
-size=15,
-value='value');
and need to tell the button which script to call (ie. action=test.cgi).
You can't do that. The closest you can come in an HTML document is to 
use JavaScript (attached to the onclick and onkeydown even handlers) to 
dynamically alter the action. This is a really bad idea as it fails in 
the absence of JavaScript.

The standard way to get the same effect is to test the value of the 
button (which you must give a name) in the form handler. You can then 
do whatever actions you like (which may involve an http redirect to 
another script). Be aware that it is possible for users to submit forms 
without clicking on any submit button, so you need to have the form 
handler act in a sane way if $query-param('button_name') isn't set.

Where can I find documentation on all the attributes of the components
http://www.w3.org/TR/html4/index/elements.html
--
David Dorward
 http://dorward.me.uk/
http://blog.dorward.me.uk/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: use CGI qw(:standard);

2004-06-11 Thread Camilo Gonzalez
Owen Cook wrote:
On Fri, 11 Jun 2004, Werner Otto wrote:
 

I am making use of use CGI qw(:standard); to create my form. I need to 
amend the size of a submit button and need to tell the button which script 
to call (ie. action=test.cgi). Where can I find documentation on all the 
attributes of the components, or an example for my two queries would be 
appreciated.
   


perldoc CGI
look for HOW TO CREATE A SUBMIT BUTTON etc.

Owen 

 

Methinks you may need to use style sheets to force the type size and 
thus the overall size smaller. Make sure to specify type size as pixels. 
See the CGI documentation for using style sheets with the CGI module.

As an alternative, you can always make the submit button an image.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



help with user vars qw

2004-01-05 Thread Ricardo Pichler
Hi,  I'm beginner in the perl world, I having see very files .pl to learn and I  have 
one question...
In this script, what do make the parts in bold?


#!/usr/bin/perl
use strict;
$|=0;
use vars qw (%WRRConf %DHCPDConf %IPTablesConf %GeneralConf
 %DBIConf %NetworkConf %IfCfgConf %WIPLConf
 %WANInitConf %LANInitConf
 %NetworkRemoteConf %WRRRemoteConf %DHCPDRemoteConf
 %IPTablesRemoteConf %GeneralRemoteConf %SubnetRemoteConf
 %AdmNetRemoteConf %VisitorSubnetRemoteConf
 %BlockedSubnetRemoteConf %WANRemoteConf
 %DCClientsMAC %DCClientsWeight %DCClientsIP
 $dbh $Debug
);

This file have various includes .pm after these lines, I believe that this lines  in 
bold,
export the variables declared to modules. This is correct? This is an mode of making
they to becoming global to modules? Sorry my bad english.

Thanks in advance,
Ricardo Pichler

Re: help with user vars qw

2004-01-05 Thread Rob Dixon
Ricardo Pichler wrote:

 #!/usr/bin/perl
 use strict;
 $|=0;
 use vars qw (%WRRConf %DHCPDConf %IPTablesConf %GeneralConf
  %DBIConf %NetworkConf %IfCfgConf %WIPLConf
  %WANInitConf %LANInitConf
  %NetworkRemoteConf %WRRRemoteConf %DHCPDRemoteConf
  %IPTablesRemoteConf %GeneralRemoteConf %SubnetRemoteConf
  %AdmNetRemoteConf %VisitorSubnetRemoteConf
  %BlockedSubnetRemoteConf %WANRemoteConf
  %DCClientsMAC %DCClientsWeight %DCClientsIP
  $dbh $Debug
 );

 This file have various includes .pm after these lines, I believe that this lines  in 
 bold,
 export the variables declared to modules. This is correct? This is an mode of making
 they to becoming global to modules? Sorry my bad english.

Hi Ricardo.

'use vars' is very similar to declaring variables with 'our', which has been
available since Perl 5.6. In fact at this place in the program the two are
identical, and 'our' is preferred for new software. Both forms declare
persistent package variables in the current package.

Package variables differ from lexical variables in that there is only ever
one variable of a given name. In your example, for instance, using hash
%WRRConf anywhere in the program will access the same data, even within
subroutines and code blocks. This is in contrast with 'my' variables which
are created and destroyed as they are required, and are unique to the code
block in which they are declared.

This has no bearing on the modules that are included, and no exporting is
involved (although code in any package could, if it chose, access the
data as %main::WRRConf etc.)

There really should be a good reason to use package variables like this.
It is rarely necessary outside an imported module.

HTH,

Rob





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: help with user vars qw

2004-01-05 Thread Daniel Staal
--As off Monday, January 5, 2004 7:20 PM -0300, Ricardo Pichler is 
alleged to have said:

Hi,  I'm beginner in the perl world, I having see very files .pl to
learn and I  have one question... In this script, what do make the
parts in bold?
Umm, Bold?  You sent text/plain.  There is no bold.

# !/usr/bin/perl
use strict;
$|=0;
use vars qw(%WRRConf %DHCPDConf %IPTablesConf %GeneralConf
 %DBIConf %NetworkConf %IfCfgConf %WIPLConf
 %WANInitConf %LANInitConf
 %NetworkRemoteConf %WRRRemoteConf
%DHCPDRemoteConf  %IPTablesRemoteConf
%GeneralRemoteConf %SubnetRemoteConf
%AdmNetRemoteConf %VisitorSubnetRemoteConf
%BlockedSubnetRemoteConf %WANRemoteConf
%DCClientsMAC %DCClientsWeight %DCClientsIP
$dbh $Debug
);
I'll assume this line of code is what you meant.  (Everything from 
'use' to ';' is one line of code, to me.)

This file have various includes .pm after these lines, I believe
that this lines  in bold, export the variables declared to modules.
This is correct? This is an mode of making they to becoming
global to modules? Sorry my bad english.
If I'm reading my copy of the Camel right it is declaring them to be 
valid global variables.  Perl has a concept of exported varibles as 
well, but this is just listing them in the global namespace.

I am sure that I'm reading it right when it says that this is 
depreciated.  (Meaning: it still works, but don't do it anymore.)

I'll leave it to someone who knows what they are talking about to 
tell me if I'm right. ;)

Daniel T. Staal

---
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: help with user vars qw

2004-01-05 Thread Randal L. Schwartz
 Ricardo == Ricardo Pichler [EMAIL PROTECTED] writes:

Ricardo Hi,  I'm beginner in the perl world, I having see very files .pl to learn and 
I  have one question...
Ricardo In this script, what do make the parts in bold?


Ricardo #!/usr/bin/perl
Ricardo use strict;
Ricardo $|=0;
Ricardo use vars qw (%WRRConf %DHCPDConf %IPTablesConf %GeneralConf
Ricardo  %DBIConf %NetworkConf %IfCfgConf %WIPLConf
Ricardo  %WANInitConf %LANInitConf
Ricardo  %NetworkRemoteConf %WRRRemoteConf %DHCPDRemoteConf
Ricardo  %IPTablesRemoteConf %GeneralRemoteConf %SubnetRemoteConf
Ricardo  %AdmNetRemoteConf %VisitorSubnetRemoteConf
Ricardo  %BlockedSubnetRemoteConf %WANRemoteConf
Ricardo  %DCClientsMAC %DCClientsWeight %DCClientsIP
Ricardo  $dbh $Debug
Ricardo );

I would be *so* happy not to ever have to work on this source file.

1) far too many globals
2) far too many Ugly-named globals
3) nearly impossible to test correctly

The problems faced by this file need to be delegated out into separate
modules, proabably (but not necessarily) with object interfaces.

Code review: $200/hr
Result of code review: priceless :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




use CGI qw(:cgi-lib :standard);

2003-11-12 Thread Yehezkiel B Syamsuhadi
What does this line mean?

use CGI qw(:cgi-lib :standard);

I know that use CGI; means to use CGI module but what does qw(:cgi-lib
:standard) that follow use CGI mean?

Thanks,
YBS



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: use CGI qw(:cgi-lib :standard);

2003-11-12 Thread Thomas Bätzler
Yehezkiel B Syamsuhadi [EMAIL PROTECTED] asked:
 What does this line mean?
 
 use CGI qw(:cgi-lib :standard);

The qw operator makes a text into a list by splitting at
the whitespace.

That list is passed to the module as an argument. In
CGI.pm's case these arguments are used to specify what
subset of CGI.pm's functions should be exported to your
namespace so that they can be called by their name.

See the CGI.pm manpage, section USING THE FUNCTION-
ORIENTED INTERFACE, for a list of export tags.

HTH,
Thomas

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Jeff 'japhy' Pinyan
On Nov 5, Dan Anderson said:

I've noticed that in code examples something like the following will be
used:

use Data::Dump qw(dump);
foo-bar qw(foo bar);

(Syntax may not be 100% correct).

Am I correct in assuming that if I have a subroutine foo (or method if
called with a package name), and I use qw() it takes all words seperated
by spaces, and passes them in as arguments.

So: foo-bar qw(foo bar); is equivalent to foo-bar(foo,bar); ?

Thanks in advance,

Dan



-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Jeff 'japhy' Pinyan
[sorry about that first post, I got ^X-happy]

On Nov 5, Dan Anderson said:

use Data::Dump qw(dump);
foo-bar qw(foo bar);

Am I correct in assuming that if I have a subroutine foo (or method if
called with a package name), and I use qw() it takes all words seperated
by spaces, and passes them in as arguments.

So: foo-bar qw(foo bar); is equivalent to foo-bar(foo,bar); ?

The qw() operator changes your source code at compile-time, which is why
you can say

  $object-method qw(...)

when ordinarily you'd need

  $object-method(...)

When you use qw(this that those), Perl changes that to

  ('this', 'that', 'those')

Perl splits the qw(...) on spaces, and returns the raw data,
single-quoted.  This means no variables.  You can't even escape a space:

  qw( abc\ def )

becomes

  ('abc\\', 'def')

That is all.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Randal L. Schwartz
 Dan == Dan Anderson [EMAIL PROTECTED] writes:

Dan So: foo-bar qw(foo bar); is equivalent to foo-bar(foo,bar); ?

Only in recent Perls.  The mapping of qw(...) to a (...) list at compile
time is a modern addition.  Older Perls replaced it with a runtime
split on the string, and probably would not accept it as the arglist
of a method call.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Dan Anderson

 Dan So: foo-bar qw(foo bar); is equivalent to foo-bar(foo,bar); ?
 
 Only in recent Perls.  

Do you know exactly how recent?  Are we talking 5 or better or 3 or
better?

Thanks in advance,

-Dan

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Jeff 'japhy' Pinyan
On Nov 6, Dan Anderson said:


 Dan So: foo-bar qw(foo bar); is equivalent to foo-bar(foo,bar); ?

 Only in recent Perls.

Do you know exactly how recent?  Are we talking 5 or better or 3 or
better?

Without check perldeltas, I'd say 5.6.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-05 Thread Dan Anderson
I've noticed that in code examples something like the following will be
used:

use Data::Dump qw(dump);
foo-bar qw(foo bar);

(Syntax may not be 100% correct).

Am I correct in assuming that if I have a subroutine foo (or method if
called with a package name), and I use qw() it takes all words seperated
by spaces, and passes them in as arguments.  

So: foo-bar qw(foo bar); is equivalent to foo-bar(foo,bar); ?

Thanks in advance,

Dan

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-05 Thread R. Joseph Newton
Dan Anderson wrote:

 I've noticed that in code examples something like the following will be
 used:

 use Data::Dump qw(dump);
 foo-bar qw(foo bar);

 (Syntax may not be 100% correct).

 Am I correct in assuming that if I have a subroutine foo (or method if
 called with a package name), and I use qw() it takes all words seperated
 by spaces, and passes them in as arguments.

 So: foo-bar qw(foo bar); is equivalent to foo-bar(foo,bar); ?

almost:
foo-bar ('foo', 'bar')

qq (foo bar) would render
(foo, bar)

It does make a difference.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



qw versus qx

2003-07-24 Thread JOHN FISHER
Is qw for holding list of data and qx is for running commands?
Do they both indicate a list context?
Thanks,
John



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: qw versus qx

2003-07-24 Thread Hanson, Rob
 Is qw for holding list of data and qx is for running commands?

yes.

 Do they both indicate a list context?

no.

qw{word word} is the same as ('word', 'word')... and qx{foo bar} is the same
as `foo bar`.  qx{} is just there if you need an alternate syntax to ``,
like if you needed to use a backtick in your command.

Rob

-Original Message-
From: JOHN FISHER [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 24, 2003 7:52 AM
To: [EMAIL PROTECTED]
Subject: qw versus qx


Is qw for holding list of data and qx is for running commands?
Do they both indicate a list context?
Thanks,
John



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: qw versus qx

2003-07-24 Thread Dan Muey
 
 Is qw for holding list of data and qx is for running 
 commands? Do they both indicate a list context? Thanks, John

 perldoc -f qq
 perlop Regexp Quote-Like Operators

 my @stuff = qw(hi bye joe mama);
 my @cmdln = qx(cat monkey.txt| grep fred);
 my $cmdln = qx(cat monkey.txt| grep fred);
 print qq(I said Foo you bar and they were like no way);

HTH

DMuey
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



difference between use Carp and use Carp qw(cluck)

2003-06-16 Thread Ramprasad
Hi all,

   What is the diff between

use Carp qw(cluck);
Carp::cluck(hello);
and

use Carp;
Carp::Cluck(hello);
I had assumed that when I 'use Carp qw ( cluck )' I will be able to use 
only the cluck function of Carp but when I tried it out I found it was 
not so. Then where does the difference lie.

Thanks
Ram




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: difference between use Carp and use Carp qw(cluck)

2003-06-16 Thread Jenda Krynicky
From: Ramprasad [EMAIL PROTECTED]
 What is the diff between
 
 use Carp qw(cluck);
 Carp::cluck(hello);
 
 and
 
 use Carp;
 Carp::Cluck(hello);
 
The difference is that in the first case the cluck() is imported into 
the current package/namespace so you may write just
cluck(hello);
while in the second case the module exports its default set of 
symbols. What is the default list depends on the module, but quite 
often modules do not export anything in that case.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



qq/qw

2002-09-16 Thread Rum Pel

hello

perl -e print qq(@INC)
prints the library paths.
Can somebody tell me what does qq do here?

Also, what does qw do in the following statement?

use HTTP::Request::Common qw(GET POST);


--rp

_
Send and receive Hotmail on your mobile device: http://mobile.msn.com


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: qq/qw

2002-09-16 Thread Toby Stuart

read the Regexp Quote-Like Operators section of the perlop manpage 

 -Original Message-
 From: Rum Pel [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, September 17, 2002 2:48 PM
 To: [EMAIL PROTECTED]
 Subject: qq/qw
 
 
 hello
 
 perl -e print qq(@INC)
 prints the library paths.
 Can somebody tell me what does qq do here?
 
 Also, what does qw do in the following statement?
 
 use HTTP::Request::Common qw(GET POST);
 
 
 --rp
 
 _
 Send and receive Hotmail on your mobile device: http://mobile.msn.com
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: qq/qw

2002-09-16 Thread George Schlossnagle

 From perldoc perlop:


   qq/STRING/

STRING
A double-quoted, interpolated string.

$_ .= qq
 (*** The previous line contains the naughty word 
$1.\n)
if /\b(tcl|java|python)\b/i;  # :-)
$baz = \n;# a one-character string


i.e.  qq  is just like double quotes.

qw/STRING/
Evaluates to a list of the words extracted out of
STRING, using embedded whitespace as the word
delimiters.  It can be understood as being roughly
equivalent to:

split(' ', q/STRING/);

the difference being that it generates a real list
at compile time.  So this expression:

qw(foo bar baz)

is semantically equivalent to the list:

'foo', 'bar', 'baz'

Some frequently seen examples:

use POSIX qw( setlocale localeconv )
@EXPORT = qw( foo bar baz );

A common mistake is to try to separate the words
with comma or to put comments into a multi-line
`qw'-string.  For this reason, the `use warnings'
pragma and the -w switch (that is, the `$^W' vari-
able) produces warnings if the STRING contains the
, or the # character.


i.e. qw takes a list of words that are whitespace separated and turns 
them into an array, split on the whitespace.

On Tuesday, September 17, 2002, at 12:47 AM, Rum Pel wrote:

 hello

 perl -e print qq(@INC)
 prints the library paths.
 Can somebody tell me what does qq do here?

 Also, what does qw do in the following statement?

 use HTTP::Request::Common qw(GET POST);


 --rp

 _
 Send and receive Hotmail on your mobile device: http://mobile.msn.com


 -- To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




removing qw( [ array ] ) seems to fix it?

2002-07-10 Thread Zachary Buckholz



Original::
avg_resp_time=  [ qw(@$avg_resp_time[0]
 @$avg_resp_time[1]
 @$avg_resp_time[2]
 @$avg_resp_time[3]
 @$avg_resp_time[4]
 @$avg_resp_time[5]
 @$avg_resp_time[6]) ],
Modification::
avg_resp_time=  [ (@$avg_resp_time[0],
 @$avg_resp_time[1],
 @$avg_resp_time[2],
 @$avg_resp_time[3],
 @$avg_resp_time[4],
 @$avg_resp_time[5],
 @$avg_resp_time[6]) ],


Now this works
$email_vars-{avg_resp_time}[0]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: removing qw( [ array ] ) seems to fix it?

2002-07-10 Thread John W. Krahn

Zachary Buckholz wrote:
 
 Original::
 avg_resp_time=  [ qw(@$avg_resp_time[0]
   @$avg_resp_time[1]
   @$avg_resp_time[2]
   @$avg_resp_time[3]
   @$avg_resp_time[4]
   @$avg_resp_time[5]
   @$avg_resp_time[6]) ],
 Modification::
 avg_resp_time=  [ (@$avg_resp_time[0],
 @$avg_resp_time[1],
 @$avg_resp_time[2],
 @$avg_resp_time[3],
 @$avg_resp_time[4],
 @$avg_resp_time[5],
 @$avg_resp_time[6]) ],
 
 Now this works
 $email_vars-{avg_resp_time}[0]

The quote words (qw) operator does not interpolate variables like a
double quoted string does.  The following are equivalent:

@x = qw($f $g $h $i);
@x = ('$f','$g','$h','$i');
@x = (\$f,\$g,\$h,\$i);


Also, instead of writing:

avg_resp_time=  [ (@$avg_resp_time[0],
@$avg_resp_time[1],
@$avg_resp_time[2],
@$avg_resp_time[3],
@$avg_resp_time[4],
@$avg_resp_time[5],
@$avg_resp_time[6]) ],

This will do the same thing:

avg_resp_time = [ @$avg_resp_time[0..6] ],



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




qw for help in - Re: Perl simple array

2002-04-17 Thread drieux


On Wednesday, April 17, 2002, at 04:59 , A. Rivera wrote:

 @data = (test1,test2,test3,test4);
 print $data[1];


my @data = qw/test1 test2 test3 test4/ ;

gives us all a chance to remember that since hubris and
laziness are two of our three virtues why quote
and comma that which can be done short and simple?

 Just wondering why the following code won't print anything at all.

 @data = test1,test2,test3,test4;

 @data = split(/,/);

 print $data[1];



ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




qw for variables?

2002-02-19 Thread Dennis G. Wicks

Greetings;

I can get qw to work for things like

@n = qw( john jacob jingleheimer schmidt );

but something like

@n = qw( $names );

doesn't work. I get the literal string $names in @n!

What does the equivalent of qw(???) for a variable?

Many TIA!
Dennis

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: qw for variables?

2002-02-19 Thread Nikola Janceski

qw( john jacob $name ) is equivelent to

('john', 'jacob', '$name')  notice the single quote. The single quotes does
not interpolate (use the special meanings of special charaters, so the $
doesn't designate a varible name it's just a $ character).

see man perlop
or perldoc perlop

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 19, 2002 2:39 PM
To: [EMAIL PROTECTED]
Subject: qw for variables?


Greetings;

I can get qw to work for things like

@n = qw( john jacob jingleheimer schmidt );

but something like

@n = qw( $names );

doesn't work. I get the literal string $names in @n!

What does the equivalent of qw(???) for a variable?

Many TIA!
Dennis

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: qw for variables?

2002-02-19 Thread Jonathan E. Paton

 What does the equivalent of qw(???) for a variable?

You mean like:

my @array = ($var1, $var2, $var3);

Jonathan Paton

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: qw for variables?

2002-02-19 Thread Dennis G. Wicks

Greetings;

No, I mean if $names contains Jesus Mary Joseph and I do

my @n = qw( $names );

I want the same results as if I had done

my @n = qw( Jesus Mary Joseph );

Obviously qw() does not work this way, but I can't find the
equivalent that does.

Thanks,
Dennis

}On Feb 19, 17:47, =?iso-8859-1?q?Jonathan=20E.=20Paton?= wrote:
} Subject: Re: qw for variables?
 What does the equivalent of qw(???) for a variable?

You mean like:

my @array = ($var1, $var2, $var3);

Jonathan Paton

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

}-- End of excerpt from =?iso-8859-1?q?Jonathan=20E.=20Paton?=



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: qw for variables?

2002-02-19 Thread Nikola Janceski

you want split then..

my $names = Jesus Mary Joseph;
my @n = split /\s+/, $names;


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 19, 2002 3:08 PM
To: [EMAIL PROTECTED]
Subject: Re: qw for variables?


Greetings;

No, I mean if $names contains Jesus Mary Joseph and I do

my @n = qw( $names );

I want the same results as if I had done

my @n = qw( Jesus Mary Joseph );

Obviously qw() does not work this way, but I can't find the
equivalent that does.

Thanks,
Dennis

}On Feb 19, 17:47, =?iso-8859-1?q?Jonathan=20E.=20Paton?= wrote:
} Subject: Re: qw for variables?
 What does the equivalent of qw(???) for a variable?

You mean like:

my @array = ($var1, $var2, $var3);

Jonathan Paton

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

}-- End of excerpt from =?iso-8859-1?q?Jonathan=20E.=20Paton?=



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: qw for variables?

2002-02-19 Thread Johnathan Kupferer

Dennis G. Wicks wrote:

Greetings;

No, I mean if $names contains Jesus Mary Joseph and I do

   my @n = qw( $names );

I want the same results as if I had done

   my @n = qw( Jesus Mary Joseph );

Obviously qw() does not work this way, but I can't find the
equivalent that does.

Thanks,
Dennis

How about:

my @n = split(/\s+/, $names);

- Johnathan



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: qw for variables?

2002-02-19 Thread Dennis G. Wicks

The split did the trick, and cut out a few lines of code
also. I had already done some splits and joins to get ready
for qw() which I can n ow delete!

Thanks for the help everyone!
Dennis

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: qw for variables?

2002-02-19 Thread Andrea Holstein

In article [EMAIL PROTECTED] wrote Dennis G. Wicks [EMAIL PROTECTED]:

 Greetings;
 
 I can get qw to work for things like
 
 @n = qw( john jacob jingleheimer schmidt );
 
 but something like
 
 @n = qw( $names );
 
 doesn't work. I get the literal string $names in @n!
 
 What does the equivalent of qw(???) for a variable?
 
Do you mean that $names contains the string
john jacob jingleheimer schmidt

Then split is your friend:
@n = split / /, $names;

Greetings,
Andrea

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




acronym of qw

2001-12-05 Thread nafiseh saberi

hi dear team...
I wish all of you be healthy.

do you know ...what is the acronym of qw that
use in Object-Oriented ??
thx.

  Best regards. Nafiseh Saberi   
   www.iraninfocenter.net
 www.sorna.net
Beaty is in the eye of the beholder.
 _



Re: acronym of qw

2001-12-05 Thread [EMAIL PROTECTED]

On Wed, 5 Dec 2001, nafiseh saberi wrote:

 Date: Wed, 5 Dec 2001 12:00:17 +0330
 From: nafiseh saberi [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: acronym of qw

 hi dear team...
 I wish all of you be healthy.

 do you know ...what is the acronym of qw that
i believe quote word
 use in Object-Oriented ??
 thx.
 
   Best regards. Nafiseh Saberi
www.iraninfocenter.net
  www.sorna.net
 Beaty is in the eye of the beholder.
  _


-- 
  - josh
N8MSO

20A8 2FC6 9099 D215 78F4 D005 B9F3 21C4 300C C25E~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - [EMAIL PROTECTED] - tel: +972.58.520.636, http://www.tkos.co.il


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: acronym of qw

2001-12-05 Thread [EMAIL PROTECTED]

On Wed, 5 Dec 2001, nafiseh saberi wrote:

 Date: Wed, 5 Dec 2001 12:00:17 +0330
 From: nafiseh saberi [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: acronym of qw

 hi dear team...
 I wish all of you be healthy.

 do you know ...what is the acronym of qw that
 use in Object-Oriented ??
its not only for use with object oriented code, use it in arrays and
hashes too

 thx.
 
   Best regards. Nafiseh Saberi
www.iraninfocenter.net
  www.sorna.net
 Beaty is in the eye of the beholder.
  _


-- 
  - josh
N8MSO

20A8 2FC6 9099 D215 78F4 D005 B9F3 21C4 300C C25E~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - [EMAIL PROTECTED] - tel: +972.58.520.636, http://www.tkos.co.il


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: acronym of qw

2001-12-05 Thread Peter Scott

At 12:00 PM 12/5/01 +0330, nafiseh saberi wrote:
do you know ...what is the acronym of qw that
use in Object-Oriented ??

It stands for quote words.

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Need some clarification of rules for qw()

2001-10-04 Thread Gary L. Armstrong

I have written this:

system qw( /usr/lib/lpd/pio/etc/piomisc_ext mkpq_remote_ext -q $qname
-h $newhost.$domain.ko.com -r jfsrvrsap -t bsd -d $qname
Jetforms NT Server TEMPORARY );

Nevermind what I am doing (adding a remote print queue), I am mainly
interested in using the qw() properly.  It splits on whitespace, so I
figure that this will do exactly what I want, but I am not sure if it will
split on the whitespace inside the double-quotes.  Will double-quotes
suffice to keep that string intact?

I could just type out a big list using , to separate, but where's the fun
in that?

Thanks,
-=GLA=-


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Need some clarification of rules for qw()

2001-10-04 Thread Ask Bjoern Hansen

On Thu, 4 Oct 2001, Gary L. Armstrong wrote:

 system qw( /usr/lib/lpd/pio/etc/piomisc_ext mkpq_remote_ext -q $qname
 -h $newhost.$domain.ko.com -r jfsrvrsap -t bsd -d $qname
 Jetforms NT Server TEMPORARY );
 
 Nevermind what I am doing (adding a remote print queue), I am mainly
 interested in using the qw() properly.  It splits on whitespace, so I
 figure that this will do exactly what I want, but I am not sure if it will
 split on the whitespace inside the double-quotes.  Will double-quotes
 suffice to keep that string intact?

Try doing something like 

my @a = qw( ... );
print join \n, @a, ;

then you can see what happens. 

You wil also see that $variables doesn't get interpolated in
qw().  :)

system (qw( /usr/lib/lpd/pio/etc/piomisc_ext mkpq_remote_ext -q),
$queue, '-h', $newhost.$domain.ko.com, qw(-r jfsrvrsap -t bsd 
-d), $qname, Jetforms NT Server TEMPORARY); 

would work, but then it's a bit messy. =)

Remember that = can be used instead of a , here, so you could also
do something like,

system ('/usr/lib/lpd/pio/etc/piomisc_ext',  
'mkpq_remote_ext',
'-q' = $queue, 
'-h' = $newhost.$domain.ko.com,
...
   );


 - ask

-- 
ask bjoern hansen, http://ask.netcetera.dk/   !try; do();



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Need some clarification of rules for qw()

2001-10-04 Thread Curtis Poe

--- Gary L. Armstrong [EMAIL PROTECTED] wrote:
 I have written this:
 
 system qw( /usr/lib/lpd/pio/etc/piomisc_ext mkpq_remote_ext -q $qname
 -h $newhost.$domain.ko.com -r jfsrvrsap -t bsd -d $qname
 Jetforms NT Server TEMPORARY );
 
 Nevermind what I am doing (adding a remote print queue), I am mainly
 interested in using the qw() properly.  It splits on whitespace, so I
 figure that this will do exactly what I want, but I am not sure if it will
 split on the whitespace inside the double-quotes.  Will double-quotes
 suffice to keep that string intact?
 
 I could just type out a big list using , to separate, but where's the fun
 in that?

Sorry, no white space allowed.  Further, using the 'qw()' construct does *not* allow 
for
interpolation.  Unless you want a literal '$qname' in their, you'll need an array.

From Quote and Quote-Like Operators (perldoc perlop):

Customary  GenericMeaningInterpolates
''   q{}  Literal no
  qq{}  Literal yes
``  qx{}  Command yes (unless '' is delimiter)
-- qw{} Word listno
//   m{}   Pattern match  yes (unless '' is delimiter)
qr{}  Pattern yes (unless '' is delimiter)
 s{}{}  Substitution  yes (unless '' is delimiter)
tr{}{}Transliteration no (but see below)


Cheers,
Curtis Ovid Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
Ovid on http://www.perlmonks.org/

__
Do You Yahoo!?
NEW from Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Need some clarification of rules for qw()

2001-10-04 Thread Gary L. Armstrong

First off, I really like Ask's response, that was the sort of thing I
needed: food for thought.

And Curtis, I knew I had seen that chart somewhere but this late in the
afternoon I must be tired. I do want those interpolated, so tomorrow I'll
play around with it and see what I can come up with. An array, you say? I'm
not yet used to the way these variables act like infinitely-expandable
containers: I keep thinking I'm going to break something if I just dump a
load of output into a variable. I'll grow out of it, I hope.

This is my first serious Perl program, and even just starting out I can tell
I'll be writing far fewer ksh scripts from now on. Good job, Larry 
friends.

-=GLA=-

--- Gary L. Armstrong [EMAIL PROTECTED] wrote:
 I have written this:

 system qw( /usr/lib/lpd/pio/etc/piomisc_ext mkpq_remote_ext -q $qname
 -h $newhost.$domain.ko.com -r jfsrvrsap -t bsd -d $qname
 Jetforms NT Server TEMPORARY );

 Nevermind what I am doing (adding a remote print queue), I am mainly
 interested in using the qw() properly.  It splits on whitespace, so I
 figure that this will do exactly what I want, but I am not sure if it will
 split on the whitespace inside the double-quotes.  Will double-quotes
 suffice to keep that string intact?

 I could just type out a big list using , to separate, but where's the
fun
 in that?

Sorry, no white space allowed.  Further, using the 'qw()' construct does
*not* allow for
interpolation.  Unless you want a literal '$qname' in their, you'll need an
array.

From Quote and Quote-Like Operators (perldoc perlop):

Customary  GenericMeaningInterpolates
''   q{}  Literal no
  qq{}  Literal yes
``  qx{}  Command yes (unless '' is
delimiter)
-- qw{} Word listno
//   m{}   Pattern match  yes (unless '' is
delimiter)
qr{}  Pattern yes (unless '' is
delimiter)
 s{}{}  Substitution  yes (unless '' is
delimiter)
tr{}{}Transliteration no (but see below)


Cheers,
Curtis Ovid Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
Ovid on http://www.perlmonks.org/

__
Do You Yahoo!?
NEW from Yahoo! GeoCities - quick and easy web site hosting, just
$8.95/month.
http://geocities.yahoo.com/ps/info1

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




qw

2001-05-30 Thread Nichole Bialczyk

i'm trying to work my way throuh an existing script and it says

@array = qw(stuff, more stuff, even more stuff);

what does the qw do?

thanks, nichole



RE: qw

2001-05-30 Thread Jeffrey Goff

It's a shortcut for assigning words to an array. That statement would return
an array that looks roughly like this:

('stuff,', 'more stuff,', 'even more stuff') # Note the double quotes.

Something like (stuff,more stuff,even more stuff); # was likely
intended, without qw().

Search for 'qw/STRING/' in perlop perldoc for more information.

-Original Message-
From: Nichole Bialczyk [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 30, 2001 4:39 PM
To: [EMAIL PROTECTED]
Subject: qw


i'm trying to work my way throuh an existing script and it says

@array = qw(stuff, more stuff, even more stuff);

what does the qw do?

thanks, nichole



RE: qw

2001-05-30 Thread Larry Shatzer

Here is the documentation on it. 
( http://www.perldoc.com/perl5.6/pod/perlop.html#qw%2fSTRING%2f )

qw/STRING/ 
Evaluates to a list of the words extracted out of STRING, using embedded
whitespace as the word delimiters. It can be understood as being roughly
equivalent to:

split(' ', q/STRING/);
the difference being that it generates a real list at compile time. So this
expression:

qw(foo bar baz)
is semantically equivalent to the list:

'foo', 'bar', 'baz'
Some frequently seen examples:

use POSIX qw( setlocale localeconv )
@EXPORT = qw( foo bar baz );
A common mistake is to try to separate the words with comma or to put
comments into a multi-line qw-string. For this reason, the use warnings
pragma and the -w switch (that is, the $^W variable) produces warnings if
the STRING contains the , or the # character.


 -Original Message-
 From: Nichole Bialczyk [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, May 30, 2001 1:39 PM
 To: [EMAIL PROTECTED]
 Subject: qw
 
 
 i'm trying to work my way throuh an existing script and it says
 
 @array = qw(stuff, more stuff, even more stuff);
 
 what does the qw do?
 
 thanks, nichole
 



Re: qw

2001-05-30 Thread Michael Fowler

On Wed, May 30, 2001 at 03:38:35PM -0500, Nichole Bialczyk wrote:
 i'm trying to work my way throuh an existing script and it says
 
 @array = qw(stuff, more stuff, even more stuff);
 
 what does the qw do?

perldoc perlop:
   qw/STRING/
   Returns a list of the words extracted out of
   STRING, using embedded whitespace as the word
   delimiters.  It is exactly equivalent to

   split(' ', q/STRING/);


In this case, qw is being misused.  The code there is equivalent to:

$array[0] = 'stuff,'  ;
$array[1] = 'more' ;
$array[2] = 'stuff,'   ;
$array[3] = 'even' ;
$array[4] = 'more'  ;
$array[5] = 'stuff';

What was probably intended is the equivalent of:

$array[0] = stuff  ;
$array[1] = more stuff ;
$array[2] = even more stuff;

In which case the qw should just be dropped, the quoting is sufficient.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--



RE: qw

2001-05-30 Thread Jeff Pinyan

On May 30, Jeffrey  Goff said:

It's a shortcut for assigning words to an array. That statement would return
an array that looks roughly like this:

('stuff,', 'more stuff,', 'even more stuff') # Note the double quotes.

Nope, no matter what you do, qw() really splits on whitespace.

  friday:~ $ perl -w
  @a = qw( stuff, more stuff, even more stuff );
  Possible attempt to separate words with commas at - line 1. -- warning
  for (@a) { print $_\n }
  __END__

  stuff,
  more
  stuff,
  even
  more
  stuff

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**I no longer need a publisher for my Perl Regex book :)**




RE: qw

2001-05-30 Thread Jeffrey Goff

Yep,caught that myself a few minutes -after- sending email. Apologies.

-Original Message-
From: Jeff Pinyan [mailto:[EMAIL PROTECTED]]
On May 30, Jeffrey  Goff said:

It's a shortcut for assigning words to an array. That statement would
return
an array that looks roughly like this:

('stuff,', 'more stuff,', 'even more stuff') # Note the double
quotes.

Nope, no matter what you do, qw() really splits on whitespace.



Re: qw

2001-05-30 Thread Walt Mankowski

On Wed, May 30, 2001 at 03:38:35PM -0500, Nichole Bialczyk wrote:
 i'm trying to work my way throuh an existing script and it says
 
 @array = qw(stuff, more stuff, even more stuff);
 
 what does the qw do?

In your example, it's a broken way of trying to say:

$array[0] = stuff;
$array[1] = more stuff;
$array[2] = even more stuff;

I say broken because qw splits on whitespace, so what you really get
here is:

$array[0] = 'stuff;'
$array[1] = 'more';
$array[2] = 'stuff;'
$array[3] = 'even';
$array[4] = 'more';
$array[5] = 'stuff;';

qw is a shorthand way of initializing an array with individual words,
because it saves you the trouble of having to type all the quotes and
commas.  For example,

@array = qw(stuff more stuff even more stuff);

gives you

$array[0] = stuff;
$array[1] = more;
$array[2] = stuff;
$array[3] = even;
$array[4] = more;
$array[5] = stuff;

But if you need to initialize the array with strings that have
embedded whitespace, then you've got to do it the long way with all
the quotes and commas.  In your example, all you have to do is drop
the qw:

@array = (stuff, more stuff, even more stuff);

Walt

-- 
Walter C. Mankowski
Senior Software EngineerMyxa Corporation
phone: (610) 234-2626   fax: (610) 234-2640
email: [EMAIL PROTECTED]http://www.myxa.com




Re: qw

2001-05-30 Thread Paul


--- Nichole Bialczyk [EMAIL PROTECTED] wrote:
 i'm trying to work my way throuh an existing script and it says
 @array = qw(stuff, more stuff, even more stuff);

That looks like a typo, though they may have actually wanted the quotes
and commas in the strings if you run that under -w, it'll complain.

By the way, have we mentioned that you should always use strict.pm and
the -w switch? =o) lol
 
 what does the qw do?

qw is the Quote-Word operator for perl. c.f. perldoc perlop

qw takes a list of whitespace-delimited strings and quotes them as if
they were each in singleticks. For example:

  @array = qw / a b c d e /;

creates an array of the alphabet's first 5 letters.
The slash isn't magical here; it's just one possible bounding
character. You can use matching pairs () {}  [] or other things like
/ if those aren't convenient. 

So, to paraphrase the above,
 @array = qw( stuff moreStuff evenMoreStuff );

makes an array of those three elements, but the literal value above
would yield:
  stuff,
  more
  stuff,
  even
  more
  stuff

Notice that the quotes and commas are part of the strings, and that
even more stuff got split into three seperate elements of the array.

Does that help?
Is that the actual code you're looking at?
If not, post it, and let's take it apart! lol



__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/