473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

substituion

i'm trying to find the price in a page source and my substition seems
not to work?
$dump =~ s/.+?Price:\s+\$([0-9][0-9].[0-9][0-9]).+/$1/s;

does anyone have a suggestion as to why it prints the whole dump file
w/o seeming to substitute the price in.
Jul 19 '05 #1
3 1658
jared in ecs wrote:
i'm trying to find the price in a page source and my substition
seems not to work?
If you are trying to _find_ something, why are you trying to _substitute_?
$dump =~ s/.+?Price:\s+\$([0-9][0-9].[0-9][0-9]).+/$1/s;


You haven't told us what $dump contains, but I imagine that it may
result in everything but the price being stripped from $dump under
certain conditions.

This is another approach:

my ($price) = $dump =~ /Price:\s+\$(\d+\.\d+)/;

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

Jul 19 '05 #2
In article <98**************************@posting.google.com >, jared in
ecs <ja*********@und.nodak.edu> wrote:
i'm trying to find the price in a page source and my substition seems
not to work?
$dump =~ s/.+?Price:\s+\$([0-9][0-9].[0-9][0-9]).+/$1/s;

does anyone have a suggestion as to why it prints the whole dump file
w/o seeming to substitute the price in.


"seems no to work" is a little vague. What is in $dump before the
substitution operator is applied? My guess is that your pattern is in
fact not matching, and no substitution is done, leaving the original
string in $dump. Perhaps your page doesn't have a space between
"Price:" and the price. If so, use 'Price:\s*$', etc. instead.

Try posting a complete (brief) program for better answers.

BTW, this newsgroup is defunct. Try comp.lang.misc.perl in the future.
Jul 19 '05 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ja*********@und.nodak.edu (jared in ecs) wrote in
news:98**************************@posting.google.c om:
i'm trying to find the price in a page source and my substition seems
not to work?
$dump =~ s/.+?Price:\s+\$([0-9][0-9].[0-9][0-9]).+/$1/s;

does anyone have a suggestion as to why it prints the whole dump file
w/o seeming to substitute the price in.


The above expression cannot print anything at all -- the s/// operator
doesn't print. What do you mean by "it prints"? Some other part of your
script is printing, that's what. Do you expect people here to be psychic?
What is in $dump before the above statement? We don't know your data.

In the future, please post questions to comp.lang.perl.misc; that's the
newsgroup for general perl questions. Comp.lang.perl is a defunct
newsgroup.

- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP5ku3GPeouIeTNHoEQJmfgCfZHl6dHOE5eg4/mUHOySB8ElIVOkAoIEi
4GylIMM+2M8B7We8jWQ0y75R
=6Tpo
-----END PGP SIGNATURE-----
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bart Nessux | last post by:
Is there a function/module that can be used to throw out extra whitespace that appears within a string? The problem that I have is this: Before any configuration is done to my files, they have...
3
by: Ondrej Krajicek | last post by:
Hello, in my application, I want to do keyword substituion in a string from a dictionary. The problem is indeed easy to solve, but seems quite common to me, so I wonder wheter there is already...
15
by: Stefan Behnel | last post by:
Hi! I'm trying to do this in Py2.4b1: ------------------------------- import logging values = {'test':'bla'} logging.log(logging.FATAL, 'Test is %(test)s', values)...
4
by: Erik Johnson | last post by:
I am still fairly new to Python and trying to learn to put RE's to good use. I am a little confused about the finditer() method. It is documented like so: finditer( pattern, string) Return an...
4
by: Damjan | last post by:
I'm using Python 2.4, cx_Oracle-4.1 on Linux with Oracle instant client 10.1.0.3. This is the sql string: SQL = """insert into D.D_NOTIFY values (:CARDREF, :BANKKEY, :OK1, :OK2 \ :DEBTEUR,...
0
by: David M. Aldridge | last post by:
(Background and details are first, with my questions at the end.) Consider the following hierarchy: Foo (abstract base) FooDerived1 FooDerived2 <...> Bar
7
by: Erwin Moller | last post by:
Hi Group, I am starting on some project and need to program all kinds of windows with buttons/textfields/etc. My natural reaction was to build this in Java, but since I like PHP so much I...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
2
by: Horacius ReX | last post by:
Hi, I have a file with a lot of the following ocurrences: denmark.handa.1-10 denmark.handa.1-12344 denmark.handa.1-4 denmark.handa.1-56 ....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.