how can I get path from a string

9 views
Skip to first unread message

LanGui TianXia

unread,
Sep 20, 2011, 1:11:29 PM9/20/11
to ack dev/users
Hello, I want to get path from a string. the string contain a path and
other information. I only know that the path is the beginning of the
string.for example, gcc error message:
"F:\DevelopeTools\hello\main.c:error:123:expected';'before 'return'
I am working on Windows Operating System now,but I hope it can run all
operating system which is install perl.is there a perl mod for me ???
thank you.

Andy Lester

unread,
Sep 20, 2011, 1:13:43 PM9/20/11
to ack-...@googlegroups.com
Sounds like you don't really need ack here.  Ack is a search tool for trees of source code.

What are you going to do with the path once you get it?

xoa

Offer Kaye

unread,
Sep 21, 2011, 7:16:14 AM9/21/11
to ack-...@googlegroups.com

Assuming you're acking from a file called "gcc_errors" which holds the
strings, you can do:

ack "^(.+?):" --output "$1" gcc_errors

That's for Windows. For Linux you will need to change the double
quotes to single quotes.

Regards,
Offer Kaye

tianxialangui

unread,
Sep 22, 2011, 11:51:12 AM9/22/11
to ack-...@googlegroups.com
I'm sorry for my poor English. I saw this group in lists.perl.org, and I made a mistake that I think of "ack" is "ask", so I think this is a perl beginner's mail-ist. how foolish I am!if I get the path, I will open the file. and do something on it. like delete it or remove it to another directory, or may be do nothing but open it on vim, it depend the file contents. Can you get me a mail-list that I can ask this problem?thanks.

Andy Lester

unread,
Sep 22, 2011, 11:52:39 AM9/22/11
to ack-...@googlegroups.com

On Sep 22, 2011, at 10:51 AM, tianxialangui wrote:

I'm sorry for my poor English. I saw this group in lists.perl.org, and I made a mistake that I think of "ack" is "ask", so I think this is a perl beginner's mail-ist. how foolish I am!if I get the path, I will open the file. and do something on it. like delete it or remove it to another directory, or may be do nothing but open it on vim, it depend the file contents. Can you get me a mail-list that I can ask this problem?thanks.

That's fine.  No harm done!

I suggest you visit http://perlmonks.org/ They are very good for questions and answers like this.

Good luck!

Andy

tianxialangui

unread,
Sep 22, 2011, 12:13:55 PM9/22/11
to ack-...@googlegroups.com
thanks. I search the "gcc_error" in google, and I find the gcc error
format is splited by ':', it's a goog news for me. regular expression
can solve this problem in Windows Operating System because it can't have
a ':' in file name and I will use this way now. but *nix Operating
System's file name can have the character ':', is there a perl mode can
help me? or use the ostrich algorithm?? I have already known I'm going
to the wrong place and sorry for asking the problem here. I will ask in
http://perlmonks.org/. thanks again for helping me.
Reply all
Reply to author
Forward
0 new messages