I've finally got it. As suggested, I want back to declare my variables
with my only within the scope where they're needed.
Out of all those regex examples, I came out with one that solved my
problem with ease. But I find the use of hash (suggested by Joseph)
would have been better.
Thanks to
thanks for help owen and Randy,
Sorry it took so lang for responding and thanking you but I was on a
long vacation
I just want to say that I have made a mistake in the question,
It doesn't have to sorted by item 5 but needs to look for everything
that contains item 5
and than be sorted by item
Chris McMahon wrote:
This script:
***
use warnings;
use Win32:ODBC;
my $db = new Win32::ODBC(TheDB);
$db-Sql(SELECT * FROM dbo.foo);
$db-FetchRow();
my @values = $db-Data;
print @values;
*
Yields two Use of
Rajesh Dorairajan wrote:
I've had this problem for a long time and I am in a sort of a dead-end and
could use some help. When I make a get request using the LWP UserAgent
inside a function and I pass a URL to the function as a string I get a
response. However, when I pass a variable that
Is there any separate reason to use 'expect' Perl will happily
talk telnet and ftp on its own.
Rob
well- namely that it works- i honestly don't know /how/ to get perl
to talk telnet *laugh* i guess the proper module would help.
i will investigate this possibility and see what happens :)
off
If I was using one specific group of commands, Could I put them inside a
variable, then just use the variable when I needed the commands instead of
copying and pasting them?
i.e.
print Hello world;
if ($i == 50) {
goto MAIN;
}
elsif ($t == 100) {
goto SECONDARY;
}
as compared to
Joel wrote:
If I was using one specific group of commands, Could I put them inside a
variable, then just use the variable when I needed the commands instead of
copying and pasting them?
i.e.
print Hello world;
if ($i == 50) {
goto MAIN;
}
elsif ($t == 100) {
goto SECONDARY;
William M West wrote:
Is there any separate reason to use 'expect'? Perl will happily
talk telnet and ftp on its own.
Rob
well- namely that it works- i honestly don't know /how/ to get perl
to talk telnet *laugh* i guess the proper module would help.
i will investigate this
Joel wrote:
If I was using one specific group of commands, Could I put them inside a
variable, then just use the variable when I needed the commands instead of
copying and pasting them?
Yes. You could do that. It would be a step backward, though. Variables are
for storing data or
For instance:
sub launch_viewer {
my $for_path = shift;
$message_viewer = create_main_viewer_window();
add_main_menu($message_viewer);
add_header_list($message_viewer, $for_path);
add_message_area($message_viewer);
print get_viewer_option('Files|References'), \n;
Great job, Rob! Thanks for the good code! Quite a timesaver.
Scott
Scott E. Robinson
SWAT Team
Data Mgt Practices Operations (DMPO)
RR-690 -- 281-654-5169
EMB-2813N -- 713-656-3629
Safety is never an accident
- Forwarded by Scott E Robinson/U-Houston/ExxonMobil on 02/19/04 09:29
AM
Hello,
I had a simple array in mind, but as i got reacquainted with PERL, with the
help of the list, i realized i was thinking to small. (that's always
dangerous)
Anyway. I have an array/hash(still learning the technical differences)
similar to
(pardon syntax irregularities, just trying
Scott E Robinson wrote:
Great job, Rob! Thanks for the good code! Quite a timesaver.
K Gupta A wrote:
wow Rob, thaz a masterpiece code!!
3 cheers for you!!
Thanks guys, but I expected a few questions from that post.
Please be sure you /understand/ as much as possible before
you use it.
West, William M wrote:
Is there any separate reason to use 'expect' Perl will happily
talk telnet and ftp on its own.
expect.nist.gov expect ???
A fine, if under valued, development system.
well- namely that it works- i honestly don't know /how/ to get perl
to talk telnet *laugh* i guess the
Hi Jeffrey.
There are several questions here, so I've answered in-line.
Jeffrey N Dyke wrote:
I had a simple array in mind, but as i got reacquainted with PERL, with the
help of the list, i realized i was thinking to small. (that's always
dangerous)
On the contrary, I think thinking BIG is
Thanks for the feedback--maybe I screwed up but what happens for me is that
the ordered array (1) only lists the keys, not the array values the hash key
points to and (2) I still don't get an ordered list of the keys that are put
in the ordered array--it comes out un-ordered.
I took your line
Smith Jeff D wrote:
Thanks for the feedback--maybe I screwed up but what happens for me is that
the ordered array (1) only lists the keys, not the array values the hash key
points to and (2) I still don't get an ordered list of the keys that are put
in the ordered array--it comes out un-ordered.
R. Joseph Newton wrote:
i.e.
print Hello world;
if ($i == 50) {
goto MAIN;
Don't do this. For some perverse reason, goto was included in the Perl
language. This may have been to support legacy programs. No new code should
ever be written with such structures. They have been
On Feb 19, 2004, at 10:25 AM, Smith Jeff D wrote:
Thanks for the feedback--maybe I screwed up but what happens for me is
that
the ordered array (1) only lists the keys, not the array values the
hash key
points to and (2) I still don't get an ordered list of the keys that
are put
in the ordered
%HofA = (orange=['ZZZ', 'ANDY'],
red=['AAA', 'AL'],
blue=['mmm','Betty'],
yellow=['aaa', 'ZEUS'],
green=['DDD','Mary Joe'],
violet=['MMM','Hugo']
);
my @ordered_keys = sort { $HofA{$a}[0] cmp $HofA{$b}[1]
||
$a
Jeff Smith wrote:
Thanks for the feedback--maybe I screwed up but what happens for me is that
the ordered array (1) only lists the keys, not the array values the hash key
points to and (2) I still don't get an ordered list of the keys that are put
in the ordered array--it comes out
Hello...
I'm leaving aside the NULL issue for the moment...
Today's project is to get a complete list of column names for each
table in the database, and the value for the first record (row) in each
table. This code does the right thing for 15 tables and then hangs and
quits
I really need to order both the keys and one of the elements in the array
stored as a value in the hash, preferably sort first on the first element of
the array (my real application has four elements but the snippet I'm testing
with has a two-element array) and then sort secondly on the key.
So
Rajesh Dorairajan wrote:
Sorry the syntax error was by mistake. It's not in the actual code.
next time when you post please do not retype your script. try copy and paste
the whole script over so you can avoid typo.
please do not top post. when you reply to any message, post your respond
Smith Jeff D wrote:
I really need to order both the keys and one of the elements in the array
stored as a value in the hash, preferably sort first on the first element of
the array (my real application has four elements but the snippet I'm testing
with has a two-element array) and then sort
Jeff Smith wrote:
I really need to order both the keys and one of the elements in the array
stored as a value in the hash, preferably sort first on the first element of
the array (my real application has four elements but the snippet I'm testing
with has a two-element array) and then sort
Papo Napolitano wrote:
On Feb 18, 2004, at 4:45 PM, Papo Napolitano wrote:
Heh, sorry... I simplified the code...
I'm still not posting the full source because it's like 15 files :(
while (1) {
Fork(Whatever);
sleep 60;
}
The first time you showed this loop, it had
Yes, BASIC is the only programming I have ever done. All I can really
remember was PRINT, GOTO, and a variety of line numbers. I'm trying to write
a text adventure (Don't look at me like that, Perl is a general purpose
language!). I'm getting tired of writing large chunks of code that I reuse
the
Hi Jeffrey.
There are several questions here, so I've answered in-line.
Rob, thanks a ton. that worked perfectly, as has the rest of the
processing of the larger hash. Thought i'd address the build portion
below, to see if i'm not utilizing PERL's strengths correctly. First PERL
i've
--As of Thursday, February 19, 2004 2:22 PM -0500, Joel is alleged to have
said:
Yes, BASIC is the only programming I have ever done. All I can really
remember was PRINT, GOTO, and a variety of line numbers. I'm trying to
write a text adventure (Don't look at me like that, Perl is a general
On Feb 19, 2004, at 1:22 PM, Joel wrote:
Yes, BASIC is the only programming I have ever done. All I can really
remember was PRINT, GOTO, and a variety of line numbers.
Most of us were there at some point. We just don't talk about it much.
:D
I'm trying to write a text adventure (Don't look at
On Feb 19, 2004, at 1:25 PM, [EMAIL PROTECTED] wrote:
Thought i'd address the build portion below, to see if i'm not
utilizing PERL's strengths correctly. First PERL i've written in 3+
years.
Perl. The language you are relearning is called Perl, not PERL. ;)
James
--
To unsubscribe,
Still new to perl... trying to create an FTP connection to move backups
from one machine to another.
Code...
#!/usr/bin/perl
# Backup tyr web directory
# to ODIN via FTP
# Begin remote transfer of file(s) #
use Net::FTP;
$ftp = Net::FTP-new(hostname, Debug = 1)
or die Could establish conneciton
Still new to using Perl, any help with this is appreciated.
Code...
#!/usr/bin/perl
# Backup 192.168.0.1 web directory
# to 192.168.0.2 via FTP
# Begin remote transfer of file to ODIN for storage #
use Net::FTP;
$ftp = Net::FTP-new(192.168.0.2, Debug = 1)
or die Could establish conneciton to
I'll post the code tommorow. I just need to change all the room descriptions
and items, since the the characters and places depicted in the game are
copyrighted. I wrote it as a fan work.
Joel
- Original Message -
From: James Edward Gray II [EMAIL PROTECTED]
To: Joel [EMAIL PROTECTED]
new to perl...
I am recieving errors when trying open an FTP connection.
Code...
#!/usr/bin/perl
# Backup 192.168.0.2 web directory
# to 192.168.0.3 via FTP
# Begin remote transfer of file to 192.168.0.3 for storage #
use Net::FTP;
$ftp = Net::FTP-new(192.168.0.3, Debug = 1)
or die Could
Joel wrote:
I'll post the code tommorow. I just need to change all the room descriptions
and items, since the the characters and places depicted in the game are
copyrighted. I wrote it as a fan work.
You'll find lots of support here Joel. I fondly remember playing
Dungeon on a 12-bit PDP8.
Joel wrote:
Yes, BASIC is the only programming I have ever done. All I can really
remember was PRINT, GOTO, and a variety of line numbers. I'm trying
to write a text adventure (Don't look at me like that, Perl is a
general purpose language!). I'm getting tired of writing large chunks
of code
On Feb 19, 2004, at 10:48 AM, Smith Jeff D wrote:
I really need to order both the keys and one of the elements in the
array
stored as a value in the hash, preferably sort first on the first
element of
the array (my real application has four elements but the snippet I'm
testing
with has a
Hi Rob,
I implemented your code and it gave perfectly desired answers. But I couldn't
understand most of it. So, currently I went ahead with Dan's tips on my code only and
would try to understand your code later after I meet a deadline for a small project of
mine in college for tomorrow! So, no
Hi Jas.
Jas wrote:
Still new to using Perl, any help with this is appreciated.
Code...
#!/usr/bin/perl
# Backup 192.168.0.1 web directory
# to 192.168.0.2 via FTP
# Begin remote transfer of file to ODIN for storage #
use Net::FTP;
$ftp = Net::FTP-new(192.168.0.2, Debug = 1)
or die
I thought I could solve the regex issue a different way, but failed.
My $path = Mazda.1.jpg ;
($file, $dir, $ext) = fileparse ($path, '\..*' );
#I'm trying to get Mazda.2.jpg and Mazda.3.jpg.
# $file contains Mazda, so why does this regex fail to deliver
Mazda.2.jpg
# and Mazda.3.jp?
my
More error diagnosis below:
Hello...
I'm leaving aside the NULL issue for the moment...
Today's project is to get a complete list of column
names for each
table in the database, and the value for the first record
(row) in each
table. This code does the right thing for
Hi Jas.
Jas wrote:
[snip]
$ftp-put(`../path/to/*-www.tar.gz`)
or die Could not transfer files , $ftp-message;
.. backticks in two statements!
$ftp-quit;
Error...
Net::FTP Net::FTP(2.71)
Net::FTP Exporter(5.566)
Net::FTP Net::Cmd(2.24)
Net::FTP
Hi Jas.
Jas wrote:
[snip]
$ftp-put(`../path/to/*-www.tar.gz`)
or die Could not transfer files , $ftp-message;
.. backticks in two statements!
$ftp-quit;
Error...
Net::FTP Net::FTP(2.71)
Net::FTP Exporter(5.566)
Net::FTP Net::Cmd(2.24)
Net::FTP
Hi
Could anyone please tell me what's wrong with the following program?
The compiler gives errors in the switch statement.
Thx!!
Anthony
%commands=('v',0,'w',1,'t',2,'/pattern/',3,'s',4,'x',5);
$end = 0;
while (!end){
print bookmarks.html;
$operation = ;
chop $operation;
--As of Thursday, February 19, 2004 10:14 PM +0100, Anthony Vanelverdinghe
is alleged to have said:
Could anyone please tell me what's wrong with the following program?
The compiler gives errors in the switch statement.
--As for the rest, it is mine.
You mean, besides the fact that Perl doesn't
At 10:53 AM 2/19/04 -0700, you wrote:
Still new to perl... trying to create an FTP connection to move backups
from one machine to another.
Code...
#!/usr/bin/perl
# Backup tyr web directory
# to ODIN via FTP
# Begin remote transfer of file(s) #
use Net::FTP;
$ftp = Net::FTP-new(hostname, Debug =
Didn't know it wasn't in Perl, but I've just discovered it's possible with
some file called Switch.pm
From: Daniel Staal [EMAIL PROTECTED]
Reply-To: Perl Beginners [EMAIL PROTECTED]
To: Perl Beginners [EMAIL PROTECTED]
Subject: Re: switch statement
Date: Thu, 19 Feb 2004 16:21:22 -0500
--As of
On Feb 19, 2004, at 3:14 PM, Anthony Vanelverdinghe wrote:
Hi
Howdy.
Could anyone please tell me what's wrong with the following program?
I'll try.
The compiler gives errors in the switch statement.
Perl doesn't have a native switch statement, but it is included as a
module in 5.8+
Thx!!
--As of Thursday, February 19, 2004 10:29 PM +0100, Anthony Vanelverdinghe
is alleged to have said:
Didn't know it wasn't in Perl, but I've just discovered it's possible
with some file called Switch.pm
--As for the rest, it is mine.
You mean the 'Switch' module. (Sorry, I should have mentioned
On Feb 19, 2004, at 3:20 PM, Smith Jeff D wrote:
Thanks, I must have missed it--I'll be getting back to it tomorrow
morning
to see what I missed in the original response. I thought I had run as
printed below.
No worries. You probably did run my original response, which was
flawed. Mark gave
Thanks, I must have missed it--I'll be getting back to it tomorrow morning
to see what I missed in the original response. I thought I had run as
printed below.
Anyway, thank for the help...I think I may have braced when I should have
paren'd... It so simple when someone else does it first I
The Advantage is you get to use the switch statement. The disadvantage is
your code will run extraordinarily slow because the Switch module uses a run time
Filter. In short: isn't an is-elsif-else statement enough??
In a message dated 2/19/2004 4:40:56 PM Eastern Standard Time, [EMAIL
In addition, I've been playing around with the 'use diagnostics' feature in perl.
That's in addition to 'use warnings'. I don't recommend it for regular coding but
when stumped it may help.
On Feb 19, 2004, at 3:14 PM, Anthony Vanelverdinghe wrote:
Hi
Howdy.
Could anyone please
From: McMahon, Chris [EMAIL PROTECTED]
Hello...
This script:
***
use warnings;
use Win32:ODBC;
my $db = new Win32::ODBC(TheDB);
$db-Sql(SELECT * FROM dbo.foo);
$db-FetchRow();
my @values = $db-Data;
print @values;
Wiggins D Anconia wrote:
Rob wrote:
The backticks are your problem: they will make Perl shell out to execute
the string as a command. The 'sh: line1:' in your error message is the
clue. Presumably you don't have execute permission for
'../path/to/02192004-www.tar.gz'?
Try this and
[EMAIL PROTECTED] wrote:
The Advantage is you get to use the switch statement. The disadvantage is
your code will run extraordinarily slow because the Switch module uses a run time
Filter. In short: isn't an is-elsif-else statement enough??
Are you saying that 'if-elsif-else' is a
James Edward Gray II wrote:
The Moral: Don't use the original message. Use this one.
Far more reliable is: Don't do what I say, do what I mean. :)
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
This:
if ($op == 0) {}
elsif ($op == 1) {}
elsif ($op == 2) {}
elsif ($op == 3) {}
elsif ($op == 4) {}
elsif ($op == 5) {}
is faster than this:
use Switch;
switch ($op) {
case 0 { last }
case 1 { last }
case 2 { last }
case 3 { last }
case 4 { last }
case 5 { last }
}
Papo Napolitano wrote:
On Feb 18, 2004, at 4:45 PM, Papo Napolitano wrote:
Heh, sorry... I simplified the code...
I'm still not posting the full source because it's like 15 files :(
while (1) {
Fork(Whatever);
sleep 60;
}
The first time you showed this loop,
On Thu, Feb 19, 2004 at 10:46:33PM -, Rob Dixon wrote:
[EMAIL PROTECTED] wrote:
The Advantage is you get to use the switch statement. The disadvantage is
your code will run extraordinarily slow because the Switch module uses a run time
Filter. In short: isn't an is-elsif-else
Here it is. Okay so it isn't tommorow. I shortened it a bit, but its the
same really.
Joel
- Original Message -
From: James Edward Gray II [EMAIL PROTECTED]
To: Joel [EMAIL PROTECTED]
Sent: Thursday, February 19, 2004 3:06 PM
Subject: Re: Could I put commands in a variable
(off list
On Feb 19, 2004, at 5:21 PM, Paul Johnson wrote:
The problem is that Switch.pm is a source filter, which is effectively
an extra level of processing before compilation.
Personally, I wouldn't use a source filter for anything I cared about.
The docs for Switch state:
There are undoubtedly
I'm trying to help out another developer with a mini-Perl script.
He has a file that contains one very long line, about 28M in size.
He needs to do a replacement of all occurances of
|^NEWLINE^|^
to a literal newline (HPUX, 0x0a or \n).
When I ran this
$ perl -ne
Rob Dixon wrote:
[EMAIL PROTECTED] wrote:
The Advantage is you get to use the switch statement. The disadvantage is
your code will run extraordinarily slow because the Switch module uses a
run time Filter. In short: isn't an is-elsif-else statement enough??
Are you saying that
Jeff Westman wrote:
I'm trying to help out another developer with a mini-Perl script.
He has a file that contains one very long line, about 28M in size.
He needs to do a replacement of all occurances of
|^NEWLINE^|^
to a literal newline (HPUX, 0x0a or \n).
When I ran this
$
Anthony Vanelverdinghe wrote:
Hi
Hello,
Could anyone please tell me what's wrong with the following program?
The compiler gives errors in the switch statement.
%commands=('v',0,'w',1,'t',2,'/pattern/',3,'s',4,'x',5);
$end = 0;
while (!end){
print bookmarks.html;
$operation = ;
chop
On Thu, Feb 19, 2004 at 04:36:55PM -0800, david wrote:
Jeff Westman wrote:
I'm trying to help out another developer with a mini-Perl script.
He has a file that contains one very long line, about 28M in size.
He needs to do a replacement of all occurances of
|^NEWLINE^|^
to a
I am attempting to install the module Digest::MD5 and it fails with the
makefile for the module. The error reported is *** missing separator.
Stop. This is on a Red Hat WS 3 box with all the latest updates
installed that includes perl 5.8. I thought Red Hat 7.3 had this same
problem caused by
Paul Johnson wrote:
[panda]# perl -ne 'BEGIN{$/=\10} s/\|\^NEWLINE\^\|\^/\n/g; print'
[loadFile
The trouble with this approach is that you will miss any separators
which are split. Your example actually reads 10 bytes at a time, but
using $/ is the right idea:
perl -ple 'BEGIN {
Paul Johnson [EMAIL PROTECTED] wrote:
On Thu, Feb 19, 2004 at 04:36:55PM -0800, david wrote:
Jeff Westman wrote:
I'm trying to help out another developer with a mini-Perl
script.
He has a file that contains one very long line, about 28M in
size.
He needs to do a replacement of
Jeff Westman wrote:
When I ran this
$ perl -ne 's/|^NEWLINE^|^/\n/g;print' loadFile
The program loads the ENTIRE loadfile and then splits characters at
whitespace between characters and then prints every character followed
by a newline.
So, how big is loadfile?
Rob Dixon wrote:
James Edward Gray II wrote:
The Moral: Don't use the original message. Use this one.
Far more reliable is: Don't do what I say, do what I mean. :)
After all, Perl is a DWIM language. :-)
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL
I just benchmarked Filter, and it was worse than 100 times slower
In a message dated 2/19/2004 6:53:56 PM Eastern Standard Time,
[EMAIL PROTECTED] writes:
last time i benchmark a source filter, it's about 100 times slower. has that
change since v5.8?
-Will
WC -Sx- Jones [EMAIL PROTECTED]
wrote:
Jeff Westman wrote:
When I ran this
$ perl -ne 's/|^NEWLINE^|^/\n/g;print' loadFile
The program loads the ENTIRE loadfile and then splits characters
at
whitespace between characters and then prints every character
followed
by a
--As of Thursday, February 19, 2004 6:31 PM -0500, Joel is alleged to have
said:
Here it is. Okay so it isn't tommorow. I shortened it a bit, but its the
same really.
--As for the rest, it is mine.
Here's a first approximation of a rewrite. ;-) (Major problem: it always
asks what you want to
Rob Dixon wrote:
IMO that's a bit strong. 'goto' will always have its place until
language authors can predict all possible flows of control that
could be wanted by a programmer. Perl is richer than most in that
it has implicit gotos last, next, redo, return and die, but it
still has no try
On Feb 19, 2004, at 9:22 PM, R. Joseph Newton wrote:
I don't know, Rob. I would be interested in hearing of any real-world
problem that
would demand this.
I believe the text book example is a language that lacks support for
something like Java's finally block. A goto can guarantee you get to
is $self a special scalar?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response
No. $self you'll usually see in a lot of Object Oriented applications. When a
subroutine is called using the - operator ($mw = MainWindow-new, for
example) the first arguement passed to that subroutine is the name of the
package/class. So, $self is usually used to display this. So, a common
No, but it's a cool convention
From: Jacob Chapa [EMAIL PROTECTED]
To: Perl Beginners [EMAIL PROTECTED]
Subject: $self
Date: Thu, 19 Feb 2004 22:23:14 -0600
is $self a special scalar?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Dan Muey wrote:
For instance:
sub launch_viewer {
my $for_path = shift;
$message_viewer = create_main_viewer_window();
[snip pretty code IMHO]
create_view_menu();
create_find_menu();
}
Nice Joseph,
If I'm looking at this right this is a GUI for viewing files?
what does bless do?
-jake
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response
Hello...
I'm leaving aside the NULL issue for the moment...
Is that wise ? :-)
Today's project is to get a complete list of column
names for each
table in the database, and the value for the first record
(row) in each
table. This code does the right thing for 15 tables
Scott E Robinson wrote:
Great job, Rob! Thanks for the good code! Quite a timesaver.
K Gupta A wrote:
wow Rob, thaz a masterpiece code!!
3 cheers for you!!
Thanks guys, but I expected a few questions from that post.
Please be sure you /understand/ as much as possible before
86 matches
Mail list logo