Hi,
I'm learning Perl with excellent Learning Perl from O'Reilly.
One of the examples given doesn't work on my computer though and I really can't
figure out why.
Here's the script :
#/usr/bin/perl -w
open(PW,/etc/passwd) || die How did you get logged in?;
while (PW) {
I'm looking for a command which permit to reach an URL from the script.
tks
PS: sorry for my english :-)
Hi,
I want to strip a variable of all characters including a token, i.e.
aaa_bbb_ccc_ddd would become bbb_ccc_ddd. As you can see I want to get rid of
aaa_. Does anyone know how to acomplish this in Perl?
I've tried:
$tmp = aaa_bbb_ccc_ddd
$tmp =~ /^\w+_/
$tmp = $';
but that results in $tmp eq
try this :
$tmp =~ tr/a/ /;
Johan Groth wrote:
Hi,
I want to strip a variable of all characters including a token, i.e.
aaa_bbb_ccc_ddd would become bbb_ccc_ddd. As you can see I want to get rid of
aaa_. Does anyone know how to acomplish this in Perl?
I've tried:
$tmp =
Andrew Teo wrote:
try this :
$tmp =~ tr/a/ /;
I see I need to be a bit more specific. The above would change the a's to spc
but what I want is to strip the string of all characters up to and including
the first underscore. Ie aaa_bbb_ccc would become bbb_ccc and
sometext_more_text would
On Mon, 7 May 2001, Johan Groth wrote:
Hi,
I want to strip a variable of all characters including a token, i.e.
aaa_bbb_ccc_ddd would become bbb_ccc_ddd. As you can see I want to get rid of
aaa_. Does anyone know how to acomplish this in Perl?
I've tried:
$tmp = aaa_bbb_ccc_ddd
$tmp =~
On Mon, 7 May 2001, Johan Groth wrote:
I want to strip a variable of all characters including a token, i.e.
aaa_bbb_ccc_ddd would become bbb_ccc_ddd. As you can see I want to get rid of
aaa_. Does anyone know how to acomplish this in Perl?
I've tried:
$tmp = aaa_bbb_ccc_ddd
$tmp =~
On Mon, 7 May 2001, Stéphane JEAN BAPTISTE wrote:
I'm looking for a command which permit to reach an URL from the script.
use LWP::Simple;
my $url = 'http://some.domain.com';
my $page = get($url);
There are plenty more ways to get urls via LWP and the HTTP modules.
-- Brett
By adding the \W as in
$temp =~ s/^[a-z0-9\W]+_//i;
You can also strip any punctuation such as ' and from the string.
- Original Message -
From: Brett W McCoy [EMAIL PROTECTED]
To: Johan Groth [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, May 07, 2001 9:32 AM
On May 7, Johan Groth said:
I want to strip a variable of all characters including a token, i.e.
aaa_bbb_ccc_ddd would become bbb_ccc_ddd. As you can see I want to get rid of
aaa_. Does anyone know how to acomplish this in Perl?
I've tried:
$tmp = aaa_bbb_ccc_ddd
$tmp =~ /^\w+_/
$tmp = $';
$tmp =~ s/^([A-Za-z]+_)(.*)/\2/;
I think the problem is that \w matches an underscore also, and the regexp
is being greedy as well. There's probably an even better way to do it
(especially if your strings have foreign characters at it), but that was
what occurred to me off the top of my
On Mon, 7 May 2001, Jeff Pinyan wrote:
You're also using \2 on the right-hand side (RHS) of a s///, which is not
safe. You should use $2.
s/^[A-Za-z]+_//;
does far less work.
Yeah, I realized that after I already sent the reply. It's what I get for
popping off replies with
--- justin todd [EMAIL PROTECTED] wrote:
thanks Paul
This did the trick!!
You're very welcome.
Since that was it, do you understand why?
In Perl, single-quoted strings are not interpolated (that is, are not
parsed for special characters or variables). Thus, if
$foo='hi';
then '$foo' is
Stumped on this problem
my ( %self );
$self-{DF_SPEC} = {
a = '(Mon|Tue|Wed|Thu|Fri|Sat|Sun)',
A = '(Monday|Tuesday|Wednesday|Thursday|Friday)',
b = '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)',
B =
On May 7, Craig Moynes/Markham/IBM said:
Stumped on this problem
my ( %self );
You're creating a hash above...
$self-{DF_SPEC} = {
And then populating a hash reference ($self is not %self).
a = '(Mon|Tue|Wed|Thu|Fri|Sat|Sun)',
A =
On Mon, 7 May 2001, Craig Moynes/Markham/IBM wrote:
Stumped on this problem
my ( %self );
$self-{DF_SPEC} = {
Why do you define %self as a hash then use it is if it were a reference to
a hash? This may not be the cause of your problem, but it is an
inconsistency. Are you using -w and 'use
: $self-{DF_SPEC} = {
: ...
: c = $self-{DF_SPEC}{a} ...,
:
: };
:
: print $self-{DF_SPEC}{'b'}\n;
: print $self-{DF_SPEC}{'h'}\n;
:
:
: Produces the output:
: (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)
: blank line
:
: Any ideas ?
You're trying to use parts of the
Tried perldoc LWP::Simple
noted the example:
perl -MLWP::Simple -e 'getprint http://www.sn.no;'
so I tried:
/usr/central/bin/perl -MLWP::Simple -e 'getprint http://foo.acme.com/;'
# perl is in /usr/central/bin
on Unix the error is:
501 Protocol scheme 'hostfirewall.acme.com' is not supported
interesting ideas. I will definitely use the self-documenting
variable creation method, extra assignments be damned :)
Would it also be wise to use the qr// ?
Such as:
my $shortDayName = qr/(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/;
then for example I could do:
my $abcXYZ =
On May 7, Craig Moynes/Markham/IBM said:
interesting ideas. I will definitely use the self-documenting
variable creation method, extra assignments be damned :)
Would it also be wise to use the qr// ?
Such as:
my $shortDayName = qr/(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/;
then for example I
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
I'm trying to install Bundle::XML. Here's a quick rundown:
# perl -MCPAN -e shell
cpan install Bundle::XML
. . . many lines of output, which I'm sure is relevant . . .
PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib
-
--- Clinton [EMAIL PROTECTED] wrote:
WOW, thanks a heap. This is the best list ever.
lol -- high praise!
The final code that seems to work is:
use strict;
my $file = test.txt;
my $stuff=e:/$file;
open STUFF, $stuff or die Cannot open $stuff for read :$!;
my $file_contents = do { local
--- Tony Cook [EMAIL PROTECTED] wrote:
On Mon, 7 May 2001, Johan Groth wrote:
I want to strip a variable of all characters including a token,
aaa_bbb_ccc_ddd would become bbb_ccc_ddd.
. . .
I've tried:
$tmp = aaa_bbb_ccc_ddd
$tmp =~ /^\w+_/
$tmp = $';
but that results in $tmp
Hi Folks
I am running a IIS server and MSSQL7, both on the same machine.
The database server is called JUSTIN. The database is called test and
the table is called test.
This is my connect string.
$dbh = DBI-connect('DBI:ODBC:test','');
This is my error.
CGI Error
The specified CGI
Stephane, what you are looking for is the LWP module.. it comes standard
with any ActiveState perl release but is not standard with Linux (or at
least RedHat)
try search.cpan.org if you need to obtain and look for LWP
you'll find the documentation very informational.
Regards,
Jos Boumans
- Original Message -
From: justin todd [EMAIL PROTECTED]
To: Beginners (E-mail) [EMAIL PROTECTED]
Sent: Monday, May 07, 2001 6:30 PM
Subject: db connect
Hi Folks
I am running a IIS server and MSSQL7, both on the same machine.
The database server is called JUSTIN. The database
In other words, you need configure Windoz to add the data source. Start |
Settings | Control Panel | Data Sources (ODBC). You'll have to check your
manuals, what entries go in this section... (Beyond the scope of Perl
Beginners list).
Bruce W. Lowther
[EMAIL PROTECTED]
Micron Technology, Inc.
Hi there,
I could use some help with printing array/list contents, rather than
length. In the class I'm taking, we learned that if you print it within
a C-string, the contents will print, but if it's in scalar context (ie.
$a = @a ; print $a) then you'll get the length of the list.
In my
:@possWords = push(@possWords,$temp) ;
This line is the problem. push() returns the number of elements in the
array after the new elements have been pushed onto it. Get rid of the
@possWords = part of this line.
-- tdk
On Mon, 7 May 2001, Lonya Julin wrote:
@possWords = push(@possWords,$temp) ;
Err... this is your problem. You are pushing your value onto @possWords,
then returning the number of elements into the same array. I don't think
this is what you want. push returns a $calar value with the new
Ok I know I know how to do this but I just can't get it out of my brain
I have a string like this:
$string1 = [%a %H:%M:%S %c] - - etc.etc.etc;
I need to parse out all the substrings that are similar to %x (where x is
any letter)
I have thought about tackling this using the regexp (%\w) using
Thanks to Timothy Kimball and Brett McCoy for answers to my problem,
included below...
Original Message
Subject: Re: scalar vs. vector context
Date: Mon, 7 May 2001 15:11:37 -0400 (EDT)
From: [EMAIL PROTECTED] (Timothy Kimball)
To: [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]
: Do
: I have thought about tackling this using the regexp (%\w) using the
: grouping and getting each match with $n (where n is a number) but I can't
: seem to get the regexp to match more than the first match.
Have you tried using the g regex option? e.g., /.../g
-- tdk
--- Craig Moynes/Markham/IBM [EMAIL PROTECTED] wrote:
. . .
I have a string like this:
$string1 = [%a %H:%M:%S %c] - - etc.etc.etc;
I need to parse out all the substrings that are similar to %x
(where x is any letter)
try
my @chars = $string1 =~ /%(.)/g; #:o)
You can probably even
--- Craig Moynes/Markham/IBM [EMAIL PROTECTED] wrote:
. . .
I have a string like this:
$string1 = [%a %H:%M:%S %c] - - etc.etc.etc;
I need to parse out all the substrings that are similar to %x
(where x is any letter)
If you sepcifically need an alpha character, you might try
@x =
Craig Moynes/Markham/IBM [EMAIL PROTECTED] wrote:
I have a string like this:
$string1 = [%a %H:%M:%S %c] - - etc.etc.etc;
I need to parse out all the substrings that are similar to %x (where x is
any letter)
Use a global pattern match in array context:
@matches = $string1 =~ /%[A-Za-z]/g;
I
Thanks, I don't know why I was having so much trouble with that.
I was trying to use the $1, $2 etc variables but that didn't seem to work.
Have to buy a good perl book in addition to my O'Reilly Nutshell Book.
thanks again for the borrowing of your brains
On Mon, 7 May 2001, Craig Moynes/Markham/IBM wrote:
Thanks, I don't know why I was having so much trouble with that.
I was trying to use the $1, $2 etc variables but that didn't seem to work.
Have to buy a good perl book in addition to my O'Reilly Nutshell Book.
I can recommend ones with a
On Mon, May 07, 2001 at 02:57:54PM -0700, Paul wrote:
: Okay, my turn to ask a newbie question. =o)
:
: Our HPUX box didn't have GDBM installed, so I just downloaded and
: compiled it from GNU, but I still don't have GDBM_File.pm, and I don't
: see any way to get it aside from either dowgrading
I recommend:
Programming Perl
Learning Perl
The Perl Cookbook
Get them and use them.
Some picks from my Perl library related to what
you seem to want to do (quick and dirty parsing):
2nd and 3rd editions of the Camel (PP)
LP for perl 4.
The Cookbook
Perl for System
On Mon, 7 May 2001, Me wrote:
Data Munging with Perl is another option.
It has a very different feel from the above books.
It goes through its topics in a systematic fashion --
it seemed almost plodding to me, with perhaps
3 jokes in the entire book. However it remains a
high quality book
Hi all,
I am geting this error message while trying to run my perl script.
Can't modify reference constructor in untie at ./keeq.pl line 320, near
$dbref)
BEGIN not safe after errors--compilation aborted at ./keeq.pl line 327.
below is few portion of my script. Let me know if you can help me
On May 7, Anshu Anshu said:
Can't modify reference constructor in untie at ./keeq.pl line 320, near
$dbref)
BEGIN not safe after errors--compilation aborted at ./keeq.pl line 327.
You are trying to untie a reference to a hash. Remove the \ in front of
the variable.
316 sub close_db
317
Stephen,
I will qualifythis by saying that I am not an expert on MCPAN but
it would appear that you probably do not have the module XML::Parser
installed. Which doesn't make that much sence considering that I thought
that MCPAN checks dependencies, and that XML::Parser would look like it
Hi,
I have download some perl/cgi scripts from various web sites and
am having the darndest time getting them to work. I have my own apache
web server to work on, so cgi access is no problem. I am running FreeBSD
on my client machine to download the scripts, do the configuring, then
copy the
On Mon, 7 May 2001, Chip Wiegand wrote:
Any suggestions as to what I should be changing so I can get some scripts
to run properly?
It's hard to say, not knowing what the scripts are, what modules or
libraries they use, or what kinds of errors they are spewing out.
'Internal Server Error' can
If you have shell access to the server where the scripts live, you should
be able to see more descriptive error messages by executing the script
directly, ex:
$ /usr/local/cgi-bin/yourFile.cgi
Ross
At 07:56 PM 5/7/2001 -0700, Chip Wiegand wrote:
Hi,
I have download some perl/cgi scripts from
i have problem with send variable to other page.
i have form and the form has variable will send to other
page.
but i can't do it.
anybody can help me?
thank you
48 matches
Mail list logo