Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: extracting data from a line

by gothic_mallard (Pilgrim)
on Oct 28, 2004 at 07:10 UTC ( [id://403290]=note: print w/replies, xml ) Need Help??


in reply to Re^2: extracting data from a line
in thread extracting data from a line

I just ran that data line ( c:/loc1/loc2/loc3/84xxxxxB01_e1_1) through the above code and got 84xxxxxB01_e1_bot as expected, so I'm not sure why it didn't work for you.

while (<DATA>) { /\/([^\/]+)\d$/; print $1."bot\n"; } __DATA__ c:/loc1/loc2/loc3/84xxxxxB01_e1_1

--- Jay

All code is untested unless otherwise stated.
All opinions expressed are my own and are intended as guidance, not gospel; please treat what I say as such and as Abigail said Think for yourself.
If in doubt ask.

Replies are listed 'Best First'.
Re^4: extracting data from a line
by RCP (Acolyte) on Nov 02, 2004 at 16:59 UTC
    UPDATE: Before anyone could reply, I had managed
    to figure this out on my own! I was able
    to extract words between two key words and
    get the last word in a line (reverse) to
    form a new sentence.

    RCP

    Took awhile to get back to Jay..but it did work the second
    time around....Thanks again.
    I have a similar extraction request but with a twist,
    as I'm trying to extract data between any two key words,
    using a keyword to find a particular sentence.

    Data: (contains several lines of data)
    Board Name: just a test run Department: my1234
    open (FILEH, "/tmp/aform"); while (<FILEH>) { chomp; open(MYOUTFILE, ">>/tmp/new_form"); if ( /Department/ ) { $bname =~ /^Board Name:(.+)Department/; print MYOUTFILE "$bname'\n"; } close(FILEH); close(MYOUTFILE);
    I'm trying to get it to output only "just a test run"
    to a file, but all I get is an error. How can I
    also extract only the last word (my1234) from the same line?
    error message I got...
    Use of uninitialized value in pattern match (m//)
    Use of uninitialized value in concatenation (.) or string
    Thanks... RCP

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found