Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Fetching unique info

by PrimeLord (Pilgrim)
on Jun 05, 2003 at 16:15 UTC ( [id://263395]=note: print w/replies, xml ) Need Help??


in reply to Fetching unique info

I think the following code does what you are looking for.
#!/usr/bin/perl -w use strict; open IN, "filename" or die "$!"; while (<IN>) { chomp; my ($first, $info) = (split />/); my $number = (split /'/, $first)[9]; print "$number => $info\n"; } close IN or warn "$!";
So the output would look like the following:
113 => San Francisco (Manager) 680 => Los Angeles (Worker) 456 => San Jose (People)


Hope that helps.

-Prime

Replies are listed 'Best First'.
Re: Re: Fetching unique info
by Anonymous Monk on Jun 05, 2003 at 17:34 UTC
    Thanks for all the responses. I still cant fetch the information. I know its coming down to the newline problem because I tried a test by putting it on one line:  <A HREF="JavaScript:AFunction('AA', 'B','0','Project','113')">San Francisco (Manager)
    and was able to fetch the different the number that was located where "113" was located:
    use LWP::Simple; my $url = 'www.website.com'; my $content = get($url); my ($number) = $content =~ /'(\d{3})'\)">San Francisco (Manager)/; print "$number\n";
    BUT I really need to fetch the information where it is split on two lines:
    <A HREF="JavaScript:AFunction('AA', 'B','0','Project','113')"> San Francisco (Manager)
    I tried both these and still didnt get it to work:
    my ($number) = $content =~ /'(\d{3})'\)">\nSan Francisco (Manager)/;
    and:
    my ($number) = $content =~ /'(\d{3})'\)">San Francisco (Manager)/s;
      Your use of my ($number) = $content =~ /'(\d{3})'\)">\nSan Francisco (Manager)/; seems almost correct. Why don't you modify it slightly to:
      my ($number) = $content =~ /'(\d{3})'\)">\s+San Franscisco \(Manager\) +/;
      You probably can't guarantee that the newline is a literal "\n", and you didn't escape the parens around the string "Manager".
        Thanks!!!! It now works. I assume "\s+" means match any whitespace character 1 or more times?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://263395]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-19 22:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found